@@ -203,6 +203,7 @@ public function testBuildRefreshClaimsMethodWillRefreshTheIAT()
203203 $ buildRefreshClaimsMethod = $ managerClass ->getMethod ('buildRefreshClaims ' );
204204 $ buildRefreshClaimsMethod ->setAccessible (true );
205205 $ managerInstance = new Manager ($ this ->jwt , $ this ->blacklist , $ this ->factory );
206+ $ managerInstance ->setRefreshIat (true );
206207
207208 $ firstResult = $ buildRefreshClaimsMethod ->invokeArgs ($ managerInstance , [$ payload ]);
208209 Carbon::setTestNow (Carbon::now ()->addMinutes (2 ));
@@ -220,6 +221,42 @@ public function testBuildRefreshClaimsMethodWillRefreshTheIAT()
220221 $ this ->assertNotEquals ($ firstResult ['iat ' ], $ secondResult ['iat ' ]);
221222 }
222223
224+ public function testBuildRefreshClaimsMethodWillNotRefreshTheIAT ()
225+ {
226+ $ claims = [
227+ new Subject (1 ),
228+ new Issuer ('http://example.com ' ),
229+ new Expiration ($ this ->testNowTimestamp - 3600 ),
230+ new NotBefore ($ this ->testNowTimestamp ),
231+ new IssuedAt ($ this ->testNowTimestamp ),
232+ new JwtId ('foo ' ),
233+ ];
234+ $ collection = Collection::make ($ claims );
235+
236+ $ this ->validator ->shouldReceive ('setRefreshFlow->check ' )->andReturn ($ collection );
237+ $ payload = new Payload ($ collection , $ this ->validator );
238+
239+ $ managerClass = new \ReflectionClass (Manager::class);
240+ $ buildRefreshClaimsMethod = $ managerClass ->getMethod ('buildRefreshClaims ' );
241+ $ buildRefreshClaimsMethod ->setAccessible (true );
242+ $ managerInstance = new Manager ($ this ->jwt , $ this ->blacklist , $ this ->factory );
243+
244+ $ firstResult = $ buildRefreshClaimsMethod ->invokeArgs ($ managerInstance , [$ payload ]);
245+ Carbon::setTestNow (Carbon::now ()->addMinutes (2 ));
246+ $ secondResult = $ buildRefreshClaimsMethod ->invokeArgs ($ managerInstance , [$ payload ]);
247+
248+ $ this ->assertIsInt ($ firstResult ['iat ' ]);
249+ $ this ->assertIsInt ($ secondResult ['iat ' ]);
250+
251+ $ carbonTimestamp = Carbon::createFromTimestamp ($ firstResult ['iat ' ]);
252+ $ this ->assertInstanceOf (Carbon::class, $ carbonTimestamp );
253+
254+ $ carbonTimestamp = Carbon::createFromTimestamp ($ secondResult ['iat ' ]);
255+ $ this ->assertInstanceOf (Carbon::class, $ carbonTimestamp );
256+
257+ $ this ->assertEquals ($ firstResult ['iat ' ], $ secondResult ['iat ' ]);
258+ }
259+
223260 /**
224261 * @throws InvalidClaimException
225262 */
0 commit comments