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