@Test void givenExpiredToken_whenCreateCommand_thenThrowJwtTokenException() { when(authenticationService.getJwtTokenFromRequest(request)).thenReturn(Optional.of("jwtToken3")); when(authenticationService.getLtpaTokenWithValidation("jwtToken3")).thenThrow(new JwtException("Token is expired")); when(authenticationService.parseJwtToken("jwtToken3")).thenReturn(queryResponse); Exception exception = assertThrows(JwtException.class, () -> zosmfScheme.createCommand(authentication, () -> queryResponse).apply(null), " Token is expired"); assertEquals("Token is expired", exception.getMessage()); }
@Override public AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier) { final QueryResponse queryResponse = tokenSupplier.get(); final Date expiration = queryResponse == null ? null : queryResponse.getExpiration(); final Long expirationTime = expiration == null ? null : expiration.getTime(); return new ZosmfCommand(expirationTime); }
ZosmfScheme implements AbstractAuthenticationScheme { @Override public AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier) { final QueryResponse queryResponse = tokenSupplier.get(); final Date expiration = queryResponse == null ? null : queryResponse.getExpiration(); final Long expirationTime = expiration == null ? null : expiration.getTime(); return new ZosmfCommand(expirationTime); } }
ZosmfScheme implements AbstractAuthenticationScheme { @Override public AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier) { final QueryResponse queryResponse = tokenSupplier.get(); final Date expiration = queryResponse == null ? null : queryResponse.getExpiration(); final Long expirationTime = expiration == null ? null : expiration.getTime(); return new ZosmfCommand(expirationTime); }  }
ZosmfScheme implements AbstractAuthenticationScheme { @Override public AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier) { final QueryResponse queryResponse = tokenSupplier.get(); final Date expiration = queryResponse == null ? null : queryResponse.getExpiration(); final Long expirationTime = expiration == null ? null : expiration.getTime(); return new ZosmfCommand(expirationTime); }  @Override AuthenticationScheme getScheme(); @Override AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier); }
ZosmfScheme implements AbstractAuthenticationScheme { @Override public AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier) { final QueryResponse queryResponse = tokenSupplier.get(); final Date expiration = queryResponse == null ? null : queryResponse.getExpiration(); final Long expirationTime = expiration == null ? null : expiration.getTime(); return new ZosmfCommand(expirationTime); }  @Override AuthenticationScheme getScheme(); @Override AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier);  }