mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-30 16:52:13 +00:00
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>
This commit is contained in:
parent
596449d882
commit
91b21663db
@ -129,6 +129,23 @@ public class JwtTimestampValidatorTests {
|
||||
|
||||
@Test
|
||||
public void validateWhenNeitherExpiryNorNotBeforeIsSpecifiedThenReturnsSuccessfulResult() {
|
||||
Jwt jwt = TestJwts.jwt().claims((c) -> {
|
||||
c.remove(JwtClaimNames.EXP);
|
||||
c.remove(JwtClaimNames.NBF);
|
||||
}).build();
|
||||
JwtTimestampValidator jwtValidator = new JwtTimestampValidator();
|
||||
assertThat(jwtValidator.validate(jwt).hasErrors()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateWhenExpiryIsSpecifiedThenReturnsSuccessfulResult() {
|
||||
Jwt jwt = TestJwts.jwt().claims((c) -> c.remove(JwtClaimNames.EXP)).build();
|
||||
JwtTimestampValidator jwtValidator = new JwtTimestampValidator();
|
||||
assertThat(jwtValidator.validate(jwt).hasErrors()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateWhenNotBeforeIsSpecifiedThenReturnsSuccessfulResult() {
|
||||
Jwt jwt = TestJwts.jwt().claims((c) -> c.remove(JwtClaimNames.EXP)).build();
|
||||
JwtTimestampValidator jwtValidator = new JwtTimestampValidator();
|
||||
assertThat(jwtValidator.validate(jwt).hasErrors()).isFalse();
|
||||
|
Loading…
x
Reference in New Issue
Block a user