From 80b5393d05da847c8ce413b4cc9b6c79bdc4db84 Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Mon, 16 Sep 2024 16:45:00 -0400 Subject: [PATCH] deal with 404 or 405 validator error (apparently varies with version of django) --- tests/test_oauth2_validators.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_oauth2_validators.py b/tests/test_oauth2_validators.py index 31d97f64..83b87c0f 100644 --- a/tests/test_oauth2_validators.py +++ b/tests/test_oauth2_validators.py @@ -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 + ) )