Browse Source

Merge pull request #1034 from syleam/9.0-fix-oauth_provider-tests

[FIX] oauth_provider: Fix tests when using last oauthlib versions
pull/482/merge
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
d477d36ed5
  1. 24
      oauth_provider/tests/test_oauth_provider_controller_web_application.py

24
oauth_provider/tests/test_oauth_provider_controller_web_application.py

@ -181,8 +181,16 @@ class TestOAuthProviderController(
'client_id': self.client.identifier, 'client_id': self.client.identifier,
'code': code.code, '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): def test_token_error_wrong_redirect_uri(self):
""" Check /oauth2/token with a wrong redirect_uri """ Check /oauth2/token with a wrong redirect_uri
@ -198,8 +206,16 @@ class TestOAuthProviderController(
'code': code.code, 'code': code.code,
'redirect_uri': 'Wrong redirect URI', '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): def test_token_error_wrong_client_id(self):
""" Check /oauth2/token with a wrong client id """ Check /oauth2/token with a wrong client id

Loading…
Cancel
Save