12
12
from ..compat import urlparse , parse_qs , urlencode , get_user_model
13
13
from ..models import get_application_model , Grant , AccessToken
14
14
from ..settings import oauth2_settings
15
- from ..oauth2_validators import OAuth2Validator
16
15
from ..views import ProtectedResourceView
17
16
18
17
from .test_utils import TestCaseUtils
@@ -35,7 +34,7 @@ def setUp(self):
35
34
self .
dev_user = UserModel .
objects .
create_user (
"dev_user" ,
"[email protected] " ,
"123456" )
36
35
37
36
oauth2_settings .ALLOWED_REDIRECT_URI_SCHEMES = ['http' , 'custom-scheme' ]
38
-
37
+
39
38
self .application = Application (
40
39
name = "Test Application" ,
41
40
redirect_uris = "http://localhost http://example.com http://example.it custom-scheme://example.com" ,
@@ -74,7 +73,6 @@ def test_skip_authorization_completely(self):
74
73
response = self .client .get (url )
75
74
self .assertEqual (response .status_code , 302 )
76
75
77
-
78
76
def test_pre_auth_invalid_client (self ):
79
77
"""
80
78
Test error for an invalid client_id with response_type: code
@@ -147,11 +145,11 @@ def test_pre_auth_valid_client_custom_redirect_uri_scheme(self):
147
145
148
146
def test_pre_auth_approval_prompt (self ):
149
147
"""
150
-
148
+ TODO
151
149
"""
152
150
tok = AccessToken .objects .create (user = self .test_user , token = '1234567890' ,
153
151
application = self .application ,
154
- expires = timezone .now ()+ datetime .timedelta (days = 1 ),
152
+ expires = timezone .now () + datetime .timedelta (days = 1 ),
155
153
scope = 'read write' )
156
154
self .client .login (username = "test_user" , password = "123456" )
157
155
query_string = urlencode ({
@@ -173,13 +171,13 @@ def test_pre_auth_approval_prompt(self):
173
171
174
172
def test_pre_auth_approval_prompt_default (self ):
175
173
"""
176
-
174
+ TODO
177
175
"""
178
176
self .assertEqual (oauth2_settings .REQUEST_APPROVAL_PROMPT , 'force' )
179
177
180
178
AccessToken .objects .create (user = self .test_user , token = '1234567890' ,
181
179
application = self .application ,
182
- expires = timezone .now ()+ datetime .timedelta (days = 1 ),
180
+ expires = timezone .now () + datetime .timedelta (days = 1 ),
183
181
scope = 'read write' )
184
182
self .client .login (username = "test_user" , password = "123456" )
185
183
query_string = urlencode ({
@@ -195,13 +193,13 @@ def test_pre_auth_approval_prompt_default(self):
195
193
196
194
def test_pre_auth_approval_prompt_default_override (self ):
197
195
"""
198
-
196
+ TODO
199
197
"""
200
198
oauth2_settings .REQUEST_APPROVAL_PROMPT = 'auto'
201
199
202
200
AccessToken .objects .create (user = self .test_user , token = '1234567890' ,
203
201
application = self .application ,
204
- expires = timezone .now ()+ datetime .timedelta (days = 1 ),
202
+ expires = timezone .now () + datetime .timedelta (days = 1 ),
205
203
scope = 'read write' )
206
204
self .client .login (username = "test_user" , password = "123456" )
207
205
query_string = urlencode ({
@@ -634,7 +632,8 @@ def test_refresh_repeating_requests_non_rotating_tokens(self):
634
632
'scope' : content ['scope' ],
635
633
}
636
634
637
- with mock .patch ('oauthlib.oauth2.rfc6749.request_validator.RequestValidator.rotate_refresh_token' , return_value = False ):
635
+ with mock .patch ('oauthlib.oauth2.rfc6749.request_validator.RequestValidator.rotate_refresh_token' ,
636
+ return_value = False ):
638
637
response = self .client .post (reverse ('oauth2_provider:token' ), data = token_request_data , ** auth_headers )
639
638
self .assertEqual (response .status_code , 200 )
640
639
response = self .client .post (reverse ('oauth2_provider:token' ), data = token_request_data , ** auth_headers )
@@ -742,7 +741,7 @@ def test_request_body_params(self):
742
741
'code' : authorization_code ,
743
742
'redirect_uri' : 'http://example.it' ,
744
743
'client_id' : self .application .client_id ,
745
- 'client_secret' : self .application .client_secret ,
744
+ 'client_secret' : self .application .client_secret ,
746
745
}
747
746
748
747
response = self .client .post (reverse ('oauth2_provider:token' ), data = token_request_data )
0 commit comments