From 281e2773b18051b0091a62780c0387a98c99660a Mon Sep 17 00:00:00 2001 From: Joseph Tate Date: Fri, 27 Feb 2015 02:06:02 -0500 Subject: add failing test --- tests/oauth2/rfc6749/test_parameters.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/oauth2/rfc6749/test_parameters.py') diff --git a/tests/oauth2/rfc6749/test_parameters.py b/tests/oauth2/rfc6749/test_parameters.py index 6b14115..a7de41a 100644 --- a/tests/oauth2/rfc6749/test_parameters.py +++ b/tests/oauth2/rfc6749/test_parameters.py @@ -95,6 +95,11 @@ class ParameterTests(TestCase): ' "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",' ' "example_parameter": "example_value",' ' "scope":"abc def"}') + json_response_noscope = ('{ "access_token": "2YotnFZFEjr1zCsicMWpAA",' + ' "token_type": "example",' + ' "expires_in": 3600,' + ' "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",' + ' "example_parameter": "example_value" }') json_error = '{ "error": "invalid_request" }' @@ -125,6 +130,15 @@ class ParameterTests(TestCase): 'scope': ['abc', 'def'] } + json_noscope_dict = { + 'access_token': '2YotnFZFEjr1zCsicMWpAA', + 'token_type': 'example', + 'expires_in': 3600, + 'expires_at': 4600, + 'refresh_token': 'tGzv3JOkF0XG5Qx2TlKWIA', + 'example_parameter': 'example_value' + } + json_notype_dict = { 'access_token': '2YotnFZFEjr1zCsicMWpAA', 'expires_in': 3600, @@ -194,6 +208,9 @@ class ParameterTests(TestCase): self.assertRaises(InvalidRequestError, parse_token_response, self.json_error) self.assertRaises(MissingTokenError, parse_token_response, self.json_notoken) + self.assertEqual(parse_token_response(self.json_response_noscope, + scope=['all', 'the', 'scopes']), self.json_noscope_dict) + scope_changes_recorded = [] def record_scope_change(sender, message, old, new): scope_changes_recorded.append((message, old, new)) @@ -212,6 +229,7 @@ class ParameterTests(TestCase): signals.scope_changed.disconnect(record_scope_change) del os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] + def test_json_token_notype(self): """Verify strict token type parsing only when configured. """ self.assertEqual(parse_token_response(self.json_notype), self.json_notype_dict) -- cgit v1.2.1