@@ -394,4 +394,58 @@ public function testEncodeDecodeWithResource()
394
394
395
395
$ this ->assertEquals ('bar ' , $ decoded ->foo );
396
396
}
397
+
398
+ public function testEncodeExpectsIntegerIat ()
399
+ {
400
+ $ this ->expectException (UnexpectedValueException::class);
401
+ $ payload = [
402
+ 'iat ' => 'abc ' ,
403
+ ];
404
+ JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
405
+ }
406
+
407
+ public function testDecodeExpectsIntegerIat ()
408
+ {
409
+ $ this ->expectException (UnexpectedValueException::class);
410
+ JWT ::decode (
411
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3IiwibmFtZSI6IkpvaG4gU25vdyIsImlhdCI6InRlc3QifQ.B8cbURVQAPay3-Ep0DAm1Ji2rhij-hxfNA5PIDarf5o ' ,
412
+ new Key ('secret ' , 'HS256 ' )
413
+ );
414
+ }
415
+
416
+ public function testEncodeExpectsIntegerNbf ()
417
+ {
418
+ $ this ->expectException (UnexpectedValueException::class);
419
+ $ payload = [
420
+ 'nbf ' => 'abc ' ,
421
+ ];
422
+ JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
423
+ }
424
+
425
+ public function testDecodeExpectsIntegerNbf ()
426
+ {
427
+ $ this ->expectException (UnexpectedValueException::class);
428
+ JWT ::decode (
429
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3IiwibmFtZSI6IkpvaG4gU25vdyIsIm5iZiI6InRlc3QifQ.9KdFz3ktQoPO5QFG3E7J86PEuw5Vmx0VPrUKszP7DDs ' ,
430
+ new Key ('secret ' , 'HS256 ' )
431
+ );
432
+ }
433
+
434
+ public function testEncodeExpectsIntegerExp ()
435
+ {
436
+ $ this ->expectException (UnexpectedValueException::class);
437
+ $ payload = [
438
+ 'exp ' => 'abc ' ,
439
+ ];
440
+ JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
441
+ }
442
+
443
+ public function testDecodeExpectsIntegerExp ()
444
+ {
445
+ $ this ->expectException (UnexpectedValueException::class);
446
+ JWT ::decode (
447
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3IiwibmFtZSI6IkpvaG4gU25vdyIsImV4cCI6InRlc3QifQ.LXevvGvchI3PTBZo9jZ5-4d0OvONVU-_8Tbg_22-PTo ' ,
448
+ new Key ('secret ' , 'HS256 ' )
449
+ );
450
+ }
397
451
}
0 commit comments