@@ -448,6 +448,9 @@ public function testSetBaseURLPath()
448448 {
449449 $ this ->assertNull (OneLogin_Saml2_Utils::getBaseURLPath ());
450450
451+ OneLogin_Saml2_Utils::setBaseURLPath ('/ ' );
452+ $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
453+
451454 OneLogin_Saml2_Utils::setBaseURLPath ('sp ' );
452455 $ this ->assertEquals ('/sp/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
453456
@@ -461,6 +464,25 @@ public function testSetBaseURLPath()
461464 $ this ->assertEquals ('/sp/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
462465 }
463466
467+ /**
468+ * @covers OneLogin_Saml2_Utils::setBaseURLPath
469+ */
470+ public function testSetBaseURLPath2 ()
471+ {
472+ $ _SERVER ['HTTP_HOST ' ] = 'sp.example.com ' ;
473+ $ _SERVER ['HTTPS ' ] = 'https ' ;
474+ $ _SERVER ['REQUEST_URI ' ] = null ;
475+ $ _SERVER ['QUERY_STRING ' ] = null ;
476+ $ _SERVER ['SCRIPT_NAME ' ] = '/ ' ;
477+ unset($ _SERVER ['PATH_INFO ' ]);
478+
479+ OneLogin_Saml2_Utils::setBaseURLPath ('/ ' );
480+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfURLNoQuery ());
481+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
482+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfURL ());
483+ $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
484+ }
485+
464486 /**
465487 * @covers OneLogin_Saml2_Utils::setBaseURL
466488 */
@@ -513,6 +535,16 @@ public function testSetBaseURL()
513535 $ this ->assertEquals ($ expectedRoutedUrlNQ2 , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
514536 $ this ->assertEquals ($ expectedUrl2 , OneLogin_Saml2_Utils::getSelfURL ());
515537 $ this ->assertEquals ('/example2/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
538+
539+ $ _SERVER ['PATH_INFO ' ] = null ;
540+ $ _SERVER ['REQUEST_URI ' ] = null ;
541+ $ _SERVER ['QUERY_STRING ' ] = null ;
542+ $ _SERVER ['SCRIPT_NAME ' ] = '/ ' ;
543+ OneLogin_Saml2_Utils::setBaseURL ("https://sp.example.com/ " );
544+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfURLNoQuery ());
545+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
546+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfURL ());
547+ $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
516548 }
517549
518550 /**
@@ -572,6 +604,13 @@ public function testGetSelfURL()
572604
573605 $ _SERVER ['REQUEST_URI ' ] = 'https://example.com/testing ' ;
574606 $ this ->assertEquals ($ url .'/testing ' , OneLogin_Saml2_Utils::getSelfURL ());
607+
608+ $ _SERVER ['REQUEST_URI ' ] = 'https://example.com/test/ ' ;
609+ $ this ->assertEquals ($ url .'/test/ ' , OneLogin_Saml2_Utils::getSelfURL ());
610+
611+ $ _SERVER ['REQUEST_URI ' ] = 'https://example.com/ ' ;
612+ $ this ->assertEquals ($ url .'/ ' , OneLogin_Saml2_Utils::getSelfURL ());
613+
575614 }
576615
577616 /**
0 commit comments