summaryrefslogtreecommitdiffstats
path: root/tests/JWTTest.php
diff options
context:
space:
mode:
authorBrendan Abbott <brendan@vuid.com>2014-11-17 11:27:21 +1000
committerBrendan Abbott <brendan@vuid.com>2014-11-17 11:27:21 +1000
commitec3a4a853ca62dddf1951972f8f5b37ea40b4ea8 (patch)
treeefe9e5e68420f99ff1a6b892638d9f690ac1ba71 /tests/JWTTest.php
parentc20a3cb3faf81ec9716449b6c07c27b14f52bc75 (diff)
downloadphp-jwt-ec3a4a853ca62dddf1951972f8f5b37ea40b4ea8.zip
php-jwt-ec3a4a853ca62dddf1951972f8f5b37ea40b4ea8.tar.gz
php-jwt-ec3a4a853ca62dddf1951972f8f5b37ea40b4ea8.tar.bz2
Add check for iat claim with some minor documentation updates
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r--tests/JWTTest.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php
index 5a76ed4..b7dbca0 100644
--- a/tests/JWTTest.php
+++ b/tests/JWTTest.php
@@ -45,7 +45,7 @@ class JWTTest extends PHPUnit_Framework_TestCase
JWT::decode($encoded, 'my_key');
}
- public function testBeforeValidToken()
+ public function testBeforeValidTokenWithNbf()
{
$this->setExpectedException('BeforeValidException');
$payload = array(
@@ -55,6 +55,16 @@ class JWTTest extends PHPUnit_Framework_TestCase
JWT::decode($encoded, 'my_key');
}
+ public function testBeforeValidTokenWithIat()
+ {
+ $this->setExpectedException('BeforeValidException');
+ $payload = array(
+ "message" => "abc",
+ "iat" => time() + 20); // time in the future
+ $encoded = JWT::encode($payload, 'my_key');
+ JWT::decode($encoded, 'my_key');
+ }
+
public function testValidToken()
{
$payload = array(
@@ -69,6 +79,7 @@ class JWTTest extends PHPUnit_Framework_TestCase
{
$payload = array(
"message" => "abc",
+ "iat" => time(),
"exp" => time() + 20, // time in the future
"nbf" => time() - 20);
$encoded = JWT::encode($payload, 'my_key');