From 2784c61666b0a9811ef921ba63b735a2643159e2 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Thu, 16 Oct 2025 12:16:38 +0300 Subject: [PATCH] fix(shared): fix tests that don't work with NEXT_PUBLIC_ENABLE_SUOMIFI=1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still one test remains that does not work if NEXT_PUBLIC_ENABLE_SUOMIFI=1 when bringing up the backend. Add FIXME to that test case. You can try running the shared backend tests before this commit to see that they do not all pass if you have NEXT_PUBLIC_ENABLE_SUOMIFI=1, e.g. using Kesäseteli's backend (You can use Benefit's too if you like): ``` docker exec -it kesaseteli-backend bash pytest . -vv --pyargs shared --ignore-glob="**" ``` --- .../shared/shared/azure_adfs/tests/test_adfs_login.py | 9 ++++++++- backend/shared/shared/oidc/tests/test_eauth_views.py | 1 + backend/shared/shared/oidc/tests/test_oidc_views.py | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/shared/shared/azure_adfs/tests/test_adfs_login.py b/backend/shared/shared/azure_adfs/tests/test_adfs_login.py index 8479d2ccb3..1fb8b5653c 100644 --- a/backend/shared/shared/azure_adfs/tests/test_adfs_login.py +++ b/backend/shared/shared/azure_adfs/tests/test_adfs_login.py @@ -219,9 +219,16 @@ def test_adfs_callback( assert "_auth_user_id" in client.session +# FIXME: This test does not work if NEXT_PUBLIC_ENABLE_SUOMIF=True +# when bringing up the backend. Overriding this setting here +# does not help, because there's conditional logic being done +# based on the setting's value elsewhere that does not get +# rerun when changing the setting in this test. @pytest.mark.django_db @override_settings( - NEXT_PUBLIC_MOCK_FLAG=False, ADFS_LOGIN_REDIRECT_URL="http://example.com" + NEXT_PUBLIC_MOCK_FLAG=False, + ADFS_LOGIN_REDIRECT_URL="http://example.com", + NEXT_PUBLIC_ENABLE_SUOMIFI=False, ) @pytest.mark.parametrize( "original_redirect_url", diff --git a/backend/shared/shared/oidc/tests/test_eauth_views.py b/backend/shared/shared/oidc/tests/test_eauth_views.py index 55811a5524..a22621eb17 100644 --- a/backend/shared/shared/oidc/tests/test_eauth_views.py +++ b/backend/shared/shared/oidc/tests/test_eauth_views.py @@ -76,6 +76,7 @@ def test_get_organization_roles(session_request, requests_mock): EAUTHORIZATIONS_CLIENT_ID="test", EAUTHORIZATIONS_CLIENT_SECRET="test", NEXT_PUBLIC_MOCK_FLAG=False, + NEXT_PUBLIC_ENABLE_SUOMIFI=False, ) def test_eauth_authentication_init_view(requests_mock, user_client, user): register_user_info = { diff --git a/backend/shared/shared/oidc/tests/test_oidc_views.py b/backend/shared/shared/oidc/tests/test_oidc_views.py index df015fde3a..1c4eadf1e1 100644 --- a/backend/shared/shared/oidc/tests/test_oidc_views.py +++ b/backend/shared/shared/oidc/tests/test_oidc_views.py @@ -73,6 +73,7 @@ def test_logout_callback_view(requests_mock, user_client, user): @override_settings( OIDC_OP_USER_ENDPOINT="http://example.com/userinfo/", NEXT_PUBLIC_MOCK_FLAG=False, + NEXT_PUBLIC_ENABLE_SUOMIFI=False, ) def test_userinfo_view(requests_mock, user_client, user): userinfo = { @@ -105,6 +106,7 @@ def test_userinfo_view(requests_mock, user_client, user): @override_settings( OIDC_OP_USER_ENDPOINT="http://example.com/userinfo/", NEXT_PUBLIC_MOCK_FLAG=False, + NEXT_PUBLIC_ENABLE_SUOMIFI=False, ) def test_userinfo_view_without_oidc_info(user_client): session = user_client.session @@ -127,6 +129,7 @@ def test_userinfo_view_without_oidc_info(user_client): @override_settings( OIDC_OP_USER_ENDPOINT="http://example.com/userinfo/", NEXT_PUBLIC_MOCK_FLAG=False, + NEXT_PUBLIC_ENABLE_SUOMIFI=False, ) def test_userinfo_view_with_userinfo_returning_401(requests_mock, user_client, user): matcher = re.compile(re.escape(settings.OIDC_OP_USER_ENDPOINT))