Skip to content

Commit

Permalink
Added test for default scopes in implicit grant
Browse files Browse the repository at this point in the history
  • Loading branch information
Psykopear committed Dec 14, 2015
1 parent a7ddca2 commit 5b7668b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions oauth2_provider/tests/test_implicit.py
Expand Up @@ -37,6 +37,7 @@ def setUp(self):
self.application.save()

oauth2_settings._SCOPES = ['read', 'write']
oauth2_settings._DEFAULT_SCOPES = ['read']

def tearDown(self):
self.application.delete()
Expand All @@ -45,6 +46,26 @@ def tearDown(self):


class TestImplicitAuthorizationCodeView(BaseTest):
def test_pre_auth_valid_client_default_scopes(self):
"""
Test response for a valid client_id with response_type: token and default_scopes
"""
self.client.login(username="test_user", password="123456")
query_string = urlencode({
'client_id': self.application.client_id,
'response_type': 'token',
'state': 'random_state_string',
'redirect_uri': 'http://example.it',
})

url = "{url}?{qs}".format(url=reverse('oauth2_provider:authorize'), qs=query_string)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

self.assertIn("form", response.context)
form = response.context["form"]
self.assertEqual(form['scope'].value(), 'read')

def test_pre_auth_valid_client(self):
"""
Test response for a valid client_id with response_type: token
Expand Down

0 comments on commit 5b7668b

Please sign in to comment.