Search in sources :

Example 36 with PolicyViolationException

use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.

the class TestPasswordDeprecated method doTestModifyUserJackPasswordFailureWithHistory.

private void doTestModifyUserJackPasswordFailureWithHistory(final String TEST_NAME, String newPassword, String oldPassword, String... expectedPasswordHistory) throws Exception {
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    try {
        // WHEN
        modifyUserChangePassword(USER_JACK_OID, newPassword, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (PolicyViolationException e) {
        // This is expected
        display("Exected exception", e);
    }
    // THEN
    result.computeStatus();
    TestUtil.assertFailure(result);
    assertJackPasswordsWithHistory(oldPassword, expectedPasswordHistory);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException)

Example 37 with PolicyViolationException

use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.

the class AbstractLdapHierarchyTest method reconcileAllOrgs.

protected void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    final Task task = createTask("reconcileAllOrgs");
    OperationResult result = task.getResult();
    ResultHandler<OrgType> handler = new ResultHandler<OrgType>() {

        @Override
        public boolean handle(PrismObject<OrgType> object, OperationResult parentResult) {
            try {
                display("reconciling " + object);
                reconcileOrg(object.getOid(), task, parentResult);
            } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException e) {
                throw new SystemException(e.getMessage(), e);
            }
            return true;
        }
    };
    display("Reconciling all orgs");
    modelService.searchObjectsIterative(OrgType.class, null, handler, null, task, result);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismObject(com.evolveum.midpoint.prism.PrismObject) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 38 with PolicyViolationException

use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.

the class TestPasswordPolicyProcessor method doTestModifyUserPasswordExpectFailure.

public void doTestModifyUserPasswordExpectFailure(final String TEST_NAME, String password) throws Exception {
    Task task = taskManager.createTaskInstance(TEST_NAME);
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult result = task.getResult();
    try {
        // WHEN
        modifyUserChangePassword(USER_JACK_OID, password, task, result);
        fail("Expected PolicyViolationException but didn't get one.");
    } catch (PolicyViolationException ex) {
        // this is expected
        display("expected exception", ex);
        result.computeStatus();
        TestUtil.assertFailure(result);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException)

Example 39 with PolicyViolationException

use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.

the class TestProjector method test269DeleteBarbossaDummyAccount.

/**
	 * User barbossa has a direct account assignment.
	 * Let's try to delete assigned account. It should end up with a policy violation error.
	 */
@Test
public void test269DeleteBarbossaDummyAccount() throws Exception {
    final String TEST_NAME = "test269DeleteBarbossaDummyAccount";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestProjector.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    LensContext<UserType> context = createUserLensContext();
    // Do not fill user to context. Projector should figure that out.
    fillContextWithAccount(context, ACCOUNT_HBARBOSSA_DUMMY_OID, task, result);
    addModificationToContextDeleteAccount(context, ACCOUNT_HBARBOSSA_DUMMY_OID);
    context.recompute();
    display("Input context", context);
    try {
        // WHEN        	
        projector.project(context, "test", task, result);
        // THEN: fail
        display("Output context", context);
        assert context.getFocusContext() != null : "The operation was successful but it should throw expcetion AND " + "there is no focus context";
        assert false : "The operation was successful but it should throw expcetion";
    } catch (PolicyViolationException e) {
        // THEN: success
        // this is expected
        display("Expected exception", e);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 40 with PolicyViolationException

use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.

the class TestStrangeCases method test332AssignDeGhoulashRecursion.

/**
     * Recursion role points to itself. The assignment should fail.
     */
@Test
public void test332AssignDeGhoulashRecursion() throws Exception {
    final String TEST_NAME = "test332AssignDeGhoulashRecursion";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestStrangeCases.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    dummyAuditService.clear();
    try {
        // WHEN
        assignRole(USER_DEGHOULASH_OID, ROLE_RECURSION_OID, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (PolicyViolationException e) {
        // This is expected
        display("Expected exception", e);
    }
    // THEN
    result.computeStatus();
    TestUtil.assertFailure(result);
    PrismObject<UserType> userDeGhoulash = getUser(USER_DEGHOULASH_OID);
    display("User after change execution", userDeGhoulash);
    assertUser(userDeGhoulash, USER_DEGHOULASH_OID, "deghoulash", "Charles DeGhoulash", "Charles", "DeGhoulash");
    assertAssignedRoles(userDeGhoulash, ROLE_IDIOT_OID);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)85 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)72 Task (com.evolveum.midpoint.task.api.Task)65 Test (org.testng.annotations.Test)50 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)32 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)24 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)23 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)22 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)22 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)22 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)22 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)18 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)15 ArrayList (java.util.ArrayList)12 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)11 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)9 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8