We should also log when there is an authentication issue. Let's add a Logger to our Handler class:
private static final Logger LOGGER =
Logger.getLogger(Handler.class);
Then, let's modify the block where we catch the exception:
... } catch (UserNotFoundException userNotFoundException) { policyEffect = PolicyStatement.Effect.DENY; LOGGER.info("User authentication failed for token " + authenticationToken); } ....
Maybe at this point, we can create another test to check whether our Handler class is returning the denial policy. We need mocking for that because we will create a mock AuthenticationInput object, and easymock and powermock are good libraries for that. Let's add it to our main build.gradle file to test dependencies:
allprojects { dependencies { ... testCompile group: 'org.easymock...