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