summaryrefslogtreecommitdiffstats
path: root/tests/JWTTest.php
diff options
context:
space:
mode:
authorRob DiMarco <rob@firebase.com>2015-04-01 11:39:10 -0700
committerRob DiMarco <rob@firebase.com>2015-04-01 11:39:10 -0700
commit4e15ea5ac53f9e543e565a85bd8f48db187c1ff8 (patch)
tree4edc74208b829fc2b5341afe769643ad9f290808 /tests/JWTTest.php
parent9f71bef30a754c737556dc448c93364d0df6d1a3 (diff)
downloadphp-jwt-4e15ea5ac53f9e543e565a85bd8f48db187c1ff8.zip
php-jwt-4e15ea5ac53f9e543e565a85bd8f48db187c1ff8.tar.gz
php-jwt-4e15ea5ac53f9e543e565a85bd8f48db187c1ff8.tar.bz2
Add a few add'l tests
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r--tests/JWTTest.php19
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');
+ }
}