File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,8 +246,8 @@ def signin(self, **kw):
246246 "token" : credentials [2 ],
247247 "type" : "saml_token" ,
248248 }
249- pre_uid = request .session .authenticate (dbname , credentials_dict )
250- resp = request .redirect (_get_login_redirect_url (pre_uid , url ), 303 )
249+ auth_info = request .session .authenticate (dbname , credentials_dict )
250+ resp = request .redirect (_get_login_redirect_url (auth_info [ "uid" ] , url ), 303 )
251251 resp .autocorrect_location_header = False
252252 return resp
253253
Original file line number Diff line number Diff line change @@ -628,6 +628,31 @@ def test_signin_no_relaystate_redirect(self):
628628 self .assertEqual (signin_response .status_code , 303 )
629629 self .assertIn ("/?type=signup" , signin_response .headers ["Location" ])
630630
631+ def test_signin_redirect_mfa (self ):
632+ """Test redirect to mfa url"""
633+ self .add_provider_to_user ()
634+
635+ redirect_url = self .saml_provider ._get_auth_request ({"a" : "action" })
636+ response = self .idp .fake_login (redirect_url )
637+ unpacked_response = response ._unpack ()
638+
639+ for key in unpacked_response :
640+ unpacked_response [key ] = html .unescape (unpacked_response [key ])
641+ with patch .object (
642+ self .env .registry ["res.users" ], "_mfa_url" , return_value = "/web/login/totp"
643+ ):
644+ response = self .url_open (
645+ "/auth_saml/signin" ,
646+ data = unpacked_response ,
647+ allow_redirects = True ,
648+ timeout = 300 ,
649+ )
650+ self .assertTrue (response .ok )
651+ self .assertEqual (
652+ response .url ,
653+ self .base_url () + "/web/login/totp?redirect=%2F%23action%3Daction" ,
654+ )
655+
631656 def test_action_redirect (self ):
632657 """Test that providing action will do correct redirect."""
633658 self .add_provider_to_user ()
You can’t perform that action at this time.
0 commit comments