Browse Source

increases time window in CSRF token expiry tests to 2 seconds

travis-cs failed with 1 second margin
Schlaefer 11 years ago
parent
commit
1e961a8aac
1 changed files with 2 additions and 4 deletions
  1. 2 4
      lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php

+ 2 - 4
lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php

@@ -1214,8 +1214,7 @@ class SecurityComponentTest extends CakeTestCase {
 		$token = $this->Security->Session->read('_Token');
 		$this->assertEquals(2, count($token['csrfTokens']), 'Missing the csrf token.');
 		foreach ($token['csrfTokens'] as $expires) {
-			$diff = $csrfExpires - $expires;
-			$this->assertTrue($diff === 0 || $diff === 1, 'Token expiry does not match');
+			$this->assertWithinMargin($expires, $csrfExpires, 2, 'Token expiry does not match');
 		}
 	}
 
@@ -1264,8 +1263,7 @@ class SecurityComponentTest extends CakeTestCase {
 
 		$this->Security->startup($this->Controller);
 		$tokens = $this->Security->Session->read('_Token.csrfTokens');
-		$diff = strtotime($csrfExpires) - $tokens['token'];
-		$this->assertTrue($diff === 0 || $diff === 1, 'Token expiry was not renewed');
+		$this->assertWithinMargin($tokens['token'], strtotime($csrfExpires), 2, 'Token expiry was not renewed');
 	}
 
 /**