@@ -605,6 +605,37 @@ def testLoginWithRelayState(self):
605605 self .assertIn ('RelayState' , parsed_query )
606606 self .assertIn (relay_state , parsed_query ['RelayState' ])
607607
608+ def testLoginPost (self ):
609+ settings_info = self .loadSettingsJSON ()
610+ request_data = self .get_request ()
611+ auth = OneLogin_Saml2_Auth (self .get_request (), old_settings = settings_info )
612+
613+ url , parameters = auth .login_post ()
614+ self .assertEqual (url , 'http://idp.example.com/SSOService.php' )
615+ # self.assertEqual(parameters['RelayState'], relay_state)
616+ saml_request = b64decode (parameters ['SAMLRequest' ])
617+ self .assertTrue (saml_request .startswith (b'<samlp:AuthnRequest' ))
618+
619+ hostname = OneLogin_Saml2_Utils .get_self_host (request_data )
620+ self .assertEqual (parameters ['RelayState' ], 'http://%s/index.html' % hostname )
621+
622+ self .assertIn (b'<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>' , saml_request )
623+ self .assertIn (b'<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>' , saml_request )
624+
625+ def testLoginPostWithRelayState (self ):
626+ settings_info = self .loadSettingsJSON ()
627+ auth = OneLogin_Saml2_Auth (self .get_request (), old_settings = settings_info )
628+ relay_state = 'http://sp.example.com'
629+
630+ url , parameters = auth .login_post (relay_state )
631+ self .assertEqual (url , 'http://idp.example.com/SSOService.php' )
632+ self .assertEqual (parameters ['RelayState' ], relay_state )
633+ saml_request = b64decode (parameters ['SAMLRequest' ])
634+ self .assertTrue (saml_request .startswith (b'<samlp:AuthnRequest' ))
635+
636+ self .assertIn (b'<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>' , saml_request )
637+ self .assertIn (b'<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>' , saml_request )
638+
608639 def testLoginSigned (self ):
609640 """
610641 Tests the login method of the OneLogin_Saml2_Auth class
0 commit comments