Browse Source

Merge pull request #6888 from Schlaefer/fix/expiry

fix cookie expire value from CsrfComponent not used
Mark Story 10 years ago
parent
commit
e5cf59f20e

+ 1 - 1
src/Controller/Component/CsrfComponent.php

@@ -125,7 +125,7 @@ class CsrfComponent extends Component
         $response->cookie([
             'name' => $this->_config['cookieName'],
             'value' => $value,
-            'expiry' => $this->_config['expiry'],
+            'expire' => $this->_config['expiry'],
             'path' => $request->webroot,
             'secure' => $this->_config['secure'],
         ]);

+ 2 - 2
tests/TestCase/Controller/Component/CsrfComponentTest.php

@@ -72,7 +72,7 @@ class CsrfComponentTest extends TestCase
         $cookie = $controller->response->cookie('csrfToken');
         $this->assertNotEmpty($cookie, 'Should set a token.');
         $this->assertRegExp('/^[a-f0-9]+$/', $cookie['value'], 'Should look like a hash.');
-        $this->assertEquals(0, $cookie['expiry'], 'session duration.');
+        $this->assertEquals(0, $cookie['expire'], 'session duration.');
         $this->assertEquals('/dir/', $cookie['path'], 'session path.');
 
         $this->assertEquals($cookie['value'], $controller->request->params['_csrfToken']);
@@ -273,7 +273,7 @@ class CsrfComponentTest extends TestCase
         $cookie = $controller->response->cookie('token');
         $this->assertNotEmpty($cookie, 'Should set a token.');
         $this->assertRegExp('/^[a-f0-9]+$/', $cookie['value'], 'Should look like a hash.');
-        $this->assertEquals(90, $cookie['expiry'], 'session duration.');
+        $this->assertEquals(90, $cookie['expire'], 'session duration.');
         $this->assertEquals('/dir/', $cookie['path'], 'session path.');
         $this->assertTrue($cookie['secure'], 'cookie security flag missing');
     }