|
|
@@ -650,6 +650,40 @@ class CookieComponentTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testReadingMalformedEncryptedCookies
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testReadingMalformedEncryptedCookies()
|
|
|
+ {
|
|
|
+ $this->Cookie->configKey('Encrypted_empty', 'encryption', 'aes');
|
|
|
+ $this->Cookie->configKey('Encrypted_wrong_prefix', 'encryption', 'aes');
|
|
|
+ $this->Cookie->configKey('Encrypted_altered', 'encryption', 'aes');
|
|
|
+ $this->Cookie->configKey('Encrypted_invalid_chars', 'encryption', 'aes');
|
|
|
+
|
|
|
+ $encrypted = $this->_encrypt('secret data', 'aes');
|
|
|
+
|
|
|
+ $this->Controller->request = $this->request->withCookieParams([
|
|
|
+ 'Encrypted_empty' => '',
|
|
|
+ 'Encrypted_wrong_prefix' => substr_replace($encrypted, 'foo', 0, 3),
|
|
|
+ 'Encrypted_altered' => str_replace('M', 'A', $encrypted),
|
|
|
+ 'Encrypted_invalid_chars' => str_replace('M', 'M#', $encrypted),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $data = $this->Cookie->read('Encrypted_empty');
|
|
|
+ $this->assertEquals('', $data);
|
|
|
+
|
|
|
+ $data = $this->Cookie->read('Encrypted_wrong_prefix');
|
|
|
+ $this->assertEquals('', $data);
|
|
|
+
|
|
|
+ $data = $this->Cookie->read('Encrypted_altered');
|
|
|
+ $this->assertEquals('', $data);
|
|
|
+
|
|
|
+ $data = $this->Cookie->read('Encrypted_invalid_chars');
|
|
|
+ $this->assertEquals('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Test Reading legacy cookie values.
|
|
|
*
|
|
|
* @return void
|