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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations