diff --git a/benefits/core/context_processors.py b/benefits/core/context_processors.py index d56ee43be..79fdffe01 100644 --- a/benefits/core/context_processors.py +++ b/benefits/core/context_processors.py @@ -55,7 +55,7 @@ def authentication(request): "logged_in": session.logged_in(request), } - if verifier.uses_auth_verification: + if verifier.uses_claims_verification: data["sign_out_button_template"] = verifier.claims_provider.sign_out_button_template data["sign_out_link_template"] = verifier.claims_provider.sign_out_link_template diff --git a/benefits/core/middleware.py b/benefits/core/middleware.py index d0bc65330..4d2e18de3 100644 --- a/benefits/core/middleware.py +++ b/benefits/core/middleware.py @@ -129,9 +129,9 @@ class LoginRequired(MiddlewareMixin): """Middleware that checks whether a user is logged in.""" def process_view(self, request, view_func, view_args, view_kwargs): - # only require login if verifier requires it + # only require login if verifier uses claims verification verifier = session.verifier(request) - if not verifier or not verifier.uses_auth_verification or session.logged_in(request): + if not verifier or not verifier.uses_claims_verification or session.logged_in(request): # pass through return None diff --git a/benefits/core/models.py b/benefits/core/models.py index b6de5a797..d9b287a86 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -214,7 +214,7 @@ def public_key_data(self): return self.public_key.data @property - def uses_auth_verification(self): + def uses_claims_verification(self): """True if this Verifier verifies via the claims provider. False otherwise.""" return self.claims_provider is not None and self.claims_provider.supports_claims_verification diff --git a/benefits/eligibility/verify.py b/benefits/eligibility/verify.py index b89c5d987..d70674bdd 100644 --- a/benefits/eligibility/verify.py +++ b/benefits/eligibility/verify.py @@ -30,7 +30,7 @@ def eligibility_from_api(verifier, form, agency): def eligibility_from_oauth(verifier, oauth_claim, agency): - if verifier.uses_auth_verification and verifier.claims_provider.claim == oauth_claim: + if verifier.uses_claims_verification and verifier.claims_provider.claim == oauth_claim: return agency.type_names_to_verify(verifier) else: return [] diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py index a5b476752..221312143 100644 --- a/benefits/eligibility/views.py +++ b/benefits/eligibility/views.py @@ -102,7 +102,7 @@ def confirm(request): types_to_verify = agency.type_names_to_verify(verifier) # GET for OAuth verification - if request.method == "GET" and verifier.uses_auth_verification: + if request.method == "GET" and verifier.uses_claims_verification: analytics.started_eligibility(request, types_to_verify) verified_types = verify.eligibility_from_oauth(verifier, session.oauth_claim(request), agency) diff --git a/benefits/oauth/analytics.py b/benefits/oauth/analytics.py index c206cae72..c68789483 100644 --- a/benefits/oauth/analytics.py +++ b/benefits/oauth/analytics.py @@ -11,7 +11,7 @@ class OAuthEvent(core.Event): def __init__(self, request, event_type): super().__init__(request, event_type) verifier = session.verifier(request) - if verifier and verifier.uses_auth_verification: + if verifier and verifier.uses_claims_verification: self.update_event_properties(auth_provider=verifier.claims_provider.client_name) diff --git a/benefits/oauth/middleware.py b/benefits/oauth/middleware.py index 81b972bc8..19f3a443b 100644 --- a/benefits/oauth/middleware.py +++ b/benefits/oauth/middleware.py @@ -24,7 +24,7 @@ def process_request(self, request): verifier = session.verifier(request) - if verifier.uses_auth_verification: + if verifier.uses_claims_verification: # all good, the chosen verifier is configured correctly return None elif not (verifier.api_url or verifier.form_class): diff --git a/tests/pytest/conftest.py b/tests/pytest/conftest.py index 25d6da110..c44f605c6 100644 --- a/tests/pytest/conftest.py +++ b/tests/pytest/conftest.py @@ -60,7 +60,7 @@ def model_ClaimsProvider(): @pytest.fixture -def model_ClaimsProvider_with_verification(model_ClaimsProvider): +def model_ClaimsProvider_with_scope_and_claim(model_ClaimsProvider): model_ClaimsProvider.scope = "scope" model_ClaimsProvider.claim = "claim" model_ClaimsProvider.save() @@ -69,7 +69,7 @@ def model_ClaimsProvider_with_verification(model_ClaimsProvider): @pytest.fixture -def model_ClaimsProvider_with_verification_no_sign_out(model_ClaimsProvider): +def model_ClaimsProvider_with_scope_and_claim_no_sign_out(model_ClaimsProvider): model_ClaimsProvider.scope = "scope" model_ClaimsProvider.claim = "claim" model_ClaimsProvider.sign_out_button_template = None @@ -80,7 +80,7 @@ def model_ClaimsProvider_with_verification_no_sign_out(model_ClaimsProvider): @pytest.fixture -def model_ClaimsProvider_without_verification(model_ClaimsProvider): +def model_ClaimsProvider_no_scope_and_claim(model_ClaimsProvider): model_ClaimsProvider.scope = None model_ClaimsProvider.claim = None model_ClaimsProvider.save() @@ -89,7 +89,7 @@ def model_ClaimsProvider_without_verification(model_ClaimsProvider): @pytest.fixture -def model_ClaimsProvider_without_verification_no_sign_out(model_ClaimsProvider): +def model_ClaimsProvider_no_scope_and_claim_no_sign_out(model_ClaimsProvider): model_ClaimsProvider.scope = None model_ClaimsProvider.claim = None model_ClaimsProvider.sign_out_button_template = None @@ -168,10 +168,10 @@ def model_EligibilityVerifier(model_PemData, model_EligibilityType): @pytest.fixture -def model_EligibilityVerifier_ClaimsProvider_with_verification( - model_ClaimsProvider_with_verification, model_EligibilityVerifier +def model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim( + model_ClaimsProvider_with_scope_and_claim, model_EligibilityVerifier ): - model_EligibilityVerifier.claims_provider = model_ClaimsProvider_with_verification + model_EligibilityVerifier.claims_provider = model_ClaimsProvider_with_scope_and_claim model_EligibilityVerifier.save() return model_EligibilityVerifier @@ -278,36 +278,36 @@ def mocked_session_verifier(mocker, model_EligibilityVerifier): @pytest.fixture -def mocked_session_verifier_oauth(mocker, model_EligibilityVerifier_ClaimsProvider_with_verification): +def mocked_session_verifier_oauth(mocker, model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim): return mocker.patch( "benefits.core.session.verifier", autospec=True, - return_value=model_EligibilityVerifier_ClaimsProvider_with_verification, + return_value=model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim, ) @pytest.fixture -def mocked_session_verifier_uses_auth_verification( - model_EligibilityVerifier_ClaimsProvider_with_verification, mocked_session_verifier_oauth +def mocked_session_verifier_uses_claims_verification( + model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim, mocked_session_verifier_oauth ): - mock_verifier = model_EligibilityVerifier_ClaimsProvider_with_verification - mock_verifier.name = model_EligibilityVerifier_ClaimsProvider_with_verification.name + mock_verifier = model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim + mock_verifier.name = model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim.name mock_verifier.claims_provider.sign_out_button_template = ( - model_EligibilityVerifier_ClaimsProvider_with_verification.claims_provider.sign_out_button_template + model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim.claims_provider.sign_out_button_template ) mock_verifier.claims_provider.sign_out_link_template = ( - model_EligibilityVerifier_ClaimsProvider_with_verification.claims_provider.sign_out_link_template + model_EligibilityVerifier_ClaimsProvider_with_scope_and_claim.claims_provider.sign_out_link_template ) mocked_session_verifier_oauth.return_value = mock_verifier return mocked_session_verifier_oauth @pytest.fixture -def mocked_session_verifier_does_not_use_auth_verification( - mocked_session_verifier_uses_auth_verification, model_ClaimsProvider_without_verification +def mocked_session_verifier_does_not_use_claims_verification( + mocked_session_verifier_uses_claims_verification, model_ClaimsProvider_no_scope_and_claim ): - mocked_verifier = mocked_session_verifier_uses_auth_verification - mocked_verifier.claims_provider = model_ClaimsProvider_without_verification + mocked_verifier = mocked_session_verifier_uses_claims_verification + mocked_verifier.claims_provider = model_ClaimsProvider_no_scope_and_claim return mocked_verifier diff --git a/tests/pytest/core/test_middleware_login_required.py b/tests/pytest/core/test_middleware_login_required.py index 048e950df..c8ef7e456 100644 --- a/tests/pytest/core/test_middleware_login_required.py +++ b/tests/pytest/core/test_middleware_login_required.py @@ -16,7 +16,7 @@ def decorated_view(mocked_view): @pytest.mark.django_db @pytest.mark.usefixtures("mocked_session_verifier_oauth") -def test_login_auth_required(app_request, mocked_view, decorated_view): +def test_login_verifier_uses_claims_verification(app_request, mocked_view, decorated_view): response = decorated_view(app_request) mocked_view.assert_not_called() @@ -26,9 +26,9 @@ def test_login_auth_required(app_request, mocked_view, decorated_view): @pytest.mark.django_db -def test_login_auth_not_required(app_request, model_EligibilityVerifier, mocked_view, decorated_view): +def test_login_verifier_does_not_use_claims_verification(app_request, model_EligibilityVerifier, mocked_view, decorated_view): model_EligibilityVerifier.claims_provider = None - assert not model_EligibilityVerifier.uses_auth_verification + assert not model_EligibilityVerifier.uses_claims_verification session.update(app_request, verifier=model_EligibilityVerifier) decorated_view(app_request) diff --git a/tests/pytest/core/test_models.py b/tests/pytest/core/test_models.py index a34bbc0eb..b31969e37 100644 --- a/tests/pytest/core/test_models.py +++ b/tests/pytest/core/test_models.py @@ -108,25 +108,25 @@ def test_model_ClaimsProvider_client_id(model_ClaimsProvider, mock_models_get_se @pytest.mark.django_db -def test_model_ClaimsProvider_with_verification(model_ClaimsProvider_with_verification): - assert model_ClaimsProvider_with_verification.supports_claims_verification +def test_model_ClaimsProvider_with_scope_and_claim(model_ClaimsProvider_with_scope_and_claim): + assert model_ClaimsProvider_with_scope_and_claim.supports_claims_verification @pytest.mark.django_db -def test_model_ClaimsProvider_with_verification_no_sign_out(model_ClaimsProvider_with_verification_no_sign_out): - assert model_ClaimsProvider_with_verification_no_sign_out.supports_claims_verification - assert not model_ClaimsProvider_with_verification_no_sign_out.supports_sign_out +def test_model_ClaimsProvider_with_scope_and_claim_no_sign_out(model_ClaimsProvider_with_scope_and_claim_no_sign_out): + assert model_ClaimsProvider_with_scope_and_claim_no_sign_out.supports_claims_verification + assert not model_ClaimsProvider_with_scope_and_claim_no_sign_out.supports_sign_out @pytest.mark.django_db -def test_model_ClaimsProvider_without_verification(model_ClaimsProvider_without_verification): - assert not model_ClaimsProvider_without_verification.supports_claims_verification +def test_model_ClaimsProvider_no_scope_and_claim(model_ClaimsProvider_no_scope_and_claim): + assert not model_ClaimsProvider_no_scope_and_claim.supports_claims_verification @pytest.mark.django_db -def test_model_ClaimsProvider_without_verification_no_sign_out(model_ClaimsProvider_without_verification_no_sign_out): - assert not model_ClaimsProvider_without_verification_no_sign_out.supports_claims_verification - assert not model_ClaimsProvider_without_verification_no_sign_out.supports_sign_out +def test_model_ClaimsProvider_no_scope_and_claim_no_sign_out(model_ClaimsProvider_no_scope_and_claim_no_sign_out): + assert not model_ClaimsProvider_no_scope_and_claim_no_sign_out.supports_claims_verification + assert not model_ClaimsProvider_no_scope_and_claim_no_sign_out.supports_sign_out @pytest.mark.django_db @@ -292,46 +292,46 @@ def test_EligibilityVerifier_by_id_nonmatching(): @pytest.mark.django_db -def test_EligibilityVerifier_with_ClaimsProvider_with_verification( - model_EligibilityVerifier, model_ClaimsProvider_with_verification +def test_EligibilityVerifier_with_ClaimsProvider_with_scope_and_claim( + model_EligibilityVerifier, model_ClaimsProvider_with_scope_and_claim ): - model_EligibilityVerifier.claims_provider = model_ClaimsProvider_with_verification + model_EligibilityVerifier.claims_provider = model_ClaimsProvider_with_scope_and_claim - assert model_EligibilityVerifier.uses_auth_verification + assert model_EligibilityVerifier.uses_claims_verification @pytest.mark.django_db -def test_EligibilityVerifier_with_ClaimsProvider_with_verification_no_sign_out( - model_EligibilityVerifier, model_ClaimsProvider_with_verification_no_sign_out +def test_EligibilityVerifier_with_ClaimsProvider_with_scope_and_claim_no_sign_out( + model_EligibilityVerifier, model_ClaimsProvider_with_scope_and_claim_no_sign_out ): - model_EligibilityVerifier.claims_provider = model_ClaimsProvider_with_verification_no_sign_out + model_EligibilityVerifier.claims_provider = model_ClaimsProvider_with_scope_and_claim_no_sign_out - assert model_EligibilityVerifier.uses_auth_verification + assert model_EligibilityVerifier.uses_claims_verification @pytest.mark.django_db -def test_EligibilityVerifier_with_ClaimsProvider_without_verification( - model_EligibilityVerifier, model_ClaimsProvider_without_verification +def test_EligibilityVerifier_with_ClaimsProvider_no_scope_and_claim( + model_EligibilityVerifier, model_ClaimsProvider_no_scope_and_claim ): - model_EligibilityVerifier.claims_provider = model_ClaimsProvider_without_verification + model_EligibilityVerifier.claims_provider = model_ClaimsProvider_no_scope_and_claim - assert not model_EligibilityVerifier.uses_auth_verification + assert not model_EligibilityVerifier.uses_claims_verification @pytest.mark.django_db -def test_EligibilityVerifier_with_ClaimsProvider_without_verification_no_sign_out( - model_EligibilityVerifier, model_ClaimsProvider_without_verification_no_sign_out +def test_EligibilityVerifier_with_ClaimsProvider_no_scope_and_claim_no_sign_out( + model_EligibilityVerifier, model_ClaimsProvider_no_scope_and_claim_no_sign_out ): - model_EligibilityVerifier.claims_provider = model_ClaimsProvider_without_verification_no_sign_out + model_EligibilityVerifier.claims_provider = model_ClaimsProvider_no_scope_and_claim_no_sign_out - assert not model_EligibilityVerifier.uses_auth_verification + assert not model_EligibilityVerifier.uses_claims_verification @pytest.mark.django_db -def test_EligibilityVerifier_without_ClaimsProvider(model_EligibilityVerifier): +def test_EligibilityVerifier_no_ClaimsProvider(model_EligibilityVerifier): model_EligibilityVerifier.claims_provider = None - assert not model_EligibilityVerifier.uses_auth_verification + assert not model_EligibilityVerifier.uses_claims_verification @pytest.mark.django_db diff --git a/tests/pytest/eligibility/test_verify.py b/tests/pytest/eligibility/test_verify.py index f10eba942..8efbada34 100644 --- a/tests/pytest/eligibility/test_verify.py +++ b/tests/pytest/eligibility/test_verify.py @@ -52,12 +52,12 @@ def test_eligibility_from_api_no_verified_types( @pytest.mark.django_db -def test_eligibility_from_oauth_does_not_use_auth_verification( - mocked_session_verifier_does_not_use_auth_verification, model_TransitAgency +def test_eligibility_from_oauth_does_not_use_claims_verification( + mocked_session_verifier_does_not_use_claims_verification, model_TransitAgency ): - # mocked_session_verifier_does_not_use_auth_verification is Mocked version of the session.verifier() function + # mocked_session_verifier_does_not_use_claims_verification is Mocked version of the session.verifier() function # call it (with a None request) to return a verifier object - verifier = mocked_session_verifier_does_not_use_auth_verification(None) + verifier = mocked_session_verifier_does_not_use_claims_verification(None) types = eligibility_from_oauth(verifier, "claim", model_TransitAgency) @@ -65,11 +65,11 @@ def test_eligibility_from_oauth_does_not_use_auth_verification( @pytest.mark.django_db -def test_eligibility_from_oauth_auth_claim_mismatch(mocked_session_verifier_uses_auth_verification, model_TransitAgency): - # mocked_session_verifier_uses_auth_verification is Mocked version of the session.verifier() function +def test_eligibility_from_oauth_claim_mismatch(mocked_session_verifier_uses_claims_verification, model_TransitAgency): + # mocked_session_verifier_uses_claims_verification is Mocked version of the session.verifier() function # call it (with a None request) to return a verifier object - verifier = mocked_session_verifier_uses_auth_verification(None) - verifier.auth_claim = "claim" + verifier = mocked_session_verifier_uses_claims_verification(None) + verifier.claim = "claim" types = eligibility_from_oauth(verifier, "some_other_claim", model_TransitAgency) @@ -77,12 +77,12 @@ def test_eligibility_from_oauth_auth_claim_mismatch(mocked_session_verifier_uses @pytest.mark.django_db -def test_eligibility_from_oauth_auth_claim_match( - mocked_session_verifier_uses_auth_verification, model_EligibilityType, model_TransitAgency +def test_eligibility_from_oauth_claim_match( + mocked_session_verifier_uses_claims_verification, model_EligibilityType, model_TransitAgency ): - # mocked_session_verifier_uses_auth_verification is Mocked version of the session.verifier() function + # mocked_session_verifier_uses_claims_verification is Mocked version of the session.verifier() function # call it (with a None request) to return a verifier object - verifier = mocked_session_verifier_uses_auth_verification.return_value + verifier = mocked_session_verifier_uses_claims_verification.return_value verifier.claims_provider.claim = "claim" verifier.eligibility_type = model_EligibilityType diff --git a/tests/pytest/eligibility/test_views.py b/tests/pytest/eligibility/test_views.py index 6c05e2158..904ee80fe 100644 --- a/tests/pytest/eligibility/test_views.py +++ b/tests/pytest/eligibility/test_views.py @@ -172,9 +172,9 @@ def test_index_calls_session_logout(client, session_logout_spy): @pytest.mark.django_db @pytest.mark.usefixtures( - "mocked_session_agency", "mocked_verifier_selection_form", "mocked_session_verifier_uses_auth_verification" + "mocked_session_agency", "mocked_verifier_selection_form", "mocked_session_verifier_uses_claims_verification" ) -def test_start_verifier_auth_required_logged_in(mocker, client): +def test_start_verifier_uses_claims_verification_logged_in(mocker, client): mock_session = mocker.patch("benefits.eligibility.views.session") mock_session.logged_in.return_value = True @@ -186,9 +186,9 @@ def test_start_verifier_auth_required_logged_in(mocker, client): @pytest.mark.django_db @pytest.mark.usefixtures( - "mocked_session_agency", "mocked_verifier_selection_form", "mocked_session_verifier_uses_auth_verification" + "mocked_session_agency", "mocked_verifier_selection_form", "mocked_session_verifier_uses_claims_verification" ) -def test_start_verifier_auth_required_not_logged_in(mocker, client): +def test_start_verifier_uses_claims_verification_not_logged_in(mocker, client): mock_session = mocker.patch("benefits.eligibility.views.session") mock_session.logged_in.return_value = False @@ -200,9 +200,9 @@ def test_start_verifier_auth_required_not_logged_in(mocker, client): @pytest.mark.django_db @pytest.mark.usefixtures( - "mocked_session_agency", "mocked_verifier_selection_form", "mocked_session_verifier_does_not_use_auth_verification" + "mocked_session_agency", "mocked_verifier_selection_form", "mocked_session_verifier_does_not_use_claims_verification" ) -def test_start_verifier_auth_not_required(client): +def test_start_verifier_does_not_use_claims_verification(client): path = reverse(ROUTE_START) response = client.get(path) diff --git a/tests/pytest/enrollment/test_views.py b/tests/pytest/enrollment/test_views.py index ec34205a1..8d9d6082b 100644 --- a/tests/pytest/enrollment/test_views.py +++ b/tests/pytest/enrollment/test_views.py @@ -839,7 +839,7 @@ def test_success_no_verifier(client): @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_session_eligibility") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_session_eligibility") def test_success_authentication_logged_in(mocker, client, model_TransitAgency, model_EligibilityType, mocked_analytics_module): mock_session = mocker.patch("benefits.enrollment.views.session") mock_session.logged_in.return_value = True @@ -856,7 +856,7 @@ def test_success_authentication_logged_in(mocker, client, model_TransitAgency, m @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_session_eligibility") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_session_eligibility") def test_success_authentication_not_logged_in( mocker, client, model_TransitAgency, model_EligibilityType, mocked_analytics_module ): @@ -875,7 +875,7 @@ def test_success_authentication_not_logged_in( @pytest.mark.django_db @pytest.mark.usefixtures( - "mocked_session_agency", "mocked_session_verifier_does_not_use_auth_verification", "mocked_session_eligibility" + "mocked_session_agency", "mocked_session_verifier_does_not_use_claims_verification", "mocked_session_eligibility" ) def test_success_no_authentication(mocker, client, model_EligibilityType, mocked_analytics_module): mock_session = mocker.patch("benefits.enrollment.views.session") diff --git a/tests/pytest/oauth/test_analytics.py b/tests/pytest/oauth/test_analytics.py index 499f8dd54..f4b26ae0b 100644 --- a/tests/pytest/oauth/test_analytics.py +++ b/tests/pytest/oauth/test_analytics.py @@ -4,10 +4,10 @@ @pytest.mark.django_db -def test_OAuthEvent_verifier_client_name_when_uses_auth_verification( - app_request, mocked_session_verifier_uses_auth_verification +def test_OAuthEvent_verifier_client_name_when_uses_claims_verification( + app_request, mocked_session_verifier_uses_claims_verification ): - mocked_verifier = mocked_session_verifier_uses_auth_verification(app_request) + mocked_verifier = mocked_session_verifier_uses_claims_verification(app_request) mocked_verifier.claims_provider.client_name = "ClientName" event = OAuthEvent(app_request, "event type") @@ -17,15 +17,15 @@ def test_OAuthEvent_verifier_client_name_when_uses_auth_verification( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_does_not_use_auth_verification") -def test_OAuthEvent_verifier_no_client_name_when_does_not_use_auth_verification(app_request): +@pytest.mark.usefixtures("mocked_session_verifier_does_not_use_claims_verification") +def test_OAuthEvent_verifier_no_client_name_when_does_not_use_claims_verification(app_request): event = OAuthEvent(app_request, "event type") assert "auth_provider" not in event.event_properties @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_OAuthErrorEvent(app_request): event_default = OAuthErrorEvent(app_request, "the message", "the operation") diff --git a/tests/pytest/oauth/test_middleware_authverifier_required.py b/tests/pytest/oauth/test_middleware_authverifier_required.py index 31cf9b7e5..ec4106911 100644 --- a/tests/pytest/oauth/test_middleware_authverifier_required.py +++ b/tests/pytest/oauth/test_middleware_authverifier_required.py @@ -34,7 +34,7 @@ def test_authverifier_required_no_verifier(app_request, mocked_view, decorated_v @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_does_not_use_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_does_not_use_claims_verification") def test_authverifier_required_no_authverifier(app_request, mocked_view, decorated_view): response = decorated_view(app_request) @@ -49,15 +49,15 @@ def test_authverifier_required_misconfigured_verifier( app_request, mocked_view, decorated_view, - mocked_session_verifier_does_not_use_auth_verification, + mocked_session_verifier_does_not_use_claims_verification, mocked_analytics_module, mocked_sentry_sdk_module, api_url, form_class, ): # fake a misconfigured verifier - mocked_session_verifier_does_not_use_auth_verification.return_value.api_url = api_url - mocked_session_verifier_does_not_use_auth_verification.return_value.form_class = form_class + mocked_session_verifier_does_not_use_claims_verification.return_value.api_url = api_url + mocked_session_verifier_does_not_use_claims_verification.return_value.form_class = form_class response = decorated_view(app_request) diff --git a/tests/pytest/oauth/test_views.py b/tests/pytest/oauth/test_views.py index 71c7631c2..80df6cfe8 100644 --- a/tests/pytest/oauth/test_views.py +++ b/tests/pytest/oauth/test_views.py @@ -49,17 +49,17 @@ def mocked_oauth_client_or_error_redirect__error(mocked_oauth_create_client): @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_oauth_client_or_error_redirect_no_oauth_client( app_request, - model_ClaimsProvider_with_verification, + model_ClaimsProvider_with_scope_and_claim, mocked_oauth_create_client, mocked_analytics_module, mocked_sentry_sdk_module, ): mocked_oauth_create_client.return_value = None - result = _oauth_client_or_error_redirect(app_request, model_ClaimsProvider_with_verification) + result = _oauth_client_or_error_redirect(app_request, model_ClaimsProvider_with_scope_and_claim) assert result.status_code == 302 assert result.url == reverse(ROUTE_SYSTEM_ERROR) @@ -68,11 +68,11 @@ def test_oauth_client_or_error_redirect_no_oauth_client( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_oauth_client_or_error_redirect__error") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_oauth_client_or_error_redirect__error") def test_oauth_client_or_error_redirect_oauth_client_exception( - app_request, model_ClaimsProvider_with_verification, mocked_analytics_module, mocked_sentry_sdk_module + app_request, model_ClaimsProvider_with_scope_and_claim, mocked_analytics_module, mocked_sentry_sdk_module ): - result = _oauth_client_or_error_redirect(app_request, model_ClaimsProvider_with_verification) + result = _oauth_client_or_error_redirect(app_request, model_ClaimsProvider_with_scope_and_claim) assert result.status_code == 302 assert result.url == reverse(ROUTE_SYSTEM_ERROR) @@ -81,11 +81,11 @@ def test_oauth_client_or_error_redirect_oauth_client_exception( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_oauth_create_client") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_oauth_create_client") def test_oauth_client_or_error_oauth_client( - app_request, model_ClaimsProvider_with_verification, mocked_analytics_module, mocked_sentry_sdk_module + app_request, model_ClaimsProvider_with_scope_and_claim, mocked_analytics_module, mocked_sentry_sdk_module ): - result = _oauth_client_or_error_redirect(app_request, model_ClaimsProvider_with_verification) + result = _oauth_client_or_error_redirect(app_request, model_ClaimsProvider_with_scope_and_claim) assert hasattr(result, "authorize_redirect") mocked_analytics_module.error.assert_not_called() @@ -93,7 +93,7 @@ def test_oauth_client_or_error_oauth_client( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_oauth_client_or_error_redirect__error") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_oauth_client_or_error_redirect__error") def test_login_oauth_client_init_error(app_request, mocked_analytics_module): result = login(app_request) @@ -111,7 +111,7 @@ def test_login_no_session_verifier(app_request): @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_login(app_request, mocked_oauth_client_or_error_redirect__client, mocked_analytics_module): assert not session.logged_in(app_request) mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value @@ -126,7 +126,7 @@ def test_login(app_request, mocked_oauth_client_or_error_redirect__client, mocke @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_login_authorize_redirect_exception( app_request, mocked_oauth_client_or_error_redirect__client, mocked_analytics_module, mocked_sentry_sdk_module ): @@ -142,7 +142,7 @@ def test_login_authorize_redirect_exception( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") @pytest.mark.parametrize("status_code", [400, 401, 403, 404, 500, 501, 503]) def test_login_authorize_redirect_error_response( app_request, mocked_oauth_client_or_error_redirect__client, mocked_analytics_module, mocked_sentry_sdk_module, status_code @@ -159,7 +159,7 @@ def test_login_authorize_redirect_error_response( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_oauth_client_or_error_redirect__error") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_oauth_client_or_error_redirect__error") def test_authorize_oauth_client_init_error(app_request, mocked_analytics_module, mocked_sentry_sdk_module): result = authorize(app_request) @@ -178,7 +178,7 @@ def test_authorize_no_session_verifier(app_request): @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_authorize_error( mocked_oauth_client_or_error_redirect__client, mocked_analytics_module, mocked_sentry_sdk_module, app_request ): @@ -198,7 +198,7 @@ def test_authorize_error( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_authorize_empty_token( mocked_oauth_client_or_error_redirect__client, mocked_analytics_module, mocked_sentry_sdk_module, app_request ): @@ -218,7 +218,7 @@ def test_authorize_empty_token( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_authorize_success(mocked_oauth_client_or_error_redirect__client, mocked_analytics_module, app_request): mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token"} @@ -236,9 +236,9 @@ def test_authorize_success(mocked_oauth_client_or_error_redirect__client, mocked @pytest.mark.django_db @pytest.mark.usefixtures("mocked_analytics_module") def test_authorize_success_with_claim_true( - app_request, mocked_session_verifier_uses_auth_verification, mocked_oauth_client_or_error_redirect__client + app_request, mocked_session_verifier_uses_claims_verification, mocked_oauth_client_or_error_redirect__client ): - verifier = mocked_session_verifier_uses_auth_verification.return_value + verifier = mocked_session_verifier_uses_claims_verification.return_value verifier.claims_provider.claim = "claim" mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": "1"}} @@ -254,9 +254,9 @@ def test_authorize_success_with_claim_true( @pytest.mark.django_db @pytest.mark.usefixtures("mocked_analytics_module") def test_authorize_success_with_claim_false( - app_request, mocked_session_verifier_uses_auth_verification, mocked_oauth_client_or_error_redirect__client + app_request, mocked_session_verifier_uses_claims_verification, mocked_oauth_client_or_error_redirect__client ): - verifier = mocked_session_verifier_uses_auth_verification.return_value + verifier = mocked_session_verifier_uses_claims_verification.return_value verifier.claims_provider.claim = "claim" mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": "0"}} @@ -272,11 +272,11 @@ def test_authorize_success_with_claim_false( @pytest.mark.django_db def test_authorize_success_with_claim_error( app_request, - mocked_session_verifier_uses_auth_verification, + mocked_session_verifier_uses_claims_verification, mocked_oauth_client_or_error_redirect__client, mocked_analytics_module, ): - verifier = mocked_session_verifier_uses_auth_verification.return_value + verifier = mocked_session_verifier_uses_claims_verification.return_value verifier.claims_provider.claim = "claim" mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": "10"}} @@ -293,9 +293,9 @@ def test_authorize_success_with_claim_error( @pytest.mark.django_db @pytest.mark.usefixtures("mocked_analytics_module") def test_authorize_success_without_verifier_claim( - app_request, mocked_session_verifier_uses_auth_verification, mocked_oauth_client_or_error_redirect__client + app_request, mocked_session_verifier_uses_claims_verification, mocked_oauth_client_or_error_redirect__client ): - verifier = mocked_session_verifier_uses_auth_verification.return_value + verifier = mocked_session_verifier_uses_claims_verification.return_value verifier.claims_provider.claim = "" mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": "True"}} @@ -318,11 +318,11 @@ def test_authorize_success_without_verifier_claim( ) def test_authorize_success_without_claim_in_response( app_request, - mocked_session_verifier_uses_auth_verification, + mocked_session_verifier_uses_claims_verification, mocked_oauth_client_or_error_redirect__client, access_token_response, ): - verifier = mocked_session_verifier_uses_auth_verification.return_value + verifier = mocked_session_verifier_uses_claims_verification.return_value verifier.claims_provider.claim = "claim" mocked_oauth_client = mocked_oauth_client_or_error_redirect__client.return_value mocked_oauth_client.authorize_access_token.return_value = access_token_response @@ -336,7 +336,7 @@ def test_authorize_success_without_claim_in_response( @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_cancel(app_request, mocked_analytics_module): unverified_route = reverse(ROUTE_UNVERIFIED) @@ -356,7 +356,7 @@ def test_cancel_no_session_verifier(app_request): @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification", "mocked_oauth_client_or_error_redirect__error") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification", "mocked_oauth_client_or_error_redirect__error") def test_logout_oauth_client_init_error(app_request): result = authorize(app_request) @@ -373,7 +373,7 @@ def test_logout_no_session_verifier(app_request): @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_logout(app_request, mocker, mocked_oauth_client_or_error_redirect__client, mocked_analytics_module): # logout internally calls deauthorize_redirect # this mocks that function and a success response @@ -400,7 +400,7 @@ def test_logout(app_request, mocker, mocked_oauth_client_or_error_redirect__clie @pytest.mark.django_db -@pytest.mark.usefixtures("mocked_session_verifier_uses_auth_verification") +@pytest.mark.usefixtures("mocked_session_verifier_uses_claims_verification") def test_post_logout(app_request, mocked_analytics_module): origin = reverse(ROUTE_INDEX) session.update(app_request, origin=origin)