mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
36 lines
982 B
PHP
36 lines
982 B
PHP
<?php
|
|
|
|
namespace Alchemy\Tests\Phrasea\Authentication;
|
|
|
|
use Alchemy\Phrasea\Authentication\Token\TokenValidator;
|
|
|
|
class TokenValidatorTest extends \PhraseanetPHPUnitAbstract
|
|
{
|
|
/**
|
|
* @covers Alchemy\Phrasea\Authentication\TokenValidator::isValid
|
|
*/
|
|
public function testValidTokenIsValid()
|
|
{
|
|
$app = self::$DI['app'];
|
|
$usr_id = 42;
|
|
|
|
$token = \random::getUrlToken($app, \random::TYPE_VALIDATE, $usr_id);
|
|
|
|
$validator = new TokenValidator($app);
|
|
$this->assertEquals($usr_id, $validator->isValid($token));
|
|
}
|
|
/**
|
|
* @covers Alchemy\Phrasea\Authentication\TokenValidator::isValid
|
|
*/
|
|
public function testInvalidTokenIsNotValid()
|
|
{
|
|
$app = self::$DI['app'];
|
|
$usr_id = 42;
|
|
|
|
$token = \random::getUrlToken($app, \random::TYPE_VALIDATE, $usr_id, new \DateTime('-2 hours'));
|
|
|
|
$validator = new TokenValidator($app);
|
|
$this->assertFalse($validator->isValid($token));
|
|
}
|
|
}
|