diff options
author | John LeSueur <jlesueur@bamboohr.com> | 2014-06-23 15:06:27 +0000 |
---|---|---|
committer | John LeSueur <jlesueur@bamboohr.com> | 2014-06-23 15:06:27 +0000 |
commit | b5829858aed4a1f73c3029ecaf3e34471a083e6e (patch) | |
tree | 363afd247dfd959b3c32e02cd4dfbddb47b666b3 /tests/JWTTest.php | |
parent | 144e201a30f96119eafe1c597b0736612b86317c (diff) | |
download | php-jwt-b5829858aed4a1f73c3029ecaf3e34471a083e6e.zip php-jwt-b5829858aed4a1f73c3029ecaf3e34471a083e6e.tar.gz php-jwt-b5829858aed4a1f73c3029ecaf3e34471a083e6e.tar.bz2 |
1. Allow encode to take a "kid" parameter
2. Allow decode to take an array of keys, and use the "kid" to look up the key.
3. Add RS256 as an algorithm
4. Add tests for the above
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r-- | tests/JWTTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php index ae65f02..5aa5dc7 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -46,6 +46,25 @@ class JWTTest extends PHPUnit_Framework_TestCase { $decoded = JWT::decode($encoded, 'my_key'); $this->assertEquals($decoded->message, 'abc'); } + + function testRSEncodeDecode() { + $privKey = openssl_pkey_new(array('digest_alg' => 'sha256', + 'private_key_bits' => 1024, + 'private_key_type' => OPENSSL_KEYTYPE_RSA)); + $msg = JWT::encode('abc',$privKey, 'RS256'); + $pubKey = openssl_pkey_get_details($privKey); + $pubKey = $pubKey['key']; + $decoded = JWT::decode($msg, $pubKey, true); + $this->assertEquals($decoded, 'abc'); + } + + function testKIDChooser() { + $keys = array('1' => 'my_key', '2' => 'my_key2'); + $msg = JWT::encode('abc', $keys['1'], 'HS256', '1'); + $decoded = JWT::decode($msg, $keys, true); + $this->assertEquals($decoded, 'abc'); + } + } |