@@ -198,11 +198,9 @@ def test_successful_authentication_new_user(self, token_mock, request_mock, algo
198198 'redirect_uri' : 'http://testserver/callback/' ,
199199 }
200200 self .assertEqual (User .objects .all ().count (), 0 )
201- result = self .backend .authenticate (request = auth_request )
201+ self .backend .authenticate (request = auth_request )
202202 self .assertEqual (User .objects .all ().count (), 1 )
203203 user = User .objects .all ()[0 ]
204- self .assertEquals (user , result )
205-
206204 self .
assertEquals (
user .
email ,
'[email protected] ' )
207205 self .assertEquals (user .username , 'username_algo' )
208206
@@ -215,31 +213,6 @@ def test_successful_authentication_new_user(self, token_mock, request_mock, algo
215213 headers = {'Authorization' : 'Bearer access_granted' }
216214 )
217215
218- @patch ('mozilla_django_oidc.auth.requests' )
219- @patch ('mozilla_django_oidc.auth.OIDCAuthenticationBackend.verify_token' )
220- def test_successful_authentication_no_email (self , token_mock , request_mock ):
221- """What happens if the auth "works" but it doesn't have an email?"""
222- auth_request = RequestFactory ().get ('/foo' , {'code' : 'foo' ,
223- 'state' : 'bar' })
224- auth_request .session = {}
225-
226- token_mock .return_value = True
227- get_json_mock = Mock ()
228- get_json_mock .json .return_value = {
229- 'nickname' : 'a_username' ,
230- 'email' : ''
231- }
232- request_mock .get .return_value = get_json_mock
233- post_json_mock = Mock ()
234- post_json_mock .json .return_value = {
235- 'id_token' : 'id_token' ,
236- 'access_token' : 'access_granted'
237- }
238- request_mock .post .return_value = post_json_mock
239- result = self .backend .authenticate (request = auth_request )
240- assert result is None
241- self .assertEqual (User .objects .all ().count (), 0 )
242-
243216 def test_authenticate_no_code_no_state (self ):
244217 """Test authenticate with wrong parameters."""
245218
0 commit comments