use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestModelServiceContract method test131ModifyUserJackAssignAccount.
@Test
public void test131ModifyUserJackAssignAccount() throws Exception {
final String TEST_NAME = "test131ModifyUserJackAssignAccount";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);
rememberPrismObjectCloneCount();
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
// WHEN
TestUtil.displayWhen(TEST_NAME);
assignAccount(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertShadowFetchOperationCountIncrement(0);
assertPrismObjectCloneIncrement(66);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack);
AssignmentType assignmentType = assertAssignedAccount(userJack, RESOURCE_DUMMY_OID);
assertAssignments(userJack, 1);
assertModifyMetadata(userJack, startTime, endTime);
assertCreateMetadata(assignmentType, startTime, endTime);
accountJackOid = getSingleLinkOid(userJack);
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, null, result);
assertDummyAccountShadowRepo(accountShadow, accountJackOid, "jack");
assertEnableTimestampShadow(accountShadow, startTime, endTime);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountJackOid, "jack", "Jack Sparrow");
assertEnableTimestampShadow(accountModel, startTime, endTime);
// Check account in dummy resource
assertDefaultDummyAccount("jack", "Jack Sparrow", true);
assertDummyScriptsAdd(userJack, accountModel, getDummyResourceType());
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(3);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages("accountPasswordNotifier", 1);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 1);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);
assertSteadyResources();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestModelServiceContract method test210AddUserMorganWithAssignment.
@Test
public void test210AddUserMorganWithAssignment() throws Exception {
final String TEST_NAME = "test210AddUserMorganWithAssignment";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);
PrismObject<UserType> user = PrismTestUtil.parseObject(new File(TEST_DIR, "user-morgan-assignment-dummy.xml"));
ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(user);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertShadowFetchOperationCountIncrement(0);
PrismObject<UserType> userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result);
display("User morgan after", userMorgan);
UserType userMorganType = userMorgan.asObjectable();
AssignmentType assignmentType = assertAssignedAccount(userMorgan, RESOURCE_DUMMY_OID);
assertLinks(userMorgan, 1);
ObjectReferenceType accountRefType = userMorganType.getLinkRef().get(0);
String accountOid = accountRefType.getOid();
assertFalse("No accountRef oid", StringUtils.isBlank(accountOid));
assertCreateMetadata(userMorgan, startTime, endTime);
assertCreateMetadata(assignmentType, startTime, endTime);
assertEncryptedUserPassword(userMorgan, "rum");
assertPasswordMetadata(userMorgan, true, startTime, endTime);
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
assertDummyAccountShadowRepo(accountShadow, accountOid, "morgan");
assertEnableTimestampShadow(accountShadow, startTime, endTime);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountOid, "morgan", "Sir Henry Morgan");
assertEnableTimestampShadow(accountModel, startTime, endTime);
// Check account in dummy resource
assertDefaultDummyAccount("morgan", "Sir Henry Morgan", true);
assertDummyScriptsAdd(userMorgan, accountModel, getDummyResourceType());
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(3);
dummyAuditService.assertHasDelta(ChangeType.ADD, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
dummyAuditService.assertTarget(USER_MORGAN_OID);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages("accountPasswordNotifier", 1);
checkDummyTransportMessages("userPasswordNotifier", 1);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 1);
checkDummyTransportMessages("simpleUserNotifier-ADD", 1);
checkDummyTransportMessages("simpleUserNotifier-DELETE", 0);
assertSteadyResources();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestRbac method test539JackUnAssignRoleCleric.
@Test
public void test539JackUnAssignRoleCleric() throws Exception {
final String TEST_NAME = "test539JackUnAssignRoleCleric";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> user = getObject(UserType.class, USER_JACK_OID);
AssignmentType assignmentType = new AssignmentType();
assignmentType.setId(user.asObjectable().getAssignment().get(0).getId());
ObjectDelta<UserType> assignmentDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, USER_JACK_OID, UserType.F_ASSIGNMENT, prismContext, assignmentType);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(MiscSchemaUtil.createCollection(assignmentDelta), null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after", userJack);
assertAssignedNoRole(userJack);
assertRoleMembershipRef(userJack);
assertDelegatedRef(userJack);
assertNoLinkedAccount(userJack);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class WfTestUtil method checkWfProcessAuditRecords.
public static void checkWfProcessAuditRecords(Map<String, WorkflowResult> expectedResults, DummyAuditService dummyAuditService) {
List<AuditEventRecord> records = dummyAuditService.getRecordsOfType(AuditEventType.WORKFLOW_PROCESS_INSTANCE);
assertEquals("Unexpected number of workflow process instance audit records", expectedResults.size() * 2, records.size());
for (AuditEventRecord record : records) {
if (record.getEventStage() != AuditEventStage.EXECUTION) {
continue;
}
ObjectDelta<? extends ObjectType> delta = record.getDeltas().iterator().next().getObjectDelta();
if (!delta.getModifications().isEmpty()) {
AssignmentType assignmentType = (AssignmentType) ((PrismContainerValue) delta.getModifications().iterator().next().getValuesToAdd().iterator().next()).asContainerable();
String oid = assignmentType.getTargetRef().getOid();
assertNotNull("Unexpected role to approve: " + oid, expectedResults.containsKey(oid));
assertEquals("Unexpected result for " + oid + ": " + record.getResult(), expectedResults.get(oid), WorkflowResult.fromNiceWfAnswer(record.getResult()));
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AbstractTestAssignmentApproval method executeAssignRole1ToJack.
private void executeAssignRole1ToJack(String TEST_NAME, boolean immediate, boolean deputy, String approverOid, QName relation) throws Exception {
PrismObject<UserType> jack = getUser(userJackOid);
AssignmentType assignment = createAssignmentTo(getRoleOid(1), ObjectTypes.ROLE, prismContext);
assignment.getTargetRef().setRelation(relation);
ObjectDelta<UserType> addRole1Delta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).add(assignment).asObjectDelta(userJackOid);
String realApproverOid = approverOid != null ? approverOid : userLead1Oid;
executeTest2(TEST_NAME, new TestDetails2<UserType>() {
@Override
protected PrismObject<UserType> getFocus(OperationResult result) throws Exception {
return jack.clone();
}
@Override
protected ObjectDelta<UserType> getFocusDelta() throws SchemaException {
return addRole1Delta.clone();
}
@Override
protected int getNumberOfDeltasToApprove() {
return 1;
}
@Override
protected List<Boolean> getApprovals() {
return Collections.singletonList(true);
}
@Override
protected List<ObjectDelta<UserType>> getExpectedDeltasToApprove() {
return Collections.singletonList(addRole1Delta.clone());
}
@Override
protected ObjectDelta<UserType> getExpectedDelta0() {
return ObjectDelta.createModifyDelta(jack.getOid(), Collections.emptyList(), UserType.class, prismContext);
}
@Override
protected String getObjectOid() {
return jack.getOid();
}
@Override
protected List<ExpectedTask> getExpectedTasks() {
return Collections.singletonList(new ExpectedTask(getRoleOid(1), "Assigning " + getRoleName(1) + " to jack"));
}
@Override
protected List<ExpectedWorkItem> getExpectedWorkItems() {
ExpectedTask etask = getExpectedTasks().get(0);
return Collections.singletonList(new ExpectedWorkItem(userLead1Oid, getRoleOid(1), etask));
}
@Override
protected void assertDeltaExecuted(int number, boolean yes, Task rootTask, OperationResult result) throws Exception {
if (number == 1) {
if (yes) {
assertAssignedRole(userJackOid, getRoleOid(1), rootTask, result);
checkWorkItemAuditRecords(createResultMap(getRoleOid(1), WorkflowResult.APPROVED));
checkUserApprovers(userJackOid, Collections.singletonList(realApproverOid), result);
} else {
assertNotAssignedRole(userJackOid, getRoleOid(1), rootTask, result);
}
}
}
@Override
protected Boolean decideOnApproval(String executionId, org.activiti.engine.task.Task task) throws Exception {
assertActiveWorkItems(userLead1Oid, 1);
assertActiveWorkItems(userLead1Deputy1Oid, deputy ? 1 : 0);
assertActiveWorkItems(userLead1Deputy2Oid, deputy ? 1 : 0);
checkTargetOid(executionId, getRoleOid(1));
login(getUser(realApproverOid));
return true;
}
}, 1, immediate);
}
Aggregations