diff options
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r-- | tests/JWTTest.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php index cc2eb8c..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( @@ -117,7 +127,7 @@ class JWTTest extends PHPUnit_Framework_TestCase $this->assertEquals($decoded, 'abc'); } - public function testNoneToken() + public function testNoneAlgorithm() { $msg = JWT::encode('abc', 'my_key'); $this->setExpectedException('DomainException'); @@ -130,4 +140,11 @@ class JWTTest extends PHPUnit_Framework_TestCase $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'); + } } |