### Question:
SiteMinderServletRequestAuthenticator implements ServletRequestAuthenticator { @Override public String authenticateRequest(final HttpServletRequest request) { final String smUser = request.getHeader(SITE_MINDER_HEADER.getValue()); if (smUser == null || smUser.trim().isEmpty()) { return null; } else { return smUser; } }  static boolean isEnabled(); @Override String authenticateRequest(final HttpServletRequest request); static final SystemProperty<String> SITE_MINDER_HEADER; }### Answer:
@Test public void willAuthenticateAUser() { final String userId = "a-test-user"; doReturn(userId).when(request).getHeader("SM_USER"); final String authenticatedUser = authenticator.authenticateRequest(request); assertThat(authenticatedUser, is(userId)); }
@Test public void willNotAuthenticateAMissingUser() { doReturn(null).when(request).getHeader("SM_USER"); final String authenticatedUser = authenticator.authenticateRequest(request); assertThat(authenticatedUser, is(nullValue())); }
@Test public void willNotAuthenticateABlankUser() { doReturn("").when(request).getHeader("SM_USER"); final String authenticatedUser = authenticator.authenticateRequest(request); assertThat(authenticatedUser, is(nullValue())); }
@Test public void willAuthenticateAUserWithDifferentHeader() { final String userId = "a-test-user"; final String header = "a-custom-header"; SiteMinderServletRequestAuthenticator.SITE_MINDER_HEADER.setValue(header); doReturn(userId).when(request).getHeader(header); final String authenticatedUser = authenticator.authenticateRequest(request); assertThat(authenticatedUser, is(userId)); }