Skip to content

Commit

Permalink
✅ [#99] Add test for IPD availability check mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed May 13, 2024
1 parent 994a9c2 commit 185d250
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_init_flow_custom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import pytest

from mozilla_django_oidc_db.exceptions import OIDCProviderOutage
from mozilla_django_oidc_db.models import OpenIDConnectConfig
from mozilla_django_oidc_db.views import OIDCInit

Expand Down Expand Up @@ -88,3 +89,18 @@ def test_suspicious_return_url(auth_request):
def test_forgotten_return_url(auth_request, get_kwargs):
with pytest.raises(ValueError):
oidc_init(auth_request, **get_kwargs)


class IDPCheckInitView(OIDCInit):
def check_idp_availability(self) -> None:
raise OIDCProviderOutage("The internet is bwoken.")


oidc_init_with_idp_check = IDPCheckInitView.as_view(
config_class=CustomConfig, allow_next_from_query=True
)


def test_idp_check_mechanism(auth_request):
with pytest.raises(OIDCProviderOutage):
oidc_init_with_idp_check(auth_request)

0 comments on commit 185d250

Please sign in to comment.