From baa6bf42cb6a9c8e4a4023b131cb40275e3668a6 Mon Sep 17 00:00:00 2001 From: Casper van der Wel Date: Wed, 20 Mar 2024 14:30:00 +0100 Subject: [PATCH] Fix check on RESOURCE_SERVER_ID --- nens_auth_client/checks.py | 8 ++++++-- nens_auth_client/tests/test_wso2.py | 12 ------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/nens_auth_client/checks.py b/nens_auth_client/checks.py index 602cc70..0d1aac2 100644 --- a/nens_auth_client/checks.py +++ b/nens_auth_client/checks.py @@ -19,11 +19,15 @@ def check_resource_server_id(app_configs=None, **kwargs): "AccessTokenMiddleware is used." ) ] - if not url.endswith("/"): + if ( + settings.NENS_AUTH_OAUTH_BACKEND + == "nens_auth_client.cognito.CognitoOAuthClient" + and not url.endswith("/") + ): return [ Error( "The NENS_AUTH_RESOURCE_SERVER_ID setting needs to end with a " - "slash (because AWS Cognito will automatically add one)." + "slash when using the CognitoOAuthClient." ) ] return [] diff --git a/nens_auth_client/tests/test_wso2.py b/nens_auth_client/tests/test_wso2.py index 292f55c..6897b99 100644 --- a/nens_auth_client/tests/test_wso2.py +++ b/nens_auth_client/tests/test_wso2.py @@ -1,5 +1,3 @@ -from authlib.oidc.discovery import get_well_known_url -from django.conf import settings from nens_auth_client.wso2 import WSO2AuthClient import pytest @@ -19,13 +17,3 @@ def test_extract_provider_name(): ) def test_extract_username(claims, expected): assert WSO2AuthClient.extract_username(claims) == expected - - -@pytest.fixture -def wso2_client(): - return WSO2AuthClient( - "foo", - server_metadata_url=get_well_known_url( - settings.NENS_AUTH_ISSUER, external=True - ), - )