use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class LdapCustomAuthenticationProviderTest method shouldMergeDbUserWithLdapCredentialsTest.
@Test
public void shouldMergeDbUserWithLdapCredentialsTest() {
Attribute pwdGraceUseTime = new BasicAttribute("pwdGraceUseTime");
pwdGraceUseTime.add(new Date());
Attributes attributes = new BasicAttributes();
attributes.put(pwdGraceUseTime);
when(ldapUserDetails.getAttributes()).thenReturn(attributes);
User user = getUserForTest();
final Principal principal = new Principal(user, new GrantedAuthority[] {});
final String ldapPassword = "ldapPassword";
final Principal ldapPrincipal = sut.mergeUsers(ldapUserDetails, principal, ldapPassword);
assertThat(ldapPrincipal.getPassword(), is(ldapPassword));
assertThat(ldapPrincipal.getUser().getLdapPassword(), is(ldapPassword));
assertThat(ldapPrincipal.getUser().getPassword(), is(nullValue()));
assertThat(ldapPrincipal.getUser().isActive(), is(true));
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class SpringUtilsForTesting method createUserInContextWithRoleAndDepartment.
public static User createUserInContextWithRoleAndDepartment() {
setUserForTestingInContext();
final User user = new User();
user.setLogin("admin");
user.setRole(createRoleInContext());
user.setDepartment(createDepartmentInContext());
user.setCategory(createUserCategoryInContext());
user.setAgreement(createAgreementInContext());
final UserDAO userDao = (UserDAO) appCtx.getBean("daoUser");
userDao.insert(user);
user.setActive(true);
return user;
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class AuthenticationManagerLdapImplTest method resetPassword.
@Test
public void resetPassword() throws Exception {
User userAdmin = getUserAdmin();
Principal principal = mock(Principal.class);
when(principal.getUser()).thenReturn(userAdmin);
when(authenticationManager.getCurrentPrincipal()).thenReturn(principal);
final String randomPassword = sut.generateRandomPassword(RANDOM, RANDOM, RANDOM, RANDOM, RANDOM);
doNothing().when(authManagerLdapTemplate).modifyAttributes(any(DirContext.class), eq(user), any(ModificationItem[].class));
sut.resetPassword(user, RANDOM, RANDOM, RANDOM, RANDOM, RANDOM);
verify(authManagerLdapTemplate).changePassword(user, randomPassword, userAdmin);
verify(authManagerLdapTemplate, times(2)).getTemplate(userAdmin);
verify(authManagerLdapTemplate).getCallback(user, randomPassword);
verify(authManagerLdapTemplate).getCallback(user);
verify(authManagerLdapTemplate).changeLdapUserPassword(any(DirContext.class), eq(randomPassword), eq(user));
verify(authManagerLdapTemplate).setLdapUserPasswordResetFlag(any(DirContext.class), eq(user));
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class AuthenticationManagerLdapImplTest method getUser.
private User getUser() {
User user = new User();
user.setLdapPassword(PASSWORD);
user.setPasswordExpired(Boolean.TRUE);
user.setDn("dc=autentia,dc=com");
user.setLdapName("uid=user");
user.setLogin("user");
return user;
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class AuthenticationManagerLdapImplTest method changeAsAdminPassword.
@Test
public void changeAsAdminPassword() throws Exception {
User userAdmin = getUserAdmin();
doNothing().when(authManagerLdapTemplate).modifyAttributes(any(DirContext.class), eq(user), any(ModificationItem[].class));
sut.changePassword(user, NEW_PASSWORD, userAdmin);
verify(authManagerLdapTemplate).changePassword(user, NEW_PASSWORD, userAdmin);
verify(authManagerLdapTemplate).getTemplate(userAdmin);
verify(authManagerLdapTemplate).getCallback(user, NEW_PASSWORD);
verify(authManagerLdapTemplate).changeLdapUserPassword(any(DirContext.class), eq(NEW_PASSWORD), eq(user));
}
Aggregations