diff options
author | Steve Jones <sjones608@me.com> | 2015-07-08 12:50:06 -0500 |
---|---|---|
committer | Steve Jones <sjones608@me.com> | 2015-07-08 12:50:06 -0500 |
commit | 49f7de66cfb3ae4867a0c95665102b2b0386c4a0 (patch) | |
tree | 99613d2269cac3e38716deef0f0bdc609f8f9f40 /tests/JWTTest.php | |
parent | 21498f7b9e433b37b3a8d18388ccc77ed6853703 (diff) | |
download | php-jwt-49f7de66cfb3ae4867a0c95665102b2b0386c4a0.zip php-jwt-49f7de66cfb3ae4867a0c95665102b2b0386c4a0.tar.gz php-jwt-49f7de66cfb3ae4867a0c95665102b2b0386c4a0.tar.bz2 |
require a non-empty key to decode a JWT
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r-- | tests/JWTTest.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 2aeb201..ab1ae36 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -180,6 +180,26 @@ class JWTTest extends PHPUnit_Framework_TestCase $decoded = JWT::decode($encoded, 'my_key2', array('HS256')); } + public function testNullKeyFails() + { + $payload = array( + "message" => "abc", + "exp" => time() + JWT::$leeway + 20); // time in the future + $encoded = JWT::encode($payload, 'my_key'); + $this->setExpectedException('InvalidArgumentException'); + $decoded = JWT::decode($encoded, null, array('HS256')); + } + + public function testEmptyKeyFails() + { + $payload = array( + "message" => "abc", + "exp" => time() + JWT::$leeway + 20); // time in the future + $encoded = JWT::encode($payload, 'my_key'); + $this->setExpectedException('InvalidArgumentException'); + $decoded = JWT::decode($encoded, '', array('HS256')); + } + public function testRSEncodeDecode() { $privKey = openssl_pkey_new(array('digest_alg' => 'sha256', |