Search in sources :

Example 46 with ValuePolicyType

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 47 with ValuePolicyType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 48 with ValuePolicyType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 49 with ValuePolicyType

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)41 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 Task (com.evolveum.midpoint.task.api.Task)16 Test (org.testng.annotations.Test)13 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)11 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)8 StringPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.StringPolicyType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 File (java.io.File)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 StringLimitationResult (com.evolveum.midpoint.model.api.validator.StringLimitationResult)4 PrismContext (com.evolveum.midpoint.prism.PrismContext)4 StringPolicyResolver (com.evolveum.midpoint.repo.common.expression.StringPolicyResolver)4 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)3 ResourceTypeUtil (com.evolveum.midpoint.schema.util.ResourceTypeUtil)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SystemException (com.evolveum.midpoint.util.exception.SystemException)3