use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestDynamicSchema method testAssignmentExtensionContainerItem.
@Test
public void testAssignmentExtensionContainerItem() throws Exception {
System.out.println("===[ testAssignmentExtensionContainerItem ]===");
// GIVEN
PrismContainer<AssignmentType> assignmentExtensionContainer = parseUserAssignmentContainer();
// WHEN
PrismProperty<String> assignmentExtensionStringProperty = assignmentExtensionContainer.findOrCreateItem(new ItemPath(EXTENSION_STRING_TYPE_ELEMENT), PrismProperty.class);
// THEN
assertNotNull("stringType is null", assignmentExtensionStringProperty);
assertNotNull("stringType has no definition", assignmentExtensionStringProperty.getDefinition());
PrismAsserts.assertDefinition(assignmentExtensionStringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class ModelClientUtil method createRoleAssignment.
public static AssignmentType createRoleAssignment(String roleOid) {
AssignmentType roleAssignment = new AssignmentType();
ObjectReferenceType roleRef = new ObjectReferenceType();
roleRef.setOid(roleOid);
roleRef.setType(ModelClientUtil.getTypeQName(RoleType.class));
roleAssignment.setTargetRef(roleRef);
return roleAssignment;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestMultiResource method test440DavidAndGoliathAssignRoleAndCreateUserInOneStep.
@Test
public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exception {
final String TEST_NAME = "test440DavidAndGoliathAssignRoleAndCreateUserInOneStep";
TestUtil.displayTestTile(TEST_NAME);
dummyResourceGoliath.setBreakMode(BreakMode.NONE);
dummyResourceDavid.setBreakMode(BreakMode.NONE);
try {
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// delete user and his roles which were added before
PrismObject<UserType> userWorld = findUserByUsername(USER_FIELD_NAME);
AssertJUnit.assertNotNull("User must not be null.", userWorld);
ObjectDelta<UserType> delta = ObjectDelta.createDeleteDelta(UserType.class, userWorld.getOid(), prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
deltas.add(delta);
modelService.executeChanges(deltas, null, task, result);
OperationResult deleteResult = new OperationResult("Check if user was deleted properly.");
try {
repositoryService.getObject(UserType.class, userWorld.getOid(), null, deleteResult);
} catch (ObjectNotFoundException ex) {
//this is OK, we deleted user before
}
// GIVEN
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
PrismObject<UserType> userBefore = createUser(USER_WORLD_NAME, USER_WORLD_FULL_NAME, true);
userBefore.asObjectable().getOrganizationalUnit().add(PrismTestUtil.createPolyStringType("stone"));
PrismContainerValue<AssignmentType> cval = new PrismContainerValue<AssignmentType>(prismContext);
PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF);
targetRef.getValue().setOid(ROLE_FIGHT_OID);
targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE);
userBefore.findOrCreateContainer(UserType.F_ASSIGNMENT).add((PrismContainerValue) cval);
// userBefore.asObjectable().getAssignment().add(cval.asContainerable());
// this should add user and at the sate time assign the role fight..->
// the result of the operation have to be the same as in test 400
addObject(userBefore);
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
// assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true);
// Check audit
display("Audit", dummyAuditService);
// dummyAuditService.assertRecords(4);
// dummyAuditService.assertSimpleRecordSanity();
// dummyAuditService.assertAnyRequestDeltas();
// dummyAuditService.assertExecutionDeltas(0,3);
// dummyAuditService.asserHasDelta(0,ChangeType.MODIFY, UserType.class);
// dummyAuditService.asserHasDelta(0,ChangeType.ADD, ShadowType.class);
// dummyAuditService.assertExecutionDeltas(1,3);
// dummyAuditService.asserHasDelta(1,ChangeType.MODIFY, UserType.class);
// dummyAuditService.asserHasDelta(1,ChangeType.ADD, ShadowType.class);
// dummyAuditService.assertExecutionDeltas(2,2);
// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, UserType.class);
// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, ShadowType.class);
// dummyAuditService.assertExecutionSuccess();
//
// // Have a closer look at the last shadow modify delta. Make sure there are no phantom changes.
// ObjectDeltaOperation<?> executionDeltaOp = dummyAuditService.getExecutionDelta(2, ChangeType.MODIFY, ShadowType.class);
// ObjectDelta<?> executionDelta = executionDeltaOp.getObjectDelta();
// display("Last execution delta", executionDelta);
// PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 2);
} catch (Exception ex) {
LOGGER.info("ex: {}", ex);
throw ex;
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleAddInducementTarget.
protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
if (task == null) {
task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget");
}
OperationResult result = task.getResult();
AssignmentType inducement = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(targetOid);
inducement.setTargetRef(targetRef);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationAddContainer(RoleType.class, roleOid, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT)), prismContext, inducement);
ModelExecuteOptions options = new ModelExecuteOptions();
options.setReconcileAffected(reconcileAffected);
modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result);
result.computeStatus();
if (reconcileAffected) {
TestUtil.assertInProgressOrSuccess(result);
} else {
TestUtil.assertSuccess(result);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestAssignmentsWithDifferentMetaroles method executeUnassignRoles123ToJack.
private void executeUnassignRoles123ToJack(String TEST_NAME, boolean immediate, boolean approve, boolean byId, boolean has1and2) throws Exception {
PrismObject<UserType> jack = getUser(userJackOid);
AssignmentType a1 = has1and2 ? findAssignmentByTargetRequired(jack, roleRole21Oid) : null;
AssignmentType a2 = has1and2 ? findAssignmentByTargetRequired(jack, roleRole22Oid) : null;
AssignmentType a3 = findAssignmentByTargetRequired(jack, roleRole23Oid);
AssignmentType del1 = toDelete(a1, byId);
AssignmentType del2 = toDelete(a2, byId);
AssignmentType del3 = toDelete(a3, byId);
@SuppressWarnings("unchecked") ObjectDelta<UserType> deleteRole1Delta = has1and2 ? (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).delete(del1).asObjectDelta(userJackOid) : null;
@SuppressWarnings("unchecked") ObjectDelta<UserType> deleteRole2Delta = has1and2 ? (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).delete(del2).asObjectDelta(userJackOid) : null;
@SuppressWarnings("unchecked") ObjectDelta<UserType> deleteRole3Delta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).delete(del3).asObjectDelta(userJackOid);
@SuppressWarnings("unchecked") ObjectDelta<UserType> changeDescriptionDelta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_DESCRIPTION).replace(TEST_NAME).asObjectDelta(userJackOid);
ObjectDelta<UserType> primaryDelta = ObjectDelta.summarize(changeDescriptionDelta, deleteRole1Delta, deleteRole2Delta, deleteRole3Delta);
ObjectDelta<UserType> delta0 = ObjectDelta.summarize(changeDescriptionDelta, deleteRole1Delta, deleteRole2Delta);
String originalDescription = getUser(userJackOid).asObjectable().getDescription();
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 primaryDelta.clone();
}
@Override
protected int getNumberOfDeltasToApprove() {
return 1;
}
@Override
protected List<Boolean> getApprovals() {
return Arrays.asList(approve);
}
@Override
protected List<ObjectDelta<UserType>> getExpectedDeltasToApprove() {
return Arrays.asList(deleteRole3Delta.clone());
}
@Override
protected ObjectDelta<UserType> getExpectedDelta0() {
return delta0.clone();
}
@Override
protected String getObjectOid() {
return jack.getOid();
}
@Override
protected List<ExpectedTask> getExpectedTasks() {
return Arrays.asList(new ExpectedTask(roleRole23Oid, "Unassigning Role23 from jack"));
}
// after first step
@Override
protected List<ExpectedWorkItem> getExpectedWorkItems() {
List<ExpectedTask> tasks = getExpectedTasks();
return Arrays.asList(new ExpectedWorkItem(userSecurityApproverOid, roleRole23Oid, tasks.get(0)));
}
@Override
protected void assertDeltaExecuted(int number, boolean yes, Task rootTask, OperationResult result) throws Exception {
switch(number) {
case 0:
if (yes) {
assertUserProperty(userJackOid, UserType.F_DESCRIPTION, TEST_NAME);
} else {
if (originalDescription != null) {
assertUserProperty(userJackOid, UserType.F_DESCRIPTION, originalDescription);
} else {
assertUserNoProperty(userJackOid, UserType.F_DESCRIPTION);
}
}
if (yes || !has1and2) {
assertNotAssignedRole(userJackOid, roleRole21Oid, rootTask, result);
assertNotAssignedRole(userJackOid, roleRole22Oid, rootTask, result);
} else {
assertAssignedRole(userJackOid, roleRole21Oid, rootTask, result);
assertAssignedRole(userJackOid, roleRole22Oid, rootTask, result);
}
break;
case 1:
if (yes) {
assertNotAssignedRole(userJackOid, roleRole23Oid, rootTask, result);
} else {
assertAssignedRole(userJackOid, roleRole23Oid, rootTask, result);
}
break;
default:
throw new IllegalArgumentException("Unexpected delta number: " + number);
}
}
@Override
protected Boolean decideOnApproval(String executionId, org.activiti.engine.task.Task task) throws Exception {
// ignore this way of approving
return null;
}
@Override
public List<ApprovalInstruction> getApprovalSequence() {
List<ExpectedTask> tasks = getExpectedTasks();
List<ApprovalInstruction> instructions = new ArrayList<>();
instructions.add(new ApprovalInstruction(new ExpectedWorkItem(userSecurityApproverOid, roleRole23Oid, tasks.get(0)), approve, userSecurityApproverOid));
return instructions;
}
}, 1, immediate);
}
Aggregations