Skip to content

Commit

Permalink
Add test for leading dot cookies.
Browse files Browse the repository at this point in the history
These cookies are 'deprecated' but still show up in server responses.
  • Loading branch information
markstory committed Mar 25, 2017
1 parent 8dbf562 commit bd317d9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/TestCase/Http/Cookie/CookieCollectionTest.php
Expand Up @@ -319,6 +319,26 @@ public function testAddToRequest()
$this->assertSame(['blog' => 'b'], $request->getCookieParams());
}

/**
* Test adding cookies ignores leading dot
*
* @return void
*/
public function testAddToRequestLeadingDot()
{
$collection = new CookieCollection();
$collection = $collection
->add(new Cookie('public', 'b', null, '/', '.example.com'));
$request = new ServerRequest([
'environment' => [
'HTTP_HOST' => 'example.com',
'REQUEST_URI' => '/blog'
]
]);
$request = $collection->addToRequest($request);
$this->assertSame(['public' => 'b'], $request->getCookieParams());
}

/**
* Test adding cookies checks the secure crumb
*
Expand All @@ -329,7 +349,7 @@ public function testAddToRequestSecureCrumb()
$collection = new CookieCollection();
$collection = $collection
->add(new Cookie('secret', 'A', null, '/', 'example.com', true))
->add(new Cookie('public', 'b', null, '/', 'example.com', false));
->add(new Cookie('public', 'b', null, '/', '.example.com', false));
$request = new ServerRequest([
'environment' => [
'HTTPS' => 'on',
Expand Down

0 comments on commit bd317d9

Please sign in to comment.