From 580371faaaf493373cf63676ff64969fcf3c622d Mon Sep 17 00:00:00 2001 From: Sixto Martin Date: Sun, 29 Sep 2024 19:54:10 +0200 Subject: [PATCH] Add more tests --- tests/src/OneLogin/Saml2/UtilsTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/src/OneLogin/Saml2/UtilsTest.php b/tests/src/OneLogin/Saml2/UtilsTest.php index eb9004bd..0471c8a6 100644 --- a/tests/src/OneLogin/Saml2/UtilsTest.php +++ b/tests/src/OneLogin/Saml2/UtilsTest.php @@ -460,6 +460,9 @@ public function testSetBaseURLPath() { $this->assertNull(Utils::getBaseURLPath()); + Utils::setBaseURLPath('/'); + $this->assertEquals('/', Utils::getBaseURLPath()); + Utils::setBaseURLPath('sp'); $this->assertEquals('/sp/', Utils::getBaseURLPath()); @@ -473,6 +476,25 @@ public function testSetBaseURLPath() $this->assertEquals('/sp/', Utils::getBaseURLPath()); } + /** + * @covers OneLogin\Saml2\Utils::setBaseURLPath + */ + public function testSetBaseURLPath2() + { + $_SERVER['HTTP_HOST'] = 'sp.example.com'; + $_SERVER['HTTPS'] = 'https'; + $_SERVER['REQUEST_URI'] = null; + $_SERVER['QUERY_STRING'] = null; + $_SERVER['SCRIPT_NAME'] = '/'; + unset($_SERVER['PATH_INFO']); + + Utils::setBaseURLPath('/'); + $this->assertEquals("https://sp.example.com/", Utils::getSelfURLNoQuery()); + $this->assertEquals("https://sp.example.com/", Utils::getSelfRoutedURLNoQuery()); + $this->assertEquals("https://sp.example.com/", Utils::getSelfURL()); + $this->assertEquals('/', Utils::getBaseURLPath()); + } + /** * @covers OneLogin\Saml2\Utils::setBaseURL *