diff options
author | Steve Jones <sjones608@me.com> | 2015-07-21 16:14:28 -0500 |
---|---|---|
committer | Steve Jones <sjones608@me.com> | 2015-07-21 16:14:28 -0500 |
commit | d0e9a7a48a685935ccb1156b70c2f4460dd1a053 (patch) | |
tree | f9374efb6588c10bf6bb2b169c64d05ea3e8c933 /tests/JWTTest.php | |
parent | 49f7de66cfb3ae4867a0c95665102b2b0386c4a0 (diff) | |
parent | 11855dbf52eedc82320d8ad7102cf32c18d2be7e (diff) | |
download | php-jwt-d0e9a7a48a685935ccb1156b70c2f4460dd1a053.zip php-jwt-d0e9a7a48a685935ccb1156b70c2f4460dd1a053.tar.gz php-jwt-d0e9a7a48a685935ccb1156b70c2f4460dd1a053.tar.bz2 |
Merge remote-tracking branch 'upstream/master' into nullkey
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r-- | tests/JWTTest.php | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php index ab1ae36..89de8d2 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,4 +1,5 @@ <?php +use \Firebase\JWT\JWT; class JWTTest extends PHPUnit_Framework_TestCase { @@ -37,7 +38,7 @@ class JWTTest extends PHPUnit_Framework_TestCase public function testExpiredToken() { - $this->setExpectedException('ExpiredException'); + $this->setExpectedException('Firebase\JWT\ExpiredException'); $payload = array( "message" => "abc", "exp" => time() - 20); // time in the past @@ -47,7 +48,7 @@ class JWTTest extends PHPUnit_Framework_TestCase public function testBeforeValidTokenWithNbf() { - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $payload = array( "message" => "abc", "nbf" => time() + 20); // time in the future @@ -57,7 +58,7 @@ class JWTTest extends PHPUnit_Framework_TestCase public function testBeforeValidTokenWithIat() { - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $payload = array( "message" => "abc", "iat" => time() + 20); // time in the future @@ -93,7 +94,7 @@ class JWTTest extends PHPUnit_Framework_TestCase $payload = array( "message" => "abc", "exp" => time() - 70); // time far in the past - $this->setExpectedException('ExpiredException'); + $this->setExpectedException('Firebase\JWT\ExpiredException'); $encoded = JWT::encode($payload, 'my_key'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); $this->assertEquals($decoded->message, 'abc'); @@ -141,7 +142,7 @@ class JWTTest extends PHPUnit_Framework_TestCase "message" => "abc", "nbf" => time() + 65); // not before too far in future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); JWT::$leeway = 0; } @@ -165,7 +166,7 @@ class JWTTest extends PHPUnit_Framework_TestCase "message" => "abc", "iat" => time() + 65); // issued too far in future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); JWT::$leeway = 0; } @@ -176,7 +177,7 @@ class JWTTest extends PHPUnit_Framework_TestCase "message" => "abc", "exp" => time() + 20); // time in the future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('SignatureInvalidException'); + $this->setExpectedException('Firebase\JWT\SignatureInvalidException'); $decoded = JWT::decode($encoded, 'my_key2', array('HS256')); } @@ -254,4 +255,10 @@ class JWTTest extends PHPUnit_Framework_TestCase $msg = JWT::encode('abc', 'my_key', 'HS256', null, array('cty' => 'test-eit;v=1')); $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), 'abc'); } + + public function testInvalidSegmentCount() + { + $this->setExpectedException('UnexpectedValueException'); + JWT::decode('brokenheader.brokenbody', 'my_key', array('HS256')); + } } |