|
6 | 6 |
|
7 | 7 | from . import full_path |
8 | 8 | from oidcop.configure import ASConfiguration |
| 9 | + |
9 | 10 | import pytest |
10 | 11 | import yaml |
11 | 12 | from oidcmsg.message import Message |
|
16 | 17 | from oidcmsg.oidc import TokenErrorResponse |
17 | 18 |
|
18 | 19 | import oidcop.oauth2.introspection |
| 20 | +from oidcop.configure import ASConfiguration |
19 | 21 | from oidcop.configure import OPConfiguration |
20 | 22 | from oidcop.cookie_handler import CookieHandler |
21 | 23 | from oidcop.endpoint import Endpoint |
@@ -290,6 +292,41 @@ def test_not_essential(self, conf): |
290 | 292 |
|
291 | 293 | assert isinstance(_req, Message) |
292 | 294 |
|
| 295 | + def test_essential_per_client(self, conf): |
| 296 | + conf["add_on"]["pkce"]["kwargs"]["essential"] = False |
| 297 | + server = create_server(conf) |
| 298 | + authn_endpoint = server.server_get("endpoint", "authorization") |
| 299 | + token_endpoint = server.server_get("endpoint", "token") |
| 300 | + _authn_req = AUTH_REQ.copy() |
| 301 | + endpoint_context = server.server_get("endpoint_context") |
| 302 | + endpoint_context.cdb[AUTH_REQ["client_id"]]["pkce_essential"] = True |
| 303 | + |
| 304 | + _pr_resp = authn_endpoint.parse_request(_authn_req.to_dict()) |
| 305 | + |
| 306 | + assert isinstance(_pr_resp, AuthorizationErrorResponse) |
| 307 | + assert _pr_resp["error"] == "invalid_request" |
| 308 | + assert _pr_resp["error_description"] == "Missing required code_challenge" |
| 309 | + |
| 310 | + def test_not_essential_per_client(self, conf): |
| 311 | + conf["add_on"]["pkce"]["kwargs"]["essential"] = True |
| 312 | + server = create_server(conf) |
| 313 | + authn_endpoint = server.server_get("endpoint", "authorization") |
| 314 | + token_endpoint = server.server_get("endpoint", "token") |
| 315 | + _authn_req = AUTH_REQ.copy() |
| 316 | + endpoint_context = server.server_get("endpoint_context") |
| 317 | + endpoint_context.cdb[AUTH_REQ["client_id"]]["pkce_essential"] = False |
| 318 | + |
| 319 | + _pr_resp = authn_endpoint.parse_request(_authn_req.to_dict()) |
| 320 | + resp = authn_endpoint.process_request(_pr_resp) |
| 321 | + |
| 322 | + assert isinstance(resp["response_args"], AuthorizationResponse) |
| 323 | + |
| 324 | + _token_request = TOKEN_REQ.copy() |
| 325 | + _token_request["code"] = resp["response_args"]["code"] |
| 326 | + _req = token_endpoint.parse_request(_token_request) |
| 327 | + |
| 328 | + assert isinstance(_req, Message) |
| 329 | + |
293 | 330 | def test_unknown_code_challenge_method(self): |
294 | 331 | _authn_req = AUTH_REQ.copy() |
295 | 332 | _authn_req["code_challenge"] = "aba" |
|
0 commit comments