From b660136bd21826160897c3351b47f5c9cd1cf8ce Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Fri, 3 May 2024 09:56:04 -0400 Subject: [PATCH] Return None indicates auth does not apply * Returning a tuple indicates the user auth failure. We want "auth does not apply". --- ansible_base/jwt_consumer/common/auth.py | 2 +- test_app/tests/jwt_consumer/common/test_auth.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible_base/jwt_consumer/common/auth.py b/ansible_base/jwt_consumer/common/auth.py index c0ce3fa94..1139c1ba2 100644 --- a/ansible_base/jwt_consumer/common/auth.py +++ b/ansible_base/jwt_consumer/common/auth.py @@ -281,7 +281,7 @@ def authenticate(self, request): return user, None else: - return None, None + return None def process_user_data(self, user, token): common_auth = JWTCommonAuth(self.map_fields) diff --git a/test_app/tests/jwt_consumer/common/test_auth.py b/test_app/tests/jwt_consumer/common/test_auth.py index d8a0be749..f551d7f0a 100644 --- a/test_app/tests/jwt_consumer/common/test_auth.py +++ b/test_app/tests/jwt_consumer/common/test_auth.py @@ -342,10 +342,10 @@ def test_authenticate(self, jwt_token, django_user_model, mocked_http, test_encr def test_authenticate_no_user(self, user): with mock.patch('ansible_base.jwt_consumer.common.auth.JWTCommonAuth.parse_jwt_token') as mock_parse: - mock_parse.return_value = (None, {}) + mock_parse.return_value = (None, None) jwt_auth = JWTAuthentication() - created_user, _ = jwt_auth.authenticate(mock.MagicMock()) - assert created_user is None + auth_provided = jwt_auth.authenticate(mock.MagicMock()) + assert auth_provided is None def test_process_user_data(self): with mock.patch("ansible_base.jwt_consumer.common.auth.JWTCommonAuth.map_user_fields") as mock_inspect: