diff options
author | myyang <ymy1019@gmail.com> | 2015-07-01 23:11:41 +0800 |
---|---|---|
committer | myyang <ymy1019@gmail.com> | 2015-07-01 23:53:50 +0800 |
commit | de586cd17cce1363ee611fea30a47aee908f861b (patch) | |
tree | 02a028b1dbce67a564f77cbce0a931adc4f3ad5c /tests/oauth2/rfc6749/clients/test_base.py | |
parent | b878ba1d12aca8d123c4ad9b776b6afbe77cfc65 (diff) | |
download | oauthlib-de586cd17cce1363ee611fea30a47aee908f861b.tar.gz |
Fix and remove missing attribute: _client
* Fix and remove missing attribute: _client in prepare_refresh_token_request()
* Add testcase for prepare_refresh_token_request()
Diffstat (limited to 'tests/oauth2/rfc6749/clients/test_base.py')
-rw-r--r-- | tests/oauth2/rfc6749/clients/test_base.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/oauth2/rfc6749/clients/test_base.py b/tests/oauth2/rfc6749/clients/test_base.py index dc67c31..b60c6a8 100644 --- a/tests/oauth2/rfc6749/clients/test_base.py +++ b/tests/oauth2/rfc6749/clients/test_base.py @@ -206,3 +206,33 @@ class ClientTest(TestCase): # NotImplementedError self.assertRaises(NotImplementedError, client.prepare_authorization_request, auth_url) + + def test_prepare_refresh_token_request(self): + client = Client(self.client_id) + + url = 'https://example.com/revoke' + token = 'foobar' + scope = 'extra_scope' + + u, h, b = client.prepare_refresh_token_request(url, token) + self.assertEqual(u, url) + self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) + self.assertEqual(b, 'grant_type=refresh_token&refresh_token={}'.format(token)) + + # Non-HTTPS revocation endpoint + self.assertRaises(InsecureTransportError, + client.prepare_refresh_token_request, + 'http://example.com/revoke', token) + + # provide extra scope + u, h, b = client.prepare_refresh_token_request(url, token, scope=scope) + self.assertEqual(u, url) + self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) + self.assertEqual(b, 'grant_type=refresh_token&scope={}&refresh_token={}'.format(scope, token)) + + # provide scope while init + client = Client(self.client_id, scope=scope) + u, h, b = client.prepare_refresh_token_request(url, token, scope=scope) + self.assertEqual(u, url) + self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) + self.assertEqual(b, 'grant_type=refresh_token&scope={}&refresh_token={}'.format(scope, token)) |