use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto in project CzechIdMng by bcvsolutions.
the class PasswordPreValidationIntegrationTest method testLenght.
@Test
public void testLenght() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName(System.currentTimeMillis() + "");
policy.setDefaultPolicy(true);
policy.setMinPasswordLength(5);
policy.setMaxPasswordLength(10);
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setIdm(true);
policy = passwordPolicyService.save(policy);
try {
idmIdentityService.validatePassword(passwordChange);
} catch (ResultCodeException ex) {
assertEquals(5, ex.getError().getError().getParameters().get("minLength"));
assertEquals(10, ex.getError().getError().getParameters().get("maxLength"));
assertEquals(policy.getName(), ex.getError().getError().getParameters().get("policiesNamesPreValidation"));
assertEquals(3, ex.getError().getError().getParameters().size());
policy.setDefaultPolicy(false);
passwordPolicyService.save(policy);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto in project CzechIdMng by bcvsolutions.
the class PasswordPreValidationIntegrationTest method testNumberSpecialChar.
@Test
public void testNumberSpecialChar() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName(System.currentTimeMillis() + "");
policy.setDefaultPolicy(true);
policy.setMinNumber(5);
policy.setMinSpecialChar(10);
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setIdm(true);
policy = passwordPolicyService.save(policy);
try {
idmIdentityService.validatePassword(passwordChange);
} catch (ResultCodeException ex) {
assertEquals(5, ex.getError().getError().getParameters().get("minNumber"));
assertEquals(10, ex.getError().getError().getParameters().get("minSpecialChar"));
assertEquals(policy.getName(), ex.getError().getError().getParameters().get("policiesNamesPreValidation"));
assertFalse(ex.getError().getError().getParameters().get("specialCharacterBase") == null);
assertEquals(4, ex.getError().getError().getParameters().size());
policy.setDefaultPolicy(false);
passwordPolicyService.save(policy);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto in project CzechIdMng by bcvsolutions.
the class PasswordPreValidationIntegrationTest method testMinChar.
@Test
public void testMinChar() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName(System.currentTimeMillis() + "");
policy.setDefaultPolicy(true);
policy.setMinUpperChar(5);
policy.setMinLowerChar(10);
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setIdm(true);
policy = passwordPolicyService.save(policy);
try {
idmIdentityService.validatePassword(passwordChange);
} catch (ResultCodeException ex) {
assertEquals(5, ex.getError().getError().getParameters().get("minUpperChar"));
assertEquals(10, ex.getError().getError().getParameters().get("minLowerChar"));
assertEquals(policy.getName(), ex.getError().getError().getParameters().get("policiesNamesPreValidation"));
assertEquals(3, ex.getError().getError().getParameters().size());
policy.setDefaultPolicy(false);
passwordPolicyService.save(policy);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyIntegrationTest method testValidateBase.
@Test
public void testValidateBase() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName("test_15");
policy.setType(IdmPasswordPolicyType.GENERATE);
policy.setGenerateType(IdmPasswordPolicyGenerateType.RANDOM);
policy.setMaxPasswordLength(5);
policy.setMinPasswordLength(1);
policy.setNumberBase("123");
policy.setMinNumber(3);
IdmPasswordValidationDto password = new IdmPasswordValidationDto();
try {
password.setPassword("123");
this.passwordPolicyService.validate(password, policy);
password.setPassword("1234");
this.passwordPolicyService.validate(password, policy);
password.setPassword("111");
this.passwordPolicyService.validate(password, policy);
} catch (Exception e) {
fail("Password base validation. " + policy);
}
try {
password.setPassword("124");
this.passwordPolicyService.validate(password, policy);
fail("Password base validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("456");
this.passwordPolicyService.validate(password, policy);
fail("Password base validation. " + policy);
} catch (Exception e) {
// nothing, success
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyIntegrationTest method testOnlyMinimalLength.
@Test
public void testOnlyMinimalLength() {
// maximal password length must be always set!!
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName("test_04");
policy.setType(IdmPasswordPolicyType.GENERATE);
policy.setGenerateType(IdmPasswordPolicyGenerateType.RANDOM);
policy.setMinPasswordLength(20);
policy.setMaxPasswordLength(25);
for (int index = 0; index < ATTEMPTS; index++) {
String password = passwordPolicyService.generatePassword(policy);
assertTrue(password.length() >= 20);
}
}
Aggregations