summaryrefslogtreecommitdiff
path: root/tests/oauth2/rfc6749/grant_types/test_refresh_token.py
diff options
context:
space:
mode:
authorJan Wrobel <wrr@mixedbit.org>2013-11-05 16:34:47 +0100
committerJan Wrobel <wrr@mixedbit.org>2013-11-05 16:34:47 +0100
commit7d4f5ce783206bce5eade09c45cca81c75b34cf1 (patch)
tree9c4294d930a58630472f3714ec1806ee32acb0ae /tests/oauth2/rfc6749/grant_types/test_refresh_token.py
parent170d04e87489fb338e660d8248873908037db6ae (diff)
downloadoauthlib-7d4f5ce783206bce5eade09c45cca81c75b34cf1.tar.gz
is_within_original_scope method for refresh token grant (Issue #220)
Diffstat (limited to 'tests/oauth2/rfc6749/grant_types/test_refresh_token.py')
-rw-r--r--tests/oauth2/rfc6749/grant_types/test_refresh_token.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/oauth2/rfc6749/grant_types/test_refresh_token.py b/tests/oauth2/rfc6749/grant_types/test_refresh_token.py
index 57c9af2..b54e208 100644
--- a/tests/oauth2/rfc6749/grant_types/test_refresh_token.py
+++ b/tests/oauth2/rfc6749/grant_types/test_refresh_token.py
@@ -47,8 +47,21 @@ class RefreshTokenGrantTest(TestCase):
self.assertIn('expires_in', token)
self.assertEqual(token['scope'], 'foo bar')
+ def test_create_token_within_original_scope(self):
+ self.mock_validator.get_original_scopes.return_value = ['baz']
+ self.mock_validator.is_within_original_scope.return_value = True
+ bearer = BearerToken(self.mock_validator)
+ headers, body, status_code = self.auth.create_token_response(
+ self.request, bearer)
+ token = json.loads(body)
+ self.assertIn('access_token', token)
+ self.assertIn('token_type', token)
+ self.assertIn('expires_in', token)
+ self.assertEqual(token['scope'], 'foo')
+
def test_invalid_scope(self):
self.mock_validator.get_original_scopes.return_value = ['baz']
+ self.mock_validator.is_within_original_scope.return_value = False
bearer = BearerToken(self.mock_validator)
headers, body, status_code = self.auth.create_token_response(
self.request, bearer)
@@ -110,6 +123,7 @@ class RefreshTokenGrantTest(TestCase):
def test_invalid_scope(self):
self.mock_validator.validate_refresh_token.return_value = True
+ self.mock_validator.is_within_original_scope.return_value = False
self.assertRaises(errors.InvalidScopeError,
self.auth.validate_token_request, self.request)