Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-03-02 12:45:54 +0300
committerGitHub <noreply@github.com>2020-03-02 12:45:54 +0300
commit9c3c724aae2b87d15dab1fa130cee5a037bdfc1d (patch)
tree038f281bf7b4f1d011741057e5007ae45da39f72 /tests
parent2ffc440fef6c123ac335e6a8af1f144686a023bd (diff)
Fix session cookie expire (#15633)
* Fix session expire fixes #15625 * adds some tests
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/SessionTest.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/SessionTest.php b/tests/PHPUnit/Integration/SessionTest.php
index 8c6eade11c..5b216e436c 100644
--- a/tests/PHPUnit/Integration/SessionTest.php
+++ b/tests/PHPUnit/Integration/SessionTest.php
@@ -27,4 +27,46 @@ class SessionTest extends \PHPUnit_Framework_TestCase
$this->assertSame('ok', trim($result));
}
+ /**
+ * @dataProvider getCookieTests
+ */
+ public function testWriteCookie($expected, $name, $value, $expires, $path, $domain, $secure, $httpOnly, $sameSite)
+ {
+ $result = Session::writeCookie($name, $value, $expires, $path, $domain, $secure, $httpOnly, $sameSite);
+ $this->assertEquals($expected, $result);
+ }
+
+ public function getCookieTests()
+ {
+ return [
+ [
+ 'Set-Cookie: myname=myvalue; expires=Tue, 03-May-2022 02:27:34 GMT; path=/; domain=my.test.domain; secure; httponly; SameSite=lax',
+ 'myname', 'myvalue', 1651544854, '/', 'my.test.domain', true, true, 'lax'
+ ],
+ [
+ 'Set-Cookie: myname=myvalue; expires=Tue, 03-May-2022 02:27:34 GMT; path=/; domain=my.test.domain; httponly; SameSite=none',
+ 'myname', 'myvalue', 1651544854, '/', 'my.test.domain', false, true, 'none'
+ ],
+ [
+ 'Set-Cookie: %3Cxss%3Emyname%26%24=my%3Cxss%3E%27%24%25value; expires=Tue, 03-May-2022 02:27:34 GMT; path=/; domain=ma%3Cf0r3%24%25%25.tld; SameSite=lax',
+ '<xss>myname&$', 'my<xss>\'$%value', 1651544854, '/', 'ma<f0r3$%%.tld', false, false, 'lax'
+ ],
+ [
+ 'Set-Cookie: myname=myvalue; expires=Tue, 03-May-2022 02:27:34 GMT; path=/; domain=my.test.domain',
+ 'myname', 'myvalue', 1651544854, '/', 'my.test.domain', false, false, ''
+ ],
+ [
+ 'Set-Cookie: myname=myvalue; expires=Tue, 03-May-2022 02:27:34 GMT; path=/',
+ 'myname', 'myvalue', 1651544854, '/', '', false, false, ''
+ ],
+ [
+ 'Set-Cookie: myname=myvalue; path=/',
+ 'myname', 'myvalue', 0, '/', '', false, false, ''
+ ],
+ [
+ 'Set-Cookie: myname=myvalue',
+ 'myname', 'myvalue', 0, '', '', false, false, ''
+ ],
+ ];
+ }
}