diff options
author | Hong Minhee <minhee@dahlia.kr> | 2013-05-24 22:28:32 +0900 |
---|---|---|
committer | Hong Minhee <minhee@dahlia.kr> | 2013-05-24 22:28:32 +0900 |
commit | 14fffb8dc1c6a3fabf35bc74c3032abcae402a67 (patch) | |
tree | 30f0a32a29ee5b8239a94e71db9ba4481e0f1416 /tests | |
parent | 28f1d3bb1a406b3f45f6cf2f1ccce96e2b31c489 (diff) | |
download | oauthlib-14fffb8dc1c6a3fabf35bc74c3032abcae402a67.tar.gz |
Add optional expires_in parameter to BearerToken
The expires_in is still 3600 by default.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/oauth2/draft25/test_grant_types.py | 4 | ||||
-rw-r--r-- | tests/oauth2/draft25/test_server.py | 17 |
2 files changed, 12 insertions, 9 deletions
diff --git a/tests/oauth2/draft25/test_grant_types.py b/tests/oauth2/draft25/test_grant_types.py index 4040db9..34907a0 100644 --- a/tests/oauth2/draft25/test_grant_types.py +++ b/tests/oauth2/draft25/test_grant_types.py @@ -117,13 +117,13 @@ class ImplicitGrantTest(TestCase): self.auth = ImplicitGrant(request_validator=self.mock_validator) def test_create_token_response(self): - bearer = BearerToken(self.mock_validator) + bearer = BearerToken(self.mock_validator, expires_in=1800) orig_generate_token = common.generate_token self.addCleanup(setattr, common, 'generate_token', orig_generate_token) common.generate_token = lambda *args, **kwargs: '1234' uri, headers, body, status_code = self.auth.create_token_response( self.request, bearer) - correct_uri = 'https://b.c/p#access_token=1234&token_type=Bearer&expires_in=3600&state=xyz&scope=hello+world' + correct_uri = 'https://b.c/p#access_token=1234&token_type=Bearer&expires_in=1800&state=xyz&scope=hello+world' self.assertURLEqual(uri, correct_uri, parse_fragment=True) def test_error_response(self): diff --git a/tests/oauth2/draft25/test_server.py b/tests/oauth2/draft25/test_server.py index 46298c2..db26fcc 100644 --- a/tests/oauth2/draft25/test_server.py +++ b/tests/oauth2/draft25/test_server.py @@ -23,8 +23,9 @@ class AuthorizationEndpointTest(TestCase): 'code': auth_code, 'token': implicit, } - - token = tokens.BearerToken(self.mock_validator) + self.expires_in = 1800 + token = tokens.BearerToken(self.mock_validator, + expires_in=self.expires_in) self.endpoint = draft25.AuthorizationEndpoint( default_response_type='code', default_token_type=token, @@ -44,7 +45,7 @@ class AuthorizationEndpointTest(TestCase): uri += '&redirect_uri=http%3A%2F%2Fback.to%2Fme' uri, headers, body, status_code = self.endpoint.create_authorization_response( uri, scopes=['all', 'of', 'them']) - self.assertURLEqual(uri, 'http://back.to/me#access_token=abc&expires_in=3600&token_type=Bearer&state=xyz&scope=all+of+them', parse_fragment=True) + self.assertURLEqual(uri, 'http://back.to/me#access_token=abc&expires_in=' + str(self.expires_in) + '&token_type=Bearer&state=xyz&scope=all+of+them', parse_fragment=True) def test_missing_type(self): uri = 'http://i.b/l?client_id=me&scope=all+of+them' @@ -88,7 +89,9 @@ class TokenEndpointTest(TestCase): 'password': password, 'client_credentials': client, } - token = tokens.BearerToken(self.mock_validator) + self.expires_in = 1800 + token = tokens.BearerToken(self.mock_validator, + expires_in=self.expires_in) self.endpoint = draft25.TokenEndpoint('authorization_code', default_token_type=token, grant_types=supported_types) @@ -99,7 +102,7 @@ class TokenEndpointTest(TestCase): '', body=body) token = { 'token_type': 'Bearer', - 'expires_in': 3600, + 'expires_in': self.expires_in, 'access_token': 'abc', 'refresh_token': 'abc', 'state': 'xyz' @@ -113,7 +116,7 @@ class TokenEndpointTest(TestCase): '', body=body) token = { 'token_type': 'Bearer', - 'expires_in': 3600, + 'expires_in': self.expires_in, 'access_token': 'abc', 'refresh_token': 'abc', 'scope': 'all of them', @@ -127,7 +130,7 @@ class TokenEndpointTest(TestCase): '', body=body) token = { 'token_type': 'Bearer', - 'expires_in': 3600, + 'expires_in': self.expires_in, 'access_token': 'abc', 'scope': 'all of them', } |