use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyServiceIntegrationTest method testValidateMinPasswordAgeFailedEnforce.
@Test(expected = PasswordChangeException.class)
public void testValidateMinPasswordAgeFailedEnforce() {
IdmIdentityDto manager = getHelper().createIdentity();
IdmIdentityDto identity = getHelper().createIdentity();
IdmPasswordDto password = getHelper().getPassword(identity);
password.setValidFrom(LocalDate.now());
password = passwordService.save(password);
//
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setType(IdmPasswordPolicyType.VALIDATE);
policy.setMinPasswordAge(1);
//
IdmPasswordValidationDto validation = new IdmPasswordValidationDto();
validation.setIdentity(identity);
validation.setPassword(getHelper().createName());
validation.setEnforceMinPasswordAgeValidation(true);
//
try {
getHelper().login(manager);
//
passwordPolicyService.validate(validation, Lists.newArrayList(policy));
} finally {
getHelper().logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultPasswordFilterManagerIntegrationTest method testValidateWithMinPasswordAgeGreenLine.
@Test
public void testValidateWithMinPasswordAgeGreenLine() {
SysSystemDto system = createSystem(false);
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName(getHelper().createName());
policy.setType(IdmPasswordPolicyType.VALIDATE);
policy.setMinPasswordAge(1);
policy = passwordPolicyService.save(policy);
system.setPasswordPolicyValidate(policy.getId());
system = systemService.save(system);
IdmIdentityDto identity = createIdentity(system);
setPasswordFilter(system, true);
assignSystem(createUniformDefinition(true), system);
cleanProvivisioning(identity, system);
checkChangeInIdm(identity, 0);
String password = getHelper().createName();
PasswordRequest request = prepareRequest(identity.getUsername(), system.getCode(), password);
IdmPasswordDto idmPassword = passwordService.findOneByIdentity(identity.getId());
Assert.assertNull(idmPassword);
checkEmptyProvisioning(identity, system);
checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
checkChangeInIdm(identity, 0);
processValidate(request, true);
checkEcho(identity, system, EchoCheck.VALIDATE);
checkChangeInIdm(identity, 0);
checkEmptyProvisioning(identity, system);
processChange(request, true);
checkEcho(identity, system, EchoCheck.VALIDATE_AND_CHANGE);
checkChangeInIdm(identity, 1);
checkEmptyProvisioning(identity, system);
idmPassword = passwordService.findOneByIdentity(identity.getId());
Assert.assertNotNull(idmPassword);
// under different user, but set
Assert.assertNotNull(idmPassword.getValidFrom());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultPasswordFilterManagerIntegrationTest method testCheckPasswordValidity10Days.
@Test
public void testCheckPasswordValidity10Days() {
IdmPasswordPolicyDto passwordPolicy = createPasswordPolicy(null, null, null, null, null, true);
passwordPolicy.setMaxPasswordAge(10);
passwordPolicy = passwordPolicyService.save(passwordPolicy);
SysSystemDto system = createSystem(false);
IdmIdentityDto identity = createIdentity(system);
assignSystem(createUniformDefinition(true), system);
String password = getHelper().createName();
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
passwordChangeDto.setAll(true);
passwordChangeDto.setNewPassword(new GuardedString(password));
List<OperationResult> results = identityService.passwordChange(identity, passwordChangeDto);
assertEquals(2, results.size());
checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
checkPassword(prepareUid(identity, system), password, true);
checkActivePasswordOperation(identity, system, 0, password);
loginToIdm(identity, password, true);
IdmPasswordDto passwordDto = passwordService.findOneByIdentity(identity.getId());
assertNotNull(passwordDto);
assertEquals(LocalDate.now().plusDays(10), passwordDto.getValidTill());
Assert.assertNull(passwordDto.getValidFrom());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultPasswordFilterManagerIntegrationTest method testCheckPasswordValidityPasswordFilterWithoutUniformPassword.
@Test
public void testCheckPasswordValidityPasswordFilterWithoutUniformPassword() {
SysSystemDto system = createSystem(false);
IdmIdentityDto identity = createIdentity(system);
setPasswordFilter(system, true);
IdmPasswordPolicyDto passwordPolicyDto = createPasswordPolicy(null, null, null, null, null, true);
passwordPolicyDto.setMaxPasswordAge(50);
passwordPolicyDto = passwordPolicyService.save(passwordPolicyDto);
assignSystem(createUniformDefinition(false), system);
cleanProvivisioning(identity, system);
checkChangeInIdm(identity, 0);
String password = getHelper().createName();
PasswordRequest request = prepareRequest(identity.getUsername(), system.getCode(), password);
loginToIdm(identity, password, false);
checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
checkChangeInIdm(identity, 0);
processValidate(request, true);
checkEcho(identity, system, EchoCheck.VALIDATE);
processChange(request, true);
loginToIdm(identity, password, false);
checkEcho(identity, system, EchoCheck.VALIDATE_AND_CHANGE);
IdmPasswordDto passwordDto = passwordService.findOneByIdentity(identity.getId());
assertNull(passwordDto);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultPasswordFilterManagerIntegrationTest method testCheckPasswordValidityPasswordFilter50daysUniformPassword.
@Test
public void testCheckPasswordValidityPasswordFilter50daysUniformPassword() {
SysSystemDto system = createSystem(false);
IdmIdentityDto identity = createIdentity(system);
setPasswordFilter(system, true);
IdmPasswordPolicyDto passwordPolicyDto = createPasswordPolicy(null, null, null, null, null, true);
passwordPolicyDto.setMaxPasswordAge(50);
passwordPolicyDto = passwordPolicyService.save(passwordPolicyDto);
assignSystem(createUniformDefinition(true), system);
cleanProvivisioning(identity, system);
checkChangeInIdm(identity, 0);
String password = getHelper().createName();
PasswordRequest request = prepareRequest(identity.getUsername(), system.getCode(), password);
loginToIdm(identity, password, false);
checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
checkChangeInIdm(identity, 0);
processValidate(request, true);
checkEcho(identity, system, EchoCheck.VALIDATE);
processChange(request, true);
loginToIdm(identity, password, true);
checkEcho(identity, system, EchoCheck.VALIDATE_AND_CHANGE);
IdmPasswordDto passwordDto = passwordService.findOneByIdentity(identity.getId());
assertNotNull(passwordDto);
assertEquals(LocalDate.now().plusDays(50), passwordDto.getValidTill());
assertEquals(LocalDate.now(), passwordDto.getValidFrom());
}
Aggregations