How can I manipulate the internal time for JWT token to make it seem like 15 minutes have passed?

Viewed 113

I already implemented a feature for my node js application where user can change their email address from user dashboard. For changing email address, when a user submits a new email address, it sends a verification email to his old email address with a verification link. The verification link contains a JWT token which is valid for 15 minutes. If the user clicks the verification link within 15 minutes then it changes to the new email address, otherwise it fails.

Currently I am writing an integration test for this feature. The problem is now testing the JWT token from my integration test. In integration test, my test code should check where it fails due to the user taking more than 15m to press the link. When I created the JWT token I used following code:

jwt.sign(payload, secret, { expiresIn: "15m" });

Can anyone tell me how can I solve this issue? How can I manipulate the internal time for JWT token to make it seem like 15 minutes have passed?

0 Answers
Related