Skip to content

Commit

Permalink
Return None indicates auth does not apply
Browse files Browse the repository at this point in the history
* Returning a tuple indicates the user auth failure. We want "auth does
  not apply".
  • Loading branch information
chrismeyersfsu committed May 3, 2024
1 parent 8e63710 commit b660136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ansible_base/jwt_consumer/common/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions test_app/tests/jwt_consumer/common/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b660136

Please sign in to comment.