Skip to content

Commit 754238d

Browse files
committed
fixed tests
1 parent 487d23a commit 754238d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

oauth2_provider/tests/test_authorization_code.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ def tearDown(self):
5050

5151

5252
class TestAuthorizationCodeView(BaseTest):
53+
def test_skip_authorization_completely(self):
54+
"""
55+
If application.skip_authorization = True, should skip the authorization page.
56+
"""
57+
self.client.login(username="test_user", password="123456")
58+
self.application.skip_authorization = True
59+
self.application.save()
60+
61+
query_string = urlencode({
62+
'client_id': self.application.client_id,
63+
'response_type': 'code',
64+
'state': 'random_state_string',
65+
'scope': 'read write',
66+
'redirect_uri': 'http://example.it',
67+
})
68+
url = "{url}?{qs}".format(url=reverse('oauth2_provider:authorize'), qs=query_string)
69+
70+
response = self.client.get(url)
71+
self.assertEqual(response.status_code, 302)
72+
73+
5374
def test_pre_auth_invalid_client(self):
5475
"""
5576
Test error for an invalid client_id with response_type: code

oauth2_provider/tests/test_implicit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ def test_post_auth_allow(self):
142142
self.assertIn('access_token=', response['Location'])
143143
self.assertIn('state=random_state_string', response['Location'])
144144

145-
@mock.patch('oauth2_provider.views.base.AuthorizationView.skip_authorization_completely', True)
146145
def test_skip_authorization_completely(self):
147146
"""
148-
If skip_authorization_completely = True, should skip the authorization page.
147+
If application.skip_authorization = True, should skip the authorization page.
149148
"""
150149
self.client.login(username="test_user", password="123456")
150+
self.application.skip_authorization = True
151+
self.application.save()
151152

152153
query_string = urlencode({
153154
'client_id': self.application.client_id,

0 commit comments

Comments
 (0)