use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test815ModifyRoleImmutableGlobalDescription.
@Test
public void test815ModifyRoleImmutableGlobalDescription() throws Exception {
final String TEST_NAME = "test815ModifyRoleImmutableGlobalDescription";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
try {
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_DESCRIPTION, task, result, "whatever");
AssertJUnit.fail("Unexpected success");
} catch (PolicyViolationException e) {
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertFailure(result);
}
PrismObject<RoleType> roleAfter = getObject(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID);
PrismAsserts.assertPropertyValue(roleAfter, RoleType.F_DESCRIPTION, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_DESCRIPTION);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test800ModifyRoleImmutable.
@Test
public void test800ModifyRoleImmutable() throws Exception {
final String TEST_NAME = "test800ModifyRoleImmutable";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
try {
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_OID, RoleType.F_DESCRIPTION, task, result, "whatever");
AssertJUnit.fail("Unexpected success");
} catch (PolicyViolationException e) {
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertFailure(result);
}
PrismObject<RoleType> roleAfter = getObject(RoleType.class, ROLE_IMMUTABLE_OID);
PrismAsserts.assertPropertyValue(roleAfter, RoleType.F_DESCRIPTION, ROLE_IMMUTABLE_DESCRIPTION);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test602JackAssignRolePirate.
/**
* Judge and pirate are excluded roles. This should fail.
*/
@Test
public void test602JackAssignRolePirate() throws Exception {
final String TEST_NAME = "test602JackAssignRolePirate";
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_PIRATE_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);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User jack after", userAfter);
assertAssignedRole(userAfter, ROLE_JUDGE_OID, task, result);
assertRoleMembershipRef(userAfter, ROLE_JUDGE_OID);
assertDelegatedRef(userAfter);
assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Honorable Justice");
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "mouth", "pistol");
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test826AddNonCreateableRole.
@Test
public void test826AddNonCreateableRole() throws Exception {
final String TEST_NAME = "test826AddNonCreateableRole";
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_NON_CREATEABLE_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_NON_CREATEABLE_OID);
}
use of com.evolveum.midpoint.util.exception.PolicyViolationException in project midpoint by Evolveum.
the class TestRbac method test804ModifyRoleImmutableGlobalIdentifier.
@Test
public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception {
final String TEST_NAME = "test804ModifyRoleImmutableGlobalIdentifier";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
try {
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_IDENTIFIER, task, result, "whatever");
AssertJUnit.fail("Unexpected success");
} catch (PolicyViolationException e) {
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertFailure(result);
}
PrismObject<RoleType> roleAfter = getObject(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID);
PrismAsserts.assertPropertyValue(roleAfter, RoleType.F_DESCRIPTION, ROLE_IMMUTABLE_GLOBAL_DESCRIPTION);
PrismAsserts.assertPropertyValue(roleAfter, RoleType.F_IDENTIFIER, ROLE_IMMUTABLE_GLOBAL_IDENTIFIER);
}
Aggregations