Skip to content

Commit

Permalink
deal with 404 or 405 validator error (apparently varies with version …
Browse files Browse the repository at this point in the history
…of django)
  • Loading branch information
n2ygk committed Sep 16, 2024
1 parent 90d7300 commit 80b5393
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,19 @@ def setUpTestData(cls):
cls.introspection_token = "test_introspection_token"
cls.validator = OAuth2Validator()

def test_response_when_auth_server_response_return_404(self):
def test_response_when_auth_server_response_return_404_405(self):
"""
Deal with either 404 or 405 response
"""
with self.assertLogs(logger="oauth2_provider") as mock_log:
self.validator._get_token_from_authentication_server(
self.token, self.introspection_url, self.introspection_token, None
)
self.assertIn(
"ERROR:oauth2_provider:Introspection: Failed to "
"get a valid response from authentication server. "
"Status code: 404, Reason: "
"Not Found.\nNoneType: None",
mock_log.output,
self.assertTrue(
any(
"Failed to get a valid response from authentication server" in message
for message in mock_log.output
)
)


Expand Down

0 comments on commit 80b5393

Please sign in to comment.