@@ -448,6 +448,9 @@ public function testSetBaseURLPath()
448
448
{
449
449
$ this ->assertNull (OneLogin_Saml2_Utils::getBaseURLPath ());
450
450
451
+ OneLogin_Saml2_Utils::setBaseURLPath ('/ ' );
452
+ $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
453
+
451
454
OneLogin_Saml2_Utils::setBaseURLPath ('sp ' );
452
455
$ this ->assertEquals ('/sp/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
453
456
@@ -461,6 +464,25 @@ public function testSetBaseURLPath()
461
464
$ this ->assertEquals ('/sp/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
462
465
}
463
466
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
+
464
486
/**
465
487
* @covers OneLogin_Saml2_Utils::setBaseURL
466
488
*/
@@ -513,6 +535,16 @@ public function testSetBaseURL()
513
535
$ this ->assertEquals ($ expectedRoutedUrlNQ2 , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
514
536
$ this ->assertEquals ($ expectedUrl2 , OneLogin_Saml2_Utils::getSelfURL ());
515
537
$ 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 ());
516
548
}
517
549
518
550
/**
@@ -572,6 +604,13 @@ public function testGetSelfURL()
572
604
573
605
$ _SERVER ['REQUEST_URI ' ] = 'https://example.com/testing ' ;
574
606
$ 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
+
575
614
}
576
615
577
616
/**
0 commit comments