Skip to content

Commit

Permalink
Merge pull request #354 from myyang/fix_missing_attribute
Browse files Browse the repository at this point in the history
Fix and remove missing attribute: _client
  • Loading branch information
lepture committed Jul 2, 2015
2 parents b878ba1 + 9940cd2 commit 03ea1a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oauthlib/oauth2/rfc6749/clients/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def prepare_refresh_token_request(self, token_url, refresh_token=None,
raise InsecureTransportError()

self.scope = scope or self.scope
body = self._client.prepare_refresh_body(body=body,
body = self.prepare_refresh_body(body=body,
refresh_token=refresh_token, scope=self.scope, **kwargs)
return token_url, FORM_ENC_HEADERS, body

Expand Down
30 changes: 30 additions & 0 deletions tests/oauth2/rfc6749/clients/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,33 @@ def test_prepare_authorization_request(self):

# 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.assertFormBodyEqual(b, 'grant_type=refresh_token&refresh_token=%s' % 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.assertFormBodyEqual(b, 'grant_type=refresh_token&scope=%s&refresh_token=%s' % (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.assertFormBodyEqual(b, 'grant_type=refresh_token&scope=%s&refresh_token=%s' % (scope, token))

0 comments on commit 03ea1a1

Please sign in to comment.