Skip to content

Commit 91b2166

Browse files
FerencKemenyjzheaux
authored andcommitted
Polish JwtTimestampValidatorTests
This commit corrects the test that checks for both nbf and exp missing. It also adds one for just exp and on for just nbf. Issue gh-17004 Signed-off-by: Ferenc Kemeny <ferenc.kemeny79+oss@gmail.com>
1 parent 596449d commit 91b2166

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtTimestampValidatorTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,23 @@ public void validateWhenConfiguredWithFixedClockThenValidatesUsingFixedTime() {
129129

130130
@Test
131131
public void validateWhenNeitherExpiryNorNotBeforeIsSpecifiedThenReturnsSuccessfulResult() {
132+
Jwt jwt = TestJwts.jwt().claims((c) -> {
133+
c.remove(JwtClaimNames.EXP);
134+
c.remove(JwtClaimNames.NBF);
135+
}).build();
136+
JwtTimestampValidator jwtValidator = new JwtTimestampValidator();
137+
assertThat(jwtValidator.validate(jwt).hasErrors()).isFalse();
138+
}
139+
140+
@Test
141+
public void validateWhenExpiryIsSpecifiedThenReturnsSuccessfulResult() {
142+
Jwt jwt = TestJwts.jwt().claims((c) -> c.remove(JwtClaimNames.EXP)).build();
143+
JwtTimestampValidator jwtValidator = new JwtTimestampValidator();
144+
assertThat(jwtValidator.validate(jwt).hasErrors()).isFalse();
145+
}
146+
147+
@Test
148+
public void validateWhenNotBeforeIsSpecifiedThenReturnsSuccessfulResult() {
132149
Jwt jwt = TestJwts.jwt().claims((c) -> c.remove(JwtClaimNames.EXP)).build();
133150
JwtTimestampValidator jwtValidator = new JwtTimestampValidator();
134151
assertThat(jwtValidator.validate(jwt).hasErrors()).isFalse();

0 commit comments

Comments
 (0)