|
6 | 6 | from django.utils import timezone
|
7 | 7 | from pytest_django.asserts import assertRedirects
|
8 | 8 |
|
9 |
| -from oauth2_provider.exceptions import ClientIdMissmatch, InvalidOIDCClientError, InvalidOIDCRedirectURIError |
| 9 | +from oauth2_provider.exceptions import ( |
| 10 | + ClientIdMissmatch, |
| 11 | + InvalidIDTokenError, |
| 12 | + InvalidOIDCClientError, |
| 13 | + InvalidOIDCRedirectURIError, |
| 14 | +) |
10 | 15 | from oauth2_provider.models import get_access_token_model, get_id_token_model, get_refresh_token_model
|
11 | 16 | from oauth2_provider.oauth2_validators import OAuth2Validator
|
12 | 17 | from oauth2_provider.settings import oauth2_settings
|
@@ -236,6 +241,13 @@ def test_deprecated_validate_logout_request(
|
236 | 241 | client_id=client_id,
|
237 | 242 | post_logout_redirect_uri="http://example.org",
|
238 | 243 | ) == (ALWAYS_PROMPT, ("http://example.org", application), oidc_tokens.user)
|
| 244 | + with pytest.raises(InvalidIDTokenError): |
| 245 | + validate_logout_request( |
| 246 | + request=mock_request_for(oidc_tokens.user), |
| 247 | + id_token_hint="111", |
| 248 | + client_id=public_application.client_id, |
| 249 | + post_logout_redirect_uri="http://other.org", |
| 250 | + ) |
239 | 251 | with pytest.raises(ClientIdMissmatch):
|
240 | 252 | validate_logout_request(
|
241 | 253 | request=mock_request_for(oidc_tokens.user),
|
@@ -271,10 +283,18 @@ def test_deprecated_validate_logout_request(
|
271 | 283 | client_id=client_id,
|
272 | 284 | post_logout_redirect_uri="http://other.org",
|
273 | 285 | )
|
| 286 | + with pytest.raises(InvalidOIDCRedirectURIError): |
| 287 | + rp_settings.OIDC_RP_INITIATED_LOGOUT_STRICT_REDIRECT_URIS = True |
| 288 | + validate_logout_request( |
| 289 | + request=mock_request_for(oidc_tokens.user), |
| 290 | + id_token_hint=None, |
| 291 | + client_id=public_application.client_id, |
| 292 | + post_logout_redirect_uri="http://other.org", |
| 293 | + ) |
274 | 294 |
|
275 | 295 |
|
276 | 296 | @pytest.mark.django_db
|
277 |
| -def test_validate_logout_request(oidc_tokens, public_application): |
| 297 | +def test_validate_logout_request(oidc_tokens, public_application, rp_settings): |
278 | 298 | oidc_tokens = oidc_tokens
|
279 | 299 | application = oidc_tokens.application
|
280 | 300 | client_id = application.client_id
|
@@ -306,6 +326,12 @@ def test_validate_logout_request(oidc_tokens, public_application):
|
306 | 326 | client_id=client_id,
|
307 | 327 | post_logout_redirect_uri="http://example.org",
|
308 | 328 | ) == (application, oidc_tokens.user)
|
| 329 | + with pytest.raises(InvalidIDTokenError): |
| 330 | + view.validate_logout_request( |
| 331 | + id_token_hint="111", |
| 332 | + client_id=public_application.client_id, |
| 333 | + post_logout_redirect_uri="http://other.org", |
| 334 | + ) |
309 | 335 | with pytest.raises(ClientIdMissmatch):
|
310 | 336 | view.validate_logout_request(
|
311 | 337 | id_token_hint=id_token,
|
@@ -336,6 +362,13 @@ def test_validate_logout_request(oidc_tokens, public_application):
|
336 | 362 | client_id=client_id,
|
337 | 363 | post_logout_redirect_uri="http://other.org",
|
338 | 364 | )
|
| 365 | + with pytest.raises(InvalidOIDCRedirectURIError): |
| 366 | + rp_settings.OIDC_RP_INITIATED_LOGOUT_STRICT_REDIRECT_URIS = True |
| 367 | + view.validate_logout_request( |
| 368 | + id_token_hint=None, |
| 369 | + client_id=public_application.client_id, |
| 370 | + post_logout_redirect_uri="http://other.org", |
| 371 | + ) |
339 | 372 |
|
340 | 373 |
|
341 | 374 | @pytest.mark.django_db
|
|
0 commit comments