Skip to content

Commit 0a12b84

Browse files
authored
Merge pull request SAML-Toolkits#159 from dhensby/pulls/proxy-tests
TESTS Added tests for get/setProxyVars
2 parents 5c04c9b + f9aa25f commit 0a12b84

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/src/OneLogin/Saml2/UtilsTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* Unit tests for Utils class
5+
*
6+
* @backupStaticAttributes enabled
57
*/
68
class OneLogin_Saml2_UtilsTest extends PHPUnit_Framework_TestCase
79
{
@@ -14,7 +16,7 @@ class OneLogin_Saml2_UtilsTest extends PHPUnit_Framework_TestCase
1416
/*
1517
public function testT()
1618
{
17-
setlocale(LC_MESSAGES, 'en_US');
19+
setlocale(LC_MESSAGES, 'en_US');
1820
1921
$msg = 'test';
2022
$translatedMsg = OneLogin_Saml2_Utils::t($msg);
@@ -275,6 +277,26 @@ public function testRedirect()
275277
$this->assertEquals("http://$hostname/example?alphavalue=a&numvaluelist[]=", $targetUrl8);
276278
}
277279

280+
/**
281+
* @covers OneLogin_Saml2_Utils::setProxyVars()
282+
* @covers OneLogin_Saml2_Utils::getProxyVars()
283+
*/
284+
public function testProxyvars()
285+
{
286+
$this->assertFalse(OneLogin_Saml2_Utils::getProxyVars());
287+
288+
OneLogin_Saml2_Utils::setProxyVars(true);
289+
$this->assertTrue(OneLogin_Saml2_Utils::getProxyVars());
290+
291+
$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
292+
$_SERVER['SERVER_PORT'] = '80';
293+
294+
$this->assertTrue(OneLogin_Saml2_Utils::isHTTPS());
295+
296+
OneLogin_Saml2_Utils::setProxyVars(false);
297+
$this->assertFalse(OneLogin_Saml2_Utils::isHTTPS());
298+
}
299+
278300
/**
279301
* Tests the getSelfHost method of the OneLogin_Saml2_Utils
280302
*

0 commit comments

Comments
 (0)