@Test
public void validate_notExpired_success() throws Exception {

  String algo = "HS256";
  Clock clock = Clock.systemUTC();
  // This token expires in 1 minute in the future.
  Instant expiration = clock.instant().plus(Duration.ofMinutes(1));
  ToBeSignedJwt unverified =
      new ToBeSignedJwt.Builder().setAlgorithm(algo).setExpiration(expiration).build();
  JwtValidator validator = new JwtValidator.Builder().build();
  Jwt token = validator.validate(algo, unverified);

  assertThat(token.getExpiration().getEpochSecond()).isEqualTo(expiration.getEpochSecond());
}