From bd317d91f01b0d6501a4bcf819d37c1c1b1c120e Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 24 Mar 2017 21:32:54 -0400 Subject: [PATCH] Add test for leading dot cookies. These cookies are 'deprecated' but still show up in server responses. --- .../Http/Cookie/CookieCollectionTest.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/TestCase/Http/Cookie/CookieCollectionTest.php b/tests/TestCase/Http/Cookie/CookieCollectionTest.php index f6aad3d4e2d..863223771bf 100644 --- a/tests/TestCase/Http/Cookie/CookieCollectionTest.php +++ b/tests/TestCase/Http/Cookie/CookieCollectionTest.php @@ -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 * @@ -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',