Skip to content

Commit

Permalink
Remove vestigial feature whose tests were causing unit tests to fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
skruger committed Mar 16, 2015
1 parent 599f776 commit 3a34630
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 50 deletions.
8 changes: 0 additions & 8 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@
Session key prefix to store temporary data while the user is completing
the authentication / authorization process.

.. attribute:: SINGLE_ACCESS_TOKEN

:settings: `OAUTH_SINGLE_ACCESS_TOKEN`
:default: `False`

To have the provider only create and retrieve one access token per
user/client/scope combination, set to `True`.

`provider.forms`
----------------
.. automodule:: provider.forms
Expand Down
1 change: 0 additions & 1 deletion provider/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@

SESSION_KEY = getattr(settings, 'OAUTH_SESSION_KEY', 'oauth')

SINGLE_ACCESS_TOKEN = getattr(settings, 'OAUTH_SINGLE_ACCESS_TOKEN', False)
27 changes: 0 additions & 27 deletions provider/oauth2/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,33 +287,6 @@ def test_fetching_access_token_with_invalid_grant_type(self):
self.assertEqual('unsupported_grant_type', json.loads(response.content)['error'],
response.content)

def test_fetching_single_access_token(self):
constants.SINGLE_ACCESS_TOKEN = True

result1 = self._login_authorize_get_token()
result2 = self._login_authorize_get_token()

self.assertEqual(result1['access_token'], result2['access_token'])

constants.SINGLE_ACCESS_TOKEN = False

def test_fetching_single_access_token_after_refresh(self):
constants.SINGLE_ACCESS_TOKEN = True

token = self._login_authorize_get_token()

self.client.post(self.access_token_url(), {
'grant_type': 'refresh_token',
'refresh_token': token['refresh_token'],
'client_id': self.get_client().client_id,
'client_secret': self.get_client().client_secret,
})

new_token = self._login_authorize_get_token()
self.assertNotEqual(token['access_token'], new_token['access_token'])

constants.SINGLE_ACCESS_TOKEN = False

def test_fetching_access_token_multiple_times(self):
self._login_authorize_get_token()
code = self.get_grant().code
Expand Down
22 changes: 8 additions & 14 deletions provider/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,10 @@ def authorization_code(self, request, data, client):
"""
grant = self.get_authorization_code_grant(request, request.POST,
client)
if constants.SINGLE_ACCESS_TOKEN:
at = self.get_access_token(request, grant.user, grant.scope.all(), client)
else:
at = self.create_access_token(request, grant.user,
list(grant.scope.all()), client)
rt = self.create_refresh_token(request, grant.user,
list(grant.scope.all()), at, client)
at = self.create_access_token(request, grant.user,
list(grant.scope.all()), client)
rt = self.create_refresh_token(request, grant.user,
list(grant.scope.all()), at, client)

self.invalidate_grant(grant)

Expand Down Expand Up @@ -554,13 +551,10 @@ def password(self, request, data, client):
user = data.get('user')
scope = data.get('scope')

if constants.SINGLE_ACCESS_TOKEN:
at = self.get_access_token(request, user, scope, client)
else:
at = self.create_access_token(request, user, scope, client)
# Public clients don't get refresh tokens
if client.client_type != 1:
rt = self.create_refresh_token(request, user, scope, at, client)
at = self.create_access_token(request, user, scope, client)
# Public clients don't get refresh tokens
if client.client_type != 1:
rt = self.create_refresh_token(request, user, scope, at, client)

return self.access_token_response(at)

Expand Down

0 comments on commit 3a34630

Please sign in to comment.