@@ -546,4 +546,31 @@ public function testAdditionalHeaderOverrides()
546546 $ this ->assertEquals ('my_key_id ' , $ headers ->kid , 'key param not overridden ' );
547547 $ this ->assertEquals ('HS256 ' , $ headers ->alg , 'alg param not overridden ' );
548548 }
549+
550+ public function testDecodeExpectsIntegerIat ()
551+ {
552+ $ this ->expectException (UnexpectedValueException::class);
553+ $ this ->expectExceptionMessage ('Payload iat must be a number ' );
554+
555+ $ payload = JWT ::encode (['iat ' => 'not-an-int ' ], 'secret ' , 'HS256 ' );
556+ JWT ::decode ($ payload , new Key ('secret ' , 'HS256 ' ));
557+ }
558+
559+ public function testDecodeExpectsIntegerNbf ()
560+ {
561+ $ this ->expectException (UnexpectedValueException::class);
562+ $ this ->expectExceptionMessage ('Payload nbf must be a number ' );
563+
564+ $ payload = JWT ::encode (['nbf ' => 'not-an-int ' ], 'secret ' , 'HS256 ' );
565+ JWT ::decode ($ payload , new Key ('secret ' , 'HS256 ' ));
566+ }
567+
568+ public function testDecodeExpectsIntegerExp ()
569+ {
570+ $ this ->expectException (UnexpectedValueException::class);
571+ $ this ->expectExceptionMessage ('Payload exp must be a number ' );
572+
573+ $ payload = JWT ::encode (['exp ' => 'not-an-int ' ], 'secret ' , 'HS256 ' );
574+ JWT ::decode ($ payload , new Key ('secret ' , 'HS256 ' ));
575+ }
549576}
0 commit comments