use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestSegregationOfDuties method test130SimpleExclusionBoth1.
@Test
public void test130SimpleExclusionBoth1() throws Exception {
final String TEST_NAME = "test130SimpleExclusionBoth1";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestSegregationOfDuties.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_JUDGE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
ObjectDelta<UserType> userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext);
try {
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);
AssertJUnit.fail("Expected policy violation, but it went well");
} catch (PolicyViolationException e) {
// This is expected
}
assertAssignedNoRole(USER_JACK_OID, task, result);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test612JackAssignRoleGovernor.
/**
* Governor has maxAssignees=1
*/
@Test
public void test612JackAssignRoleGovernor() throws Exception {
final String TEST_NAME = "test612JackAssignRoleGovernor";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
try {
// WHEN
assignRole(USER_JACK_OID, 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_JACK_OID);
assertAssignees(ROLE_GOVERNOR_OID, 1);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test840AssignRoleNonAssignable.
@Test
public void test840AssignRoleNonAssignable() throws Exception {
final String TEST_NAME = "test840AssignRoleNonAssignable";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> userJackBefore = getUser(USER_JACK_OID);
display("user jack", userJackBefore);
assertNoAssignments(userJackBefore);
try {
// WHEN
TestUtil.displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_NON_ASSIGNABLE_OID, task, result);
AssertJUnit.fail("Unexpected success");
} catch (PolicyViolationException e) {
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertFailure(result);
}
PrismObject<UserType> userJackAfter = getUser(USER_JACK_OID);
display("user after", userJackAfter);
assertNoAssignments(userJackAfter);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test827AddImmutableAssignRole.
/**
* This role has a metarole which has immutable policy rule in the
* inducement.
*/
@Test
public void test827AddImmutableAssignRole() throws Exception {
final String TEST_NAME = "test827AddImmutableAssignRole";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_ASSIGN_FILE);
display("Role before", role);
try {
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(role, task, result);
AssertJUnit.fail("Unexpected success");
} catch (PolicyViolationException e) {
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertFailure(result);
}
assertNoObject(RoleType.class, ROLE_IMMUTABLE_ASSIGN_OID);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestSegregationOfDuties method test160SimpleExclusionBothBidirectional2.
@Test
public void test160SimpleExclusionBothBidirectional2() throws Exception {
final String TEST_NAME = "test160SimpleExclusionBothBidirectional2";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestSegregationOfDuties.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_JUDGE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ROLE_THIEF_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
ObjectDelta<UserType> userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext);
try {
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);
AssertJUnit.fail("Expected policy violation, but it went well");
} catch (PolicyViolationException e) {
// This is expected
}
assertAssignedNoRole(USER_JACK_OID, task, result);
}
Aggregations