Initial commit
This commit is contained in:
34
tests/Validator/JwtValidatorTest.php
Normal file
34
tests/Validator/JwtValidatorTest.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\SimpleJwt\Validator;
|
||||
|
||||
use NoccyLabs\SimpleJwt\JwtToken;
|
||||
use NoccyLabs\SimpleJwt\Key\JwtPlaintextKey;
|
||||
|
||||
class JwtValidatorTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testValidKeysShouldPassWithDefaultConfiguration()
|
||||
{
|
||||
$key = new JwtPlaintextKey("key");
|
||||
$token = new JwtToken($key);
|
||||
|
||||
$validator = new JwtValidator();
|
||||
$valid = $validator->validateToken($token);
|
||||
$this->assertEquals(true, $valid);
|
||||
}
|
||||
|
||||
public function testExpiredKeysShouldFailWithException()
|
||||
{
|
||||
$key = new JwtPlaintextKey("key");
|
||||
$token = new JwtToken($key);
|
||||
$token->header->set("exp", 0);
|
||||
|
||||
$token = new JwtToken($key, $token->getSignedToken());
|
||||
|
||||
$validator = new JwtValidator();
|
||||
$this->expectException(JwtTokenException::class);
|
||||
$valid = $validator->validateToken($token);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user