From 72ef2a97d787db034ccc32b32bc2076d193b1224 Mon Sep 17 00:00:00 2001 From: Sylvain GARANCHER Date: Sat, 21 Oct 2017 23:48:51 +0200 Subject: [PATCH] [FIX] oauth_provider: Fix tests when using last oauthlib version --- ...uth_provider_controller_web_application.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/oauth_provider/tests/test_oauth_provider_controller_web_application.py b/oauth_provider/tests/test_oauth_provider_controller_web_application.py index 869c6e5cc..2c5f50160 100644 --- a/oauth_provider/tests/test_oauth_provider_controller_web_application.py +++ b/oauth_provider/tests/test_oauth_provider_controller_web_application.py @@ -181,8 +181,16 @@ class TestOAuthProviderController( 'client_id': self.client.identifier, 'code': code.code, }) - self.assertEqual(response.status_code, 401) - self.assertEqual(json.loads(response.data), {'error': 'access_denied'}) + # Two possible returned errors, depending on the oauthlib version + self.assertIn(response.status_code, (400, 401)) + if response.status_code == 400: + self.assertEqual(json.loads(response.data), { + 'error': 'invalid_request', + 'error_description': 'Mismatching redirect URI.', + }) + else: + self.assertEqual( + json.loads(response.data), {'error': 'access_denied'}) def test_token_error_wrong_redirect_uri(self): """ Check /oauth2/token with a wrong redirect_uri @@ -198,8 +206,16 @@ class TestOAuthProviderController( 'code': code.code, 'redirect_uri': 'Wrong redirect URI', }) - self.assertEqual(response.status_code, 401) - self.assertEqual(json.loads(response.data), {'error': 'access_denied'}) + # Two possible returned errors, depending on the oauthlib version + self.assertIn(response.status_code, (400, 401)) + if response.status_code == 400: + self.assertEqual(json.loads(response.data), { + 'error': 'invalid_request', + 'error_description': 'Mismatching redirect URI.', + }) + else: + self.assertEqual( + json.loads(response.data), {'error': 'access_denied'}) def test_token_error_wrong_client_id(self): """ Check /oauth2/token with a wrong client id