diff options
| author | Brendan McCollam <bmccollam@uchicago.edu> | 2016-12-20 20:01:49 +0000 |
|---|---|---|
| committer | Brendan McCollam <bmccollam@uchicago.edu> | 2016-12-20 21:49:12 +0000 |
| commit | d37f361aa0efd7565ac3eebb31cb38f25be70abc (patch) | |
| tree | da5fce5db851b067a685a6f80c3a737ff090d86a /tests | |
| parent | f0bbc526065ff88eaa431163d8d7c1f72694221b (diff) | |
| download | oauthlib-d37f361aa0efd7565ac3eebb31cb38f25be70abc.tar.gz | |
Adds failing test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/oauth2/rfc6749/endpoints/test_prompt_handling.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/oauth2/rfc6749/endpoints/test_prompt_handling.py b/tests/oauth2/rfc6749/endpoints/test_prompt_handling.py new file mode 100644 index 0000000..bad424f --- /dev/null +++ b/tests/oauth2/rfc6749/endpoints/test_prompt_handling.py @@ -0,0 +1,50 @@ +from __future__ import absolute_import, unicode_literals +try: + from urllib.parse import urlencode +except ImportError: + from urllib import urlencode + +import mock + +from ....unittest import TestCase +from oauthlib.oauth2.rfc6749.tokens import BearerToken +from oauthlib.oauth2.rfc6749.grant_types import OpenIDConnectAuthCode +from oauthlib.oauth2.rfc6749.endpoints.authorization import AuthorizationEndpoint + +class OpenIDConnectEndpointTest(TestCase): + + def setUp(self): + self.mock_validator = mock.MagicMock() + self.mock_validator.authenticate_client.side_effect = self.set_client + grant = OpenIDConnectAuthCode(request_validator=self.mock_validator) + bearer = BearerToken(self.mock_validator) + self.endpoint = AuthorizationEndpoint(grant, bearer, + response_types={'code': grant}) + params = { + 'prompt': 'consent', + 'state': 'abc', + 'redirect_uri': 'https://a.b/cb', + 'response_type': 'code', + 'client_id': 'abcdef', + 'scope': 'hello openid' + } + self.url = 'http://a.b/path?' + urlencode(params) + + def set_client(self, request): + request.client = mock.MagicMock() + request.client.client_id = 'mocked' + return True + + @mock.patch('oauthlib.common.generate_token') + def test_authorization_endpoint_handles_prompt(self, generate_token): + generate_token.return_value = "MOCK_CODE" + # In the GET view: + scopes, creds = self.endpoint.validate_authorization_request(self.url) + # In the POST view: + creds['scopes'] = scopes + h, b, s = self.endpoint.create_authorization_response(self.url, + credentials=creds) + expected = 'https://a.b/cb?state=abc&code=MOCK_CODE' + self.assertURLEqual(h['Location'], expected) + self.assertEqual(b, None) + self.assertEqual(s, 302) |
