Skip to content

Commit

Permalink
Add issued time to JWT claims in test cases
Browse files Browse the repository at this point in the history
This ensures that the JWT claims set contains an issued time, which is necessary for some verifications. The additional issued time makes the test cases more comprehensive and accurate.
  • Loading branch information
mme-flendly committed Sep 27, 2024
1 parent b66d7e7 commit 2d7f244
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void verify() {
@Test
public void testVerify_throwsBadJWTException_whenJWTIsExpired() {
Date exp = new Date(System.currentTimeMillis() - 60000);
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder().expirationTime(exp).build();
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder().expirationTime(exp).issueTime(new Date()).build();
when(clock.instant()).thenReturn(Instant.now());
assertThrows(BadJWTException.class, () -> {
underTest.verify(claimsSet, null);
Expand All @@ -47,7 +47,7 @@ public void testVerify_throwsBadJWTException_whenJWTIsExpired() {
@Test
public void testVerify_throwsBadJWTException_whenJWTIsNotBeforeNow() {
Date nbf = new Date(System.currentTimeMillis() + 61000);
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder().notBeforeTime(nbf).build();
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder().notBeforeTime(nbf).issueTime(new Date()).build();
when(clock.instant()).thenReturn(Instant.now());
assertThrows(BadJWTException.class, () -> {
underTest.verify(claimsSet, null);
Expand Down

0 comments on commit 2d7f244

Please sign in to comment.