@@ -75,6 +75,16 @@ public function testValidToken()
75
75
$ this ->assertEquals ($ decoded ->message , 'abc ' );
76
76
}
77
77
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
+
78
88
public function testValidTokenWithNbf ()
79
89
{
80
90
$ payload = array (
@@ -116,4 +126,25 @@ public function testKIDChooser()
116
126
$ decoded = JWT ::decode ($ msg , $ keys , array ('HS256 ' ));
117
127
$ this ->assertEquals ($ decoded , 'abc ' );
118
128
}
129
+
130
+ public function testNoneAlgorithm ()
131
+ {
132
+ $ msg = JWT ::encode ('abc ' , 'my_key ' );
133
+ $ this ->setExpectedException ('DomainException ' );
134
+ JWT ::decode ($ msg , 'my_key ' , array ('none ' ));
135
+ }
136
+
137
+ public function testIncorrectAlgorithm ()
138
+ {
139
+ $ msg = JWT ::encode ('abc ' , 'my_key ' );
140
+ $ this ->setExpectedException ('DomainException ' );
141
+ JWT ::decode ($ msg , 'my_key ' , array ('RS256 ' ));
142
+ }
143
+
144
+ public function testMissingAlgorithm ()
145
+ {
146
+ $ msg = JWT ::encode ('abc ' , 'my_key ' );
147
+ $ this ->setExpectedException ('DomainException ' );
148
+ JWT ::decode ($ msg , 'my_key ' );
149
+ }
119
150
}
0 commit comments