### Question:
AmbariJwtAuthenticationFilter implements AmbariAuthenticationFilter { boolean validateExpiration(SignedJWT jwtToken) { boolean valid = false; try { Date expires = jwtToken.getJWTClaimsSet().getExpirationTime(); if (expires == null || new Date().before(expires)) { LOG.debug("JWT token expiration date has been successfully validated"); valid = true; } else { LOG.warn("JWT expiration date validation failed."); } } catch (ParseException pe) { LOG.warn("JWT expiration date validation failed.", pe); } return valid; } AmbariJwtAuthenticationFilter(AuthenticationEntryPoint ambariEntryPoint,
                                JwtAuthenticationPropertiesProvider propertiesProvider,
                                AmbariJwtAuthenticationProvider authenticationProvider,
                                AmbariAuthenticationEventHandler eventHandler); @Override boolean shouldApply(HttpServletRequest httpServletRequest); @Override boolean shouldIncrementFailureCount(); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain); @Override void destroy();  }### Answer:
@Test public void testValidateExpiration() throws Exception { JwtAuthenticationPropertiesProvider jwtAuthenticationPropertiesProvider = createMock(JwtAuthenticationPropertiesProvider.class); expect(jwtAuthenticationPropertiesProvider.get()).andReturn(createTestProperties()).anyTimes(); AmbariAuthenticationEventHandler eventHandler = createNiceMock(AmbariAuthenticationEventHandler.class); replayAll(); AmbariJwtAuthenticationFilter filter = new AmbariJwtAuthenticationFilter(null, jwtAuthenticationPropertiesProvider, null, eventHandler); assertTrue(filter.validateExpiration(getSignedToken())); assertFalse(filter.validateExpiration(getInvalidToken())); verifyAll(); }
@Test public void testValidateNoExpiration() throws Exception { JwtAuthenticationPropertiesProvider jwtAuthenticationPropertiesProvider = createMock(JwtAuthenticationPropertiesProvider.class); expect(jwtAuthenticationPropertiesProvider.get()).andReturn(createTestProperties()).anyTimes(); AmbariAuthenticationEventHandler eventHandler = createNiceMock(AmbariAuthenticationEventHandler.class); replayAll(); AmbariJwtAuthenticationFilter filter = new AmbariJwtAuthenticationFilter(null, jwtAuthenticationPropertiesProvider, null, eventHandler); assertTrue(filter.validateExpiration(getSignedToken(null, "test-audience"))); assertFalse(filter.validateExpiration(getInvalidToken())); verifyAll(); }