Skip to content

Commit 4e15ea5

Browse files
committed
Add a few add'l tests
1 parent 9f71bef commit 4e15ea5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/JWTTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public function testValidToken()
7575
$this->assertEquals($decoded->message, 'abc');
7676
}
7777

78+
public function testValidTokenWithList()
79+
{
80+
$payload = array(
81+
"message" => "abc",
82+
"exp" => time() + 20); // time in the future
83+
$encoded = JWT::encode($payload, 'my_key');
84+
$decoded = JWT::decode($encoded, 'my_key', array('HS256', 'HS512'));
85+
$this->assertEquals($decoded->message, 'abc');
86+
}
87+
7888
public function testValidTokenWithNbf()
7989
{
8090
$payload = array(
@@ -117,7 +127,7 @@ public function testKIDChooser()
117127
$this->assertEquals($decoded, 'abc');
118128
}
119129

120-
public function testNoneToken()
130+
public function testNoneAlgorithm()
121131
{
122132
$msg = JWT::encode('abc', 'my_key');
123133
$this->setExpectedException('DomainException');
@@ -130,4 +140,11 @@ public function testIncorrectAlgorithm()
130140
$this->setExpectedException('DomainException');
131141
JWT::decode($msg, 'my_key', array('RS256'));
132142
}
143+
144+
public function testMissingAlgorithm()
145+
{
146+
$msg = JWT::encode('abc', 'my_key');
147+
$this->setExpectedException('DomainException');
148+
JWT::decode($msg, 'my_key');
149+
}
133150
}

0 commit comments

Comments
 (0)