mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add token entities
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Authentication\Token;
|
||||
|
||||
use Alchemy\Phrasea\Authentication\Token\TokenValidator;
|
||||
|
||||
class TokenValidatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Authentication\TokenValidator::isValid
|
||||
*/
|
||||
public function testValidTokenIsValid()
|
||||
{
|
||||
$usr_id = 42;
|
||||
$token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_VALIDATE, $usr_id);
|
||||
|
||||
$validator = new TokenValidator(self::$DI['app']['tokens']);
|
||||
$this->assertEquals($usr_id, $validator->isValid($token));
|
||||
}
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Authentication\TokenValidator::isValid
|
||||
*/
|
||||
public function testInvalidTokenIsNotValid()
|
||||
{
|
||||
$usr_id = 42;
|
||||
$token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_VALIDATE, $usr_id, new \DateTime('-2 hours'));
|
||||
|
||||
$validator = new TokenValidator(self::$DI['app']['tokens']);
|
||||
$this->assertFalse($validator->isValid($token));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user