diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/JWTTest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 1ace7f5..c48427d 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -75,6 +75,16 @@ class JWTTest extends PHPUnit_Framework_TestCase $this->assertEquals($decoded->message, 'abc'); } + public function testValidTokenWithList() + { + $payload = array( + "message" => "abc", + "exp" => time() + 20); // time in the future + $encoded = JWT::encode($payload, 'my_key'); + $decoded = JWT::decode($encoded, 'my_key', array('HS256', 'HS512')); + $this->assertEquals($decoded->message, 'abc'); + } + public function testValidTokenWithNbf() { $payload = array( @@ -116,4 +126,25 @@ class JWTTest extends PHPUnit_Framework_TestCase $decoded = JWT::decode($msg, $keys, array('HS256')); $this->assertEquals($decoded, 'abc'); } + + public function testNoneAlgorithm() + { + $msg = JWT::encode('abc', 'my_key'); + $this->setExpectedException('DomainException'); + JWT::decode($msg, 'my_key', array('none')); + } + + public function testIncorrectAlgorithm() + { + $msg = JWT::encode('abc', 'my_key'); + $this->setExpectedException('DomainException'); + JWT::decode($msg, 'my_key', array('RS256')); + } + + public function testMissingAlgorithm() + { + $msg = JWT::encode('abc', 'my_key'); + $this->setExpectedException('DomainException'); + JWT::decode($msg, 'my_key'); + } } |