Skip to content

Commit 2ee2b6a

Browse files
Psykopearsynasius
authored andcommitted
Added test for default scopes in implicit grant
1 parent bb4f092 commit 2ee2b6a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

oauth2_provider/tests/test_implicit.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def setUp(self):
3737
self.application.save()
3838

3939
oauth2_settings._SCOPES = ['read', 'write']
40+
oauth2_settings._DEFAULT_SCOPES = ['read']
4041

4142
def tearDown(self):
4243
self.application.delete()
@@ -45,6 +46,26 @@ def tearDown(self):
4546

4647

4748
class TestImplicitAuthorizationCodeView(BaseTest):
49+
def test_pre_auth_valid_client_default_scopes(self):
50+
"""
51+
Test response for a valid client_id with response_type: token and default_scopes
52+
"""
53+
self.client.login(username="test_user", password="123456")
54+
query_string = urlencode({
55+
'client_id': self.application.client_id,
56+
'response_type': 'token',
57+
'state': 'random_state_string',
58+
'redirect_uri': 'http://example.it',
59+
})
60+
61+
url = "{url}?{qs}".format(url=reverse('oauth2_provider:authorize'), qs=query_string)
62+
response = self.client.get(url)
63+
self.assertEqual(response.status_code, 200)
64+
65+
self.assertIn("form", response.context)
66+
form = response.context["form"]
67+
self.assertEqual(form['scope'].value(), 'read')
68+
4869
def test_pre_auth_valid_client(self):
4970
"""
5071
Test response for a valid client_id with response_type: token

0 commit comments

Comments
 (0)