use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testUsername.
/**
* MID-1657
*/
@Test
public void testUsername() throws Exception {
PrismObject<UserType> user = createUserAb();
ValuePolicyType pp = parsePasswordPolicy("password-policy-username.xml");
// WHEN
when();
for (int i = 0; i < USERNAME_ATTEMPTS; i++) {
Task task = getTestTask();
OperationResult result = task.getResult();
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), getTestNameShort(), task, result);
displayValue("Generated password (" + i + ")", psswd);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNotNull(psswd);
assertPassword(psswd, pp, user);
assertFalse("Generated password that matches the username: " + psswd, psswd.equals(USER_AB_USERNAME));
}
// THEN
then();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testValueGenerateMailNonce.
@Test
public void testValueGenerateMailNonce() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
ValuePolicyType pp = parsePasswordPolicy("value-policy-generate-without-limit-with-unique.xml");
// WHEN
when();
String mailNonce = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 24, false, null, getTestNameShort(), task, result);
// THEN
then();
displayValue("Generated password", mailNonce);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNotNull(mailNonce);
assertPassword(mailNonce, pp);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testValueGenerate.
@Test
public void testValueGenerate() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
ValuePolicyType pp = parsePasswordPolicy("value-policy-generate.xml");
// WHEN
when();
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result);
// THEN
then();
displayValue("Generated password", psswd);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNotNull(psswd);
assertPassword(psswd, pp);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testUserProps.
/**
* MID-1657
*/
@Test
public void testUserProps() throws Exception {
PrismObject<UserType> user = createUserAb();
display("User", user);
ValuePolicyType pp = parsePasswordPolicy("password-policy-props.xml");
// WHEN
when();
for (int i = 0; i < USER_PROPS_ATTEMPTS; i++) {
Task task = getTestTask();
OperationResult result = task.getResult();
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), getTestNameShort(), task, result);
displayValue("Generated password (" + i + ")", psswd);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNotNull(psswd);
assertPassword(psswd, pp, user);
assertNotContains(psswd, USER_AB_USERNAME);
assertNotContains(psswd, USER_AB_GIVEN_NAME);
assertNotContains(psswd, USER_AB_ADDITIONAL_NAME);
}
// THEN
then();
}
Aggregations