Skip to content

Commit 004f4a8

Browse files
committed
Adds negative test for secure cookie flag
1 parent a7c25f9 commit 004f4a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/csrfprotector_test.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,20 @@ public function testRefreshToken()
105105
$this->assertTrue(csrfp_wrapper::checkHeader($_SESSION[csrfprotector::$config['CSRFP_TOKEN']][1]));
106106
}
107107

108+
/**
109+
* test secure flag is set in the token cookie when requested
110+
*/
108111
public function testSecureCookie()
109112
{
110113
$_SERVER['REQUEST_METHOD'] = 'POST';
111114
$_SESSION[csrfprotector::$config['CSRFP_TOKEN']] = array('123abcd');
112115

116+
csrfprotector::$config['secureCookie'] = false;
117+
csrfprotector::refreshToken();
118+
$this->assertNotRegExp('/; secure/', csrfp_wrapper::getHeaderValue('Set-Cookie'));
119+
113120
csrfprotector::$config['secureCookie'] = true;
114-
csrfprotector::refreshToken(); //will create new session and cookies
121+
csrfprotector::refreshToken();
115122
$this->assertRegExp('/; secure/', csrfp_wrapper::getHeaderValue('Set-Cookie'));
116123
}
117124

0 commit comments

Comments
 (0)