diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2016-03-03 11:48:54 +0100 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2016-03-03 11:48:54 +0100 |
commit | d4de56da714ffc46cfee0b066c723c21be527c79 (patch) | |
tree | f79bb33b6e580868fb071da5915f7da0edcab9ec /tests/lib/SimpleSAML/Utils/HTTPTest.php | |
parent | 7ce18d59c208fb28baaef549280d09bf9b9dc903 (diff) | |
download | simplesamlphp-d4de56da714ffc46cfee0b066c723c21be527c79.zip simplesamlphp-d4de56da714ffc46cfee0b066c723c21be527c79.tar.gz simplesamlphp-d4de56da714ffc46cfee0b066c723c21be527c79.tar.bz2 |
Rename Utils\HTTP::getSelfHostWithoutPort() to Utils\HTTP::getSelfHostWithNonStandardPort(), change the logic, and reimplement Utils\HTTP::getSelfHost() to depend on use the former. Complete the tests to include the case of port 443 while using HTTPS.
Diffstat (limited to 'tests/lib/SimpleSAML/Utils/HTTPTest.php')
-rw-r--r-- | tests/lib/SimpleSAML/Utils/HTTPTest.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/lib/SimpleSAML/Utils/HTTPTest.php b/tests/lib/SimpleSAML/Utils/HTTPTest.php index b4e9845..f67b883 100644 --- a/tests/lib/SimpleSAML/Utils/HTTPTest.php +++ b/tests/lib/SimpleSAML/Utils/HTTPTest.php @@ -6,7 +6,7 @@ use SimpleSAML\Utils\HTTP; class HTTPTest extends \PHPUnit_Framework_TestCase { /** - * Test HTTP::getSelfHost with and without custom port + * Test SimpleSAML\Utils\HTTP::getSelfHost() with and without custom port. */ public function testGetSelfHost() { @@ -16,20 +16,29 @@ class HTTPTest extends \PHPUnit_Framework_TestCase $_SERVER['SERVER_PORT'] = '80'; $this->assertEquals('localhost', HTTP::getSelfHost()); $_SERVER['SERVER_PORT'] = '3030'; - $this->assertEquals('localhost:3030', HTTP::getSelfHost()); + $this->assertEquals('localhost', HTTP::getSelfHost()); } /** - * Test HTTP::getSelfHostWithoutPort + * Test SimpleSAML\Utils\HTTP::getSelfHostWithPort(), with and without custom port. */ - public function testGetSelfHostWithoutPort() + public function testGetSelfHostWithPort() { \SimpleSAML_Configuration::loadFromArray(array( 'baseurlpath' => '', ), '[ARRAY]', 'simplesaml'); + + // standard port for HTTP $_SERVER['SERVER_PORT'] = '80'; - $this->assertEquals('localhost', HTTP::getSelfHostWithoutPort()); + $this->assertEquals('localhost', HTTP::getSelfHostWithNonStandardPort()); + + // non-standard port $_SERVER['SERVER_PORT'] = '3030'; - $this->assertEquals('localhost', HTTP::getSelfHostWithoutPort()); + $this->assertEquals('localhost:3030', HTTP::getSelfHostWithNonStandardPort()); + + // standard port for HTTPS + $_SERVER['HTTPS'] = 'on'; + $_SERVER['SERVER_PORT'] = '443'; + $this->assertEquals('localhost', HTTP::getSelfHostWithNonStandardPort()); } } |