@@ -38,7 +38,7 @@ def test_valid_login(self, mock_signal):
3838 response = self .
_post ({
'auth-username' :
'[email protected] ' ,
3939 'auth-password' : 'secret' ,
4040 'login_view-current_step' : 'auth' })
41- self .assertRedirects (response , reverse ( 'two_factor:setup' ))
41+ self .assertRedirects (response , resolve_url ( settings . LOGIN_REDIRECT_URL ))
4242
4343 # No signal should be fired for non-verified user logins.
4444 self .assertFalse (mock_signal .called )
@@ -53,6 +53,16 @@ def test_valid_login_with_custom_redirect(self):
5353 'login_view-current_step' : 'auth' })
5454 self .assertRedirects (response , redirect_url )
5555
56+ def test_valid_login_non_class_based_redirect (self ):
57+ redirect_url = reverse ('plain' )
58+ self .create_user ()
59+ response = self .client .post (
60+ '%s?%s' % (reverse ('two_factor:login' ), 'next=' + redirect_url ),
61+ {
'auth-username' :
'[email protected] ' ,
62+ 'auth-password' : 'secret' ,
63+ 'login_view-current_step' : 'auth' })
64+ self .assertRedirects (response , redirect_url )
65+
5666 def test_valid_login_with_custom_post_redirect (self ):
5767 redirect_url = reverse ('two_factor:setup' )
5868 self .create_user ()
@@ -80,8 +90,7 @@ def test_valid_login_with_allowed_external_redirect(self):
8090 {
'auth-username' :
'[email protected] ' ,
8191 'auth-password' : 'secret' ,
8292 'login_view-current_step' : 'auth' })
83- self .assertEqual (self .client .session .get ('next' ), redirect_url )
84- self .assertRedirects (response , reverse ('two_factor:setup' ), fetch_redirect_response = False )
93+ self .assertRedirects (response , redirect_url , fetch_redirect_response = False )
8594
8695 def test_valid_login_with_disallowed_external_redirect (self ):
8796 redirect_url = 'https://test.disallowed-success-url.com'
@@ -91,7 +100,7 @@ def test_valid_login_with_disallowed_external_redirect(self):
91100 {
'auth-username' :
'[email protected] ' ,
92101 'auth-password' : 'secret' ,
93102 'login_view-current_step' : 'auth' })
94- self .assertRedirects (response , reverse ('two_factor:setup ' ), fetch_redirect_response = False )
103+ self .assertRedirects (response , reverse ('two_factor:profile ' ), fetch_redirect_response = False )
95104
96105 @mock .patch ('two_factor.views.core.time' )
97106 def test_valid_login_primary_key_stored (self , mock_time ):
@@ -396,12 +405,12 @@ def test_login_different_user_on_existing_session(self, mock_logger):
396405 response = self .
_post ({
'auth-username' :
'[email protected] ' ,
397406 'auth-password' : 'secret' ,
398407 'login_view-current_step' : 'auth' })
399- self .assertRedirects (response , reverse ( 'two_factor:setup' ))
408+ self .assertRedirects (response , resolve_url ( settings . LOGIN_REDIRECT_URL ))
400409
401410 response = self .
_post ({
'auth-username' :
'[email protected] ' ,
402411 'auth-password' : 'secret' ,
403412 'login_view-current_step' : 'auth' })
404- self .assertRedirects (response , reverse ( 'two_factor:setup' ))
413+ self .assertRedirects (response , resolve_url ( settings . LOGIN_REDIRECT_URL ))
405414
406415 def test_missing_management_data (self ):
407416 # missing management data
@@ -432,7 +441,7 @@ def test_login_different_user_with_otp_on_existing_session(self):
432441 response = self .
_post ({
'auth-username' :
'[email protected] ' ,
433442 'auth-password' : 'secret' ,
434443 'login_view-current_step' : 'auth' })
435- self .assertRedirects (response , reverse ( 'two_factor:setup' ))
444+ self .assertRedirects (response , resolve_url ( settings . LOGIN_REDIRECT_URL ))
436445
437446 response = self .
_post ({
'auth-username' :
'[email protected] ' ,
438447 'auth-password' : 'secret' ,
0 commit comments