### Question:
OAuth2Jwt { public boolean isValid(SigningHandler signingHandler) { if (isSignatureValid == null) { isSignatureValid = jwt.verify(signingHandler); } return isSignatureValid && isContentValid(); } @VisibleForTesting  OAuth2Jwt(SignedJwt jwt, TimeService timeService); static OAuth2Jwt create(String jwtString); boolean isValid(SigningHandler signingHandler); boolean isContentValid(); boolean isExpired(); boolean isIntendedForAudience(String audience); String getSubject(); SignedJwt getSignedJwt();  }### Answer:
@Test public void notBeforeTimeSetInPastJWTShouldBeValid() { JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap()); JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, VALID_EXPIRATION_TIME); SigningHandler handler = new NOPSigningHandler(); OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler); assertTrue(oAuth2Jwt.isValid(handler)); }
@Test public void notBeforeTimeSetInFutureJWTShouldBeInvalid() { JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap()); JwtClaimsSet claims = getJwtClaimsSet(INVALID_NOT_BEFORE_TIME, VALID_EXPIRATION_TIME); SigningHandler handler = new NOPSigningHandler(); OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler); assertTrue(!oAuth2Jwt.isValid(handler)); }
@Test public void notBeforeTimeSetAsNowShouldBeValid() { JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap()); JwtClaimsSet claims = getJwtClaimsSet(0, VALID_EXPIRATION_TIME); SigningHandler handler = new NOPSigningHandler(); OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler); assertTrue(oAuth2Jwt.isValid(handler)); }
@Test public void expirationTimeSetInPastJWTShouldBeInvalid() { JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap()); JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, INVALID_EXPIRATION_TIME); SigningHandler handler = new NOPSigningHandler(); OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler); assertTrue(!oAuth2Jwt.isValid(handler)); }
@Test public void expirationTimeSetInFutureJWTShouldBeValid() { JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap()); JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, VALID_EXPIRATION_TIME); SigningHandler handler = new NOPSigningHandler(); OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler); assertTrue(oAuth2Jwt.isValid(handler)); }
@Test public void expirationTimeSetAsNowJWTShouldBeValid() { JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap()); JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, 0); SigningHandler handler = new NOPSigningHandler(); OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler); assertTrue(oAuth2Jwt.isValid(handler)); }