Skip to content

Commit

Permalink
Fix cookie decryption when using psr7
Browse files Browse the repository at this point in the history
  • Loading branch information
jadb committed Aug 14, 2016
1 parent 37b9149 commit c7704be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/ResponseTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected static function parseCookies(array $cookieHeader)
}

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) {
Expand Down
21 changes: 21 additions & 0 deletions tests/TestCase/TestSuite/CookieEncryptedUsingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public function setUp()
DispatcherFactory::add('ControllerFactory');
}

/**
* tear down.
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
$this->_useHttpServer = false;
}

/**
* Can encrypt/decrypt the cookie value.
*/
Expand Down Expand Up @@ -140,4 +151,14 @@ public function testCanAssertCookieEncryptedWithAnotherEncryptionKey()
$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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class CookieComponentTestController extends Controller
'Cookie',
];

public $autoRender = false;

/**
* view
*
Expand Down

0 comments on commit c7704be

Please sign in to comment.