Skip to content
Permalink
Browse files

Making userAgent check test pass.

Reformatting code inside valid().
  • Loading branch information...
markstory committed Jul 8, 2010
1 parent b60b077 commit 1938e57cbcb54ee4aeb9bcfb2d66aee61b5ce500
Showing with 12 additions and 2 deletions.
  1. +6 −1 cake/libs/cake_session.php
  2. +6 −1 cake/tests/cases/libs/cake_session.test.php
@@ -334,7 +334,11 @@ public static function error() {
*/
public static function valid() {
if (self::read('Config')) {
if ((Configure::read('Session.checkAgent') === false || self::$_userAgent == self::read('Config.userAgent')) && self::$time <= self::read('Config.time')) {
$validAgent = (
Configure::read('Session.checkAgent') === false ||
self::$_userAgent == self::read('Config.userAgent')
);
if ($validAgent && self::$time <= self::read('Config.time')) {
if (self::$error === false) {
self::$valid = true;
}
@@ -442,6 +446,7 @@ public static function write($name, $value) {
*/
public function destroy() {
$_SESSION = array();
self::$id = null;
self::init(self::$path);
self::start();
self::renew();
@@ -256,6 +256,7 @@ function testDestroy() {
TestCakeSession::write('bulletProof', 'invicible');
$id = TestCakeSession::id();
TestCakeSession::destroy();
$this->assertFalse(TestCakeSession::check('bulletProof'));
$this->assertNotEqual($id, TestCakeSession::id());
}
@@ -350,7 +351,11 @@ function testCheckUserAgentFalse() {
*/
function testCheckUserAgentTrue() {
Configure::write('Session.checkAgent', true);
TestCakeSession::setUserAgent(md5('http://randomdomainname.com' . Configure::read('Security.salt')));
TestCakeSession::$error = false;
$agent = md5('http://randomdomainname.com' . Configure::read('Security.salt'));
TestCakeSession::write('Config.userAgent', md5('Hacking you!'));
TestCakeSession::setUserAgent($agent);
$this->assertFalse(TestCakeSession::valid());
}

0 comments on commit 1938e57

Please sign in to comment.
You can’t perform that action at this time.