Browse Source

Fix cookie decryption when using psr7

Jad Bitar 9 years ago
parent
commit
c7704bea42

+ 1 - 1
src/Http/ResponseTransformer.php

@@ -101,7 +101,7 @@ class ResponseTransformer
             }
 
             list($name, $value) = explode('=', array_shift($parts), 2);
-            $parsed = compact('name', 'value');
+            $parsed = compact('name') + ['value' => urldecode($value)];
 
             foreach ($parts as $part) {
                 if (strpos($part, '=') !== false) {

+ 21 - 0
tests/TestCase/TestSuite/CookieEncryptedUsingControllerTest.php

@@ -44,6 +44,17 @@ class CookieEncryptedUsingControllerTest extends IntegrationTestCase
     }
 
     /**
+     * tear down.
+     *
+     * @return void
+     */
+    public function tearDown()
+    {
+        parent::tearDown();
+        $this->_useHttpServer = false;
+    }
+
+    /**
      * Can encrypt/decrypt the cookie value.
      */
     public function testCanEncryptAndDecryptWithAes()
@@ -140,4 +151,14 @@ class CookieEncryptedUsingControllerTest extends IntegrationTestCase
         $this->get('/cookie_component_test/set_cookie');
         $this->assertCookieEncrypted('abc', 'NameOfCookie', 'aes', $key);
     }
+
+    /**
+     * Can AssertCookie even if encrypted with the aes when using PSR7 server.
+     */
+    public function testCanAssertCookieEncryptedWithAesWhenUsingPsr7()
+    {
+        $this->_useHttpServer = true;
+        $this->get('/cookie_component_test/set_cookie');
+        $this->assertCookieEncrypted('abc', 'NameOfCookie', 'aes');
+    }
 }

+ 2 - 0
tests/test_app/TestApp/Controller/CookieComponentTestController.php

@@ -27,6 +27,8 @@ class CookieComponentTestController extends Controller
         'Cookie',
     ];
 
+    public $autoRender = false;
+
     /**
      * view
      *