Search in sources :

Example 21 with PolicyViolationException

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

the class TestRbac method test625BignoseAssignRoleCanibal.

@Test
public void test625BignoseAssignRoleCanibal() throws Exception {
    final String TEST_NAME = "test625BignoseAssignRoleCanibal";
    TestUtil.displayTestTile(this, TEST_NAME);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> user = createUser(USER_BIGNOSE_NAME, USER_BIGNOSE_FULLNAME, true);
    addObject(user);
    userBignoseOid = user.getOid();
    assertAssignees(ROLE_CANNIBAL_OID, 3);
    try {
        // WHEN
        TestUtil.displayWhen(TEST_NAME);
        assignRole(user.getOid(), ROLE_GOVERNOR_OID, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (PolicyViolationException e) {
        // this is expected
        display("Expected exception", e);
    }
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertFailure(result);
    assertNoAssignments(user.getOid());
    assertAssignees(ROLE_CANNIBAL_OID, 3);
    assertAssignees(ROLE_GOVERNOR_OID, 1);
}
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) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 22 with PolicyViolationException

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

the class TestSegregationOfDuties method test222GuybrushAssignRoleControllingOne.

/**
	 * MID-3694
	 */
@Test
public void test222GuybrushAssignRoleControllingOne() throws Exception {
    final String TEST_NAME = "test222GuybrushAssignRoleControllingOne";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    try {
        // WHEN
        displayWhen(TEST_NAME);
        assignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result);
        assertNotReached();
    } catch (PolicyViolationException e) {
        // THEN
        displayThen(TEST_NAME);
        assertFailure(result);
    }
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertAssignedRole(userAfter, ROLE_EXECUTIVE_1_OID);
    assertNotAssignedRole(userAfter, ROLE_CONTROLLING_1_OID);
}
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) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 23 with PolicyViolationException

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

the class TestSegregationOfDuties method test122SimpleExclusion2Deprecated.

/**
	 * Same thing as before but other way around 
	 */
@Test
public void test122SimpleExclusion2Deprecated() throws Exception {
    final String TEST_NAME = "test122SimpleExclusion2Deprecated";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestSegregationOfDuties.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // This should go well
    assignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, task, result);
    try {
        // This should die
        assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);
        AssertJUnit.fail("Expected policy violation after adding pirate role, but it went well");
    } catch (PolicyViolationException e) {
    // This is expected
    }
    unassignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, task, result);
    assertAssignedNoRole(USER_JACK_OID, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 24 with PolicyViolationException

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

the class TestSegregationOfDuties method test225GuybrushAssignRoleControllingTwo.

/**
	 * MID-3694
	 */
@Test
public void test225GuybrushAssignRoleControllingTwo() throws Exception {
    final String TEST_NAME = "test225GuybrushAssignRoleControllingTwo";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    try {
        // WHEN
        displayWhen(TEST_NAME);
        assignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_2_OID, task, result);
        assertNotReached();
    } catch (PolicyViolationException e) {
        // THEN
        displayThen(TEST_NAME);
        assertFailure(result);
    }
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertAssignedRole(userAfter, ROLE_EXECUTIVE_1_OID);
    assertAssignedRole(userAfter, ROLE_EXECUTIVE_2_OID);
    assertNotAssignedRole(userAfter, ROLE_CONTROLLING_1_OID);
    assertNotAssignedRole(userAfter, ROLE_CONTROLLING_2_OID);
}
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) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 25 with PolicyViolationException

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

the class TestSegregationOfDuties method test110SimpleExclusion1.

@Test
public void test110SimpleExclusion1() throws Exception {
    final String TEST_NAME = "test110SimpleExclusion1";
    displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // This should go well
    assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);
    assertSuccess(result);
    try {
        // This should die
        assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result);
        fail("Expected policy violation after adding judge role, but it went well");
    } catch (PolicyViolationException e) {
        // This is expected
        result.computeStatus();
        assertFailure(result);
    }
    unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);
    assertAssignedNoRole(USER_JACK_OID, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

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