summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRob DiMarco <rob@firebase.com>2015-04-01 11:39:37 -0700
committerRob DiMarco <rob@firebase.com>2015-04-01 11:39:37 -0700
commitc6583dc5e904787563e0ee4ebca3ac7e811a5f3a (patch)
tree8c07031f55c7e7da1a5219f29d5d3e056e231298 /tests
parentd137805eeb4d7a2d1fee2be380c920b2210416ec (diff)
parent4e15ea5ac53f9e543e565a85bd8f48db187c1ff8 (diff)
downloadphp-jwt-c6583dc5e904787563e0ee4ebca3ac7e811a5f3a.zip
php-jwt-c6583dc5e904787563e0ee4ebca3ac7e811a5f3a.tar.gz
php-jwt-c6583dc5e904787563e0ee4ebca3ac7e811a5f3a.tar.bz2
Merge pull request #36 from firebase/cr-additional-tests
Add a few add'l tests - more forthcoming
Diffstat (limited to 'tests')
-rw-r--r--tests/JWTTest.php31
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');
+ }
}