Skip to content

Commit 52ccddd

Browse files
committed
add tests for null expected claim handling
1 parent cca830c commit 52ccddd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/src/test/java/com/auth0/jwt/JWTVerifierTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,17 @@ public void shouldValidateCustomClaimOfTypeDate() {
526526
assertThat(jwt, is(notNullValue()));
527527
}
528528

529+
@Test
530+
public void shouldRemoveCustomClaimOfTypeDateWhenNull() {
531+
JWTVerifier verifier = JWTVerifier.init(Algorithm.HMAC256("secret"))
532+
.withClaim("name", new Date())
533+
.withClaim("name", (Date) null)
534+
.build();
535+
536+
assertThat(verifier.claims, is(notNullValue()));
537+
assertThat(verifier.claims, not(hasKey("iss")));
538+
}
539+
529540
@Test
530541
public void shouldValidateCustomArrayClaimOfTypeString() {
531542
String token = "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjpbInRleHQiLCIxMjMiLCJ0cnVlIl19.lxM8EcmK1uSZRAPd0HUhXGZJdauRmZmLjoeqz4J9yAA";

0 commit comments

Comments
 (0)