summaryrefslogtreecommitdiffstats
path: root/tests/lib/SimpleSAML/Utils/HTTPTest.php
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2016-06-07 16:03:02 +0200
committerJaime Perez Crespo <jaime.perez@uninett.no>2016-06-07 16:03:02 +0200
commit07840369675cba5f99f68243afd8a326be189c17 (patch)
treeb1f4eef2c76187ac217c95b9b8bd5b6e5a8e67bd /tests/lib/SimpleSAML/Utils/HTTPTest.php
parent4aef583beff58cbf2c30b7f1c920fb9d61929f2a (diff)
downloadsimplesamlphp-07840369675cba5f99f68243afd8a326be189c17.zip
simplesamlphp-07840369675cba5f99f68243afd8a326be189c17.tar.gz
simplesamlphp-07840369675cba5f99f68243afd8a326be189c17.tar.bz2
Make sure the modifications to $_SERVER in the tests do not go beyond each test.
Diffstat (limited to 'tests/lib/SimpleSAML/Utils/HTTPTest.php')
-rw-r--r--tests/lib/SimpleSAML/Utils/HTTPTest.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/lib/SimpleSAML/Utils/HTTPTest.php b/tests/lib/SimpleSAML/Utils/HTTPTest.php
index f73a6db..3962fb5 100644
--- a/tests/lib/SimpleSAML/Utils/HTTPTest.php
+++ b/tests/lib/SimpleSAML/Utils/HTTPTest.php
@@ -100,6 +100,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
*/
public function testGetSelfHost()
{
+ $original = $_SERVER;
+
\SimpleSAML_Configuration::loadFromArray(array(
'baseurlpath' => '',
), '[ARRAY]', 'simplesaml');
@@ -107,6 +109,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('localhost', HTTP::getSelfHost());
$_SERVER['SERVER_PORT'] = '3030';
$this->assertEquals('localhost', HTTP::getSelfHost());
+
+ $_SERVER = $original;
}
/**
@@ -114,6 +118,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
*/
public function testGetSelfHostWithPort()
{
+ $original = $_SERVER;
+
\SimpleSAML_Configuration::loadFromArray(array(
'baseurlpath' => '',
), '[ARRAY]', 'simplesaml');
@@ -130,6 +136,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = '443';
$this->assertEquals('localhost', HTTP::getSelfHostWithNonStandardPort());
+
+ $_SERVER = $original;
}
/**
@@ -137,6 +145,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckURLAllowedWithoutRegex()
{
+ $original = $_SERVER;
+
\SimpleSAML_Configuration::loadFromArray(array(
'trusted.url.domains' => array('sp.example.com', 'app.example.com'),
'trusted.url.regex' => false,
@@ -157,6 +167,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
$this->setExpectedException('SimpleSAML_Error_Exception');
HTTP::checkURLAllowed('https://evil.com');
+
+ $_SERVER = $original;
}
/**
@@ -164,6 +176,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckURLAllowedWithRegex()
{
+ $original = $_SERVER;
+
\SimpleSAML_Configuration::loadFromArray(array(
'trusted.url.domains' => array('.*\.example\.com'),
'trusted.url.regex' => true,
@@ -186,6 +200,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
$this->setExpectedException('SimpleSAML_Error_Exception');
HTTP::checkURLAllowed('https://evil.com');
+
+ $_SERVER = $original;
}
/**
@@ -194,6 +210,8 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckURLAllowedWithRegexWithoutDelimiters()
{
+ $original = $_SERVER;
+
\SimpleSAML_Configuration::loadFromArray(array(
'trusted.url.domains' => array('app\.example\.com'),
'trusted.url.regex' => true,
@@ -203,5 +221,7 @@ class HTTPTest extends \PHPUnit_Framework_TestCase
$this->setExpectedException('SimpleSAML_Error_Exception');
HTTP::checkURLAllowed('https://app.example.com.evil.com');
+
+ $_SERVER = $original;
}
}