@Test
  public void testDetectsNullBeingReturnedFromAuthenticationDao() {
    when(mockUserDetailService.login(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_ACCESS,
            TEST_VERIFY,
            null,
            null,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME))
        .thenReturn(null);

    VistaAuthenticationToken token =
        new VistaAuthenticationToken(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_ACCESS,
            TEST_VERIFY,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME);

    try {
      provider.authenticate(token);
      fail("Should have thrown AuthenticationServiceException");
    } catch (AuthenticationServiceException expected) {
      assertEquals(
          "VistaUserDetailsService returned null, which is an interface contract violation; it should either return an authenticated VistaUserDetails instance or throw an AuthenticationException",
          expected.getMessage());
    }
  }
 @Test
 public void testGuestIsDisabled() {
   try {
     MockWindowsIdentity mockIdentity = new MockWindowsIdentity("Guest", new ArrayList<String>());
     _provider.setAllowGuestLogin(false);
     WindowsPrincipal principal = new WindowsPrincipal(mockIdentity);
     UsernamePasswordAuthenticationToken authentication =
         new UsernamePasswordAuthenticationToken(principal, "password");
     _provider.authenticate(authentication);
     fail("expected AuthenticationServiceException");
   } catch (AuthenticationServiceException e) {
     assertTrue(e.getCause() instanceof GuestLoginDisabledAuthenticationException);
   }
 }