use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method passwordValidationTestTri.
@Test
public void passwordValidationTestTri() throws Exception {
final String TEST_NAME = "passwordValidationTestTri";
TestUtil.displayTestTile(TEST_NAME);
ValuePolicyType pp = parsePasswordPolicy("password-policy-tri.xml");
// WHEN, THEN
AssertJUnit.assertTrue(pwdValidHelper("Password1", pp));
// no capital letter
AssertJUnit.assertFalse(pwdValidHelper("password1", pp));
// no lowecase letter
AssertJUnit.assertFalse(pwdValidHelper("1PASSWORD", pp));
// no numeral
AssertJUnit.assertFalse(pwdValidHelper("Password", pp));
// too short
AssertJUnit.assertFalse(pwdValidHelper("Pa1", pp));
// too long
AssertJUnit.assertFalse(pwdValidHelper("PPPPPPPPPPPPPPPPPPPPPPPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa11111111111111111111111111111111111111111111111111111111111111111111", pp));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testValueGenerateEmpty.
@Test
public void testValueGenerateEmpty() throws Exception {
final String TEST_NAME = "testValueGenerateEmpty";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
File file = new File(TEST_DIR, "value-policy-generate-empty.xml");
LOGGER.info("Positive testing {}: {}", "testValueGenerate", "value-policy-generate-empty.xml");
ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable();
// WHEN
TestUtil.displayWhen(TEST_NAME);
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, true, null, TEST_NAME, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
display("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 {
final String TEST_NAME = "testUserProps";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<UserType> user = createUserAb();
display("User", user);
ValuePolicyType pp = parsePasswordPolicy("password-policy-props.xml");
// WHEN
TestUtil.displayWhen(TEST_NAME);
for (int i = 0; i < USER_PROPS_ATTEMPTS; i++) {
Task task = createTask(TEST_NAME + ":" + i);
OperationResult result = task.getResult();
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, true, user, TEST_NAME, task, result);
display("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
TestUtil.displayThen(TEST_NAME);
}
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 {
final String TEST_NAME = "testValueGenerate";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ValuePolicyType pp = parsePasswordPolicy("value-policy-generate.xml");
// WHEN
TestUtil.displayWhen(TEST_NAME);
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, true, null, TEST_NAME, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
display("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 testUsername.
/**
* MID-1657
*/
@Test
public void testUsername() throws Exception {
final String TEST_NAME = "testUsername";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<UserType> user = createUserAb();
ValuePolicyType pp = parsePasswordPolicy("password-policy-username.xml");
// WHEN
TestUtil.displayWhen(TEST_NAME);
for (int i = 0; i < USERNAME_ATTEMPTS; i++) {
Task task = createTask(TEST_NAME + ":" + i);
OperationResult result = task.getResult();
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, true, user, TEST_NAME, task, result);
display("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
TestUtil.displayThen(TEST_NAME);
}
Aggregations