public void testGetLastExceptionOnValidateUser() throws Exception
{
assertNotNull(orgService);
UserHandler uh = orgService.getUserHandler();
User user = uh.createUserInstance("testGetLastExceptionOnValidateUser");
user.setPassword("foo");
assertNotNull(authenticator);
assertTrue(authenticator instanceof OrganizationAuthenticatorImpl);
Credential[] cred = new Credential[]{new UsernameCredential("testGetLastExceptionOnValidateUser"), new PasswordCredential("foo")};
String userId = authenticator.validateUser(cred);
assertEquals("testGetLastExceptionOnValidateUser", userId);
assertNull(authenticator.getLastExceptionOnValidateUser());
assertNull(authenticator.getLastExceptionOnValidateUser());
uh.setEnabled("testGetLastExceptionOnValidateUser", false, false);
try
{
authenticator.validateUser(cred);
fail("a LoginException was expected");
}
catch (LoginException e)
{
// expected
}
assertTrue(authenticator.getLastExceptionOnValidateUser() instanceof DisabledUserException);
assertNull(authenticator.getLastExceptionOnValidateUser());
uh.setEnabled("testGetLastExceptionOnValidateUser", true, false);
userId = authenticator.validateUser(cred);
assertEquals("testGetLastExceptionOnValidateUser", userId);
assertNull(authenticator.getLastExceptionOnValidateUser());
assertNull(authenticator.getLastExceptionOnValidateUser());
}