summaryrefslogtreecommitdiffstats
path: root/tests/JWTTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r--tests/JWTTest.php20
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',