Correct method names.
authorGunnar Wrobel <p@rdus.de>
Tue, 30 Nov 2010 15:40:07 +0000 (16:40 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 30 Nov 2010 15:40:07 +0000 (16:40 +0100)
framework/Token/lib/Horde/Token/Base.php
framework/Token/test/Horde/Token/Unit/FileTest.php
horde/login.php

index 91b8347..aa2aa84 100644 (file)
@@ -135,7 +135,7 @@ abstract class Horde_Token_Base
      *
      * @return boolean True if the token was valid.
      */
-    public function validate($token, $seed = '', $timeout = null, $unique = false)
+    public function isValid($token, $seed = '', $timeout = null, $unique = false)
     {
         list($nonce, $hash) = $this->_decode($token);
         if ($hash != $this->_hash($nonce . $seed)) {
@@ -164,7 +164,7 @@ nce?
      *
      * @throws Horde_Token_Exception If the token was invalid.
      */
-    public function isValid($token, $seed = '')
+    public function validate($token, $seed = '')
     {
         list($nonce, $hash) = $this->_decode($token);
         if ($hash != $this->_hash($nonce . $seed)) {
@@ -188,7 +188,7 @@ nce?
      *
      * @throws Horde_Token_Exception If the token was invalid or has been used before.
      */
-    public function isValidAndUnused($token, $seed = '')
+    public function validateUnique($token, $seed = '')
     {
         list($nonce, $hash) = $this->isValid($token, $seed);
         if (!$this->verify($nonce)) {
index e0d93c8..e083325 100644 (file)
@@ -48,43 +48,43 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
     public function testValidation()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertTrue($t->validate($t->get()));
+        $this->assertTrue($t->isValid($t->get()));
     }
 
     public function testValidationWithSeed()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertTrue($t->validate($t->get('a'), 'a'));
+        $this->assertTrue($t->isValid($t->get('a'), 'a'));
     }
 
     public function testInvalidToken()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertFalse($t->validate('something'));
+        $this->assertFalse($t->isValid('something'));
     }
 
     public function testInvalidEmptyToken()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertFalse($t->validate(''));
+        $this->assertFalse($t->isValid(''));
     }
 
     public function testInvalidSeed()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertFalse($t->validate($t->get('a'), 'b'));
+        $this->assertFalse($t->isValid($t->get('a'), 'b'));
     }
 
     public function testActiveToken()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertTrue($t->validate($t->get('a'), 'a', 10));
+        $this->assertTrue($t->isValid($t->get('a'), 'a', 10));
     }
 
     public function testImmediateTimeout()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $this->assertFalse($t->validate($t->get('a'), 'a', 0));
+        $this->assertFalse($t->isValid($t->get('a'), 'a', 0));
     }
 
     public function testTimeoutAfterOneSecond()
@@ -97,9 +97,9 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
         );
         $token = $t->get('a');
         sleep(1);
-        $this->assertFalse($t->validate($token, 'a', 1));
+        $this->assertFalse($t->isValid($token, 'a', 1));
         // Pack two assertions in this test to avoid sleeping twice
-        $this->assertFalse($t->validate($token, 'a'));
+        $this->assertFalse($t->isValid($token, 'a'));
     }
 
     public function testTokenLifetimeParameter()
@@ -110,7 +110,7 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
                 'token_lifetime' => -1
             )
         );
-        $this->assertTrue($t->validate($t->get()));
+        $this->assertTrue($t->isValid($t->get()));
     }
 
     public function testUniqueToken()
@@ -122,8 +122,8 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
             )
         );
         $token = $t->get('a');
-        $t->validate($token, 'a', -1, true);
-        $this->assertFalse($t->validate($token, 'a', -1, true));
+        $t->isValid($token, 'a', -1, true);
+        $this->assertFalse($t->isValid($token, 'a', -1, true));
     }
 
     public function testNonces()
@@ -138,7 +138,7 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
     public function testInvalidTokenException()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $t->isValid('something');
+        $t->validate('something');
     }
 
     /**
@@ -147,7 +147,7 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
     public function testInvalidSeedException()
     {
         $t = new Horde_Token_File(array('secret' => 'abc'));
-        $t->isValid($t->get('a'), 'b');
+        $t->validate($t->get('a'), 'b');
     }
 
     /**
@@ -163,7 +163,7 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
         );
         $token = $t->get('a');
         sleep(1);
-        $t->isValid($token, 'a');
+        $t->validate($token, 'a');
     }
 
     /**
@@ -178,8 +178,8 @@ class Horde_Token_Unit_FileTest extends PHPUnit_Framework_TestCase
             )
         );
         $token = $t->get('a');
-        $t->isValidAndUnused($token, 'a');
-        $t->isValidAndUnused($token, 'a');
+        $t->validateUnique($token, 'a');
+        $t->validateUnique($token, 'a');
     }
 
     /**
index 9d3ec6d..1fa2918 100644 (file)
@@ -124,7 +124,7 @@ case Horde_Auth::REASON_LOGOUT:
 if ($logout_reason) {
     if ($is_auth) {
         try {
-            $injector->getInstance('Horde_Token')->isValid($vars->horde_logout_token, 'horde.logout');
+            $injector->getInstance('Horde_Token')->validate($vars->horde_logout_token, 'horde.logout');
         } catch (Horde_Exception $e) {
             $notification->push($e, 'horde.error');
             require HORDE_BASE . '/index.php';