use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testTwoPoliciesSecondValidTillNull.
@Test
public void testTwoPoliciesSecondValidTillNull() {
IdmPasswordPolicyDto policy1 = getTestPolicy(false, IdmPasswordPolicyType.VALIDATE, null);
IdmPasswordPolicyDto policy2 = getTestPolicy(true, IdmPasswordPolicyType.VALIDATE, 5);
IdmIdentityDto identity = getHelper().createIdentity();
//
IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
Assert.assertNull(password.getValidFrom());
assertEquals(identity.getId(), password.getIdentity());
assertEquals(LocalDate.now().plusDays(policy2.getMaxPasswordAge()), password.getValidTill());
//
policy1.setDefaultPolicy(true);
policy1 = policyService.save(policy1);
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
passwordChangeDto.setAll(true);
passwordChangeDto.setIdm(true);
passwordChangeDto.setOldPassword(identity.getPassword());
passwordChangeDto.setNewPassword(new GuardedString("testPassword"));
//
try {
getHelper().login(identity);
identityService.passwordChange(identity, passwordChangeDto);
password = passwordService.findOneByIdentity(identity.getId());
Assert.assertNotNull(password.getValidFrom());
Assert.assertNull(password.getValidTill());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testCreatePasswordValidationPolicy.
@Test
public void testCreatePasswordValidationPolicy() {
getTestPolicy(false, IdmPasswordPolicyType.VALIDATE, 365);
IdmIdentityDto identity = getHelper().createIdentity();
//
IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
Assert.assertNull(password.getValidFrom());
Assert.assertEquals(identity.getId(), password.getIdentity());
Assert.assertNull(password.getValidTill());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testCreatePasswordNoPolicy.
@Test
public void testCreatePasswordNoPolicy() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
Assert.assertNull(password.getValidFrom());
assertEquals(identity.getId(), password.getIdentity());
assertNull(password.getValidTill());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method checkCorrectBehaviorTrue.
@Test
public void checkCorrectBehaviorTrue() {
String password = "password" + System.currentTimeMillis();
GuardedString passwordForCheck = new GuardedString(password);
IdmPasswordDto newPassword = new IdmPasswordDto();
newPassword.setPassword(generateHash(password));
assertTrue(passwordService.checkPassword(passwordForCheck, newPassword));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method checkCorrectBehaviorFalse.
@Test
public void checkCorrectBehaviorFalse() {
String password = "password" + System.currentTimeMillis();
GuardedString passwordForCheck = new GuardedString(password + "2");
IdmPasswordDto newPassword = new IdmPasswordDto();
newPassword.setPassword(generateHash(password));
assertFalse(passwordService.checkPassword(passwordForCheck, newPassword));
}
Aggregations