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 {
getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode();
getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode();
Task task = getTestTask();
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 = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, userWorld.getOid());
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
deltas.add(delta);
modelService.executeChanges(deltas, null, task, result);
OperationResult deleteResult = createOperationResult("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 = prismContext.itemFactory().createContainerValue();
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);
// 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();
expect();
assertSuccess(result);
assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true);
// Check audit
displayDumpable("Audit", dummyAuditService);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestMultiResource method test529JackUnassignRoleDarkYellowPeru.
/**
* MID-4554
*/
@Test
public void test529JackUnassignRoleDarkYellowPeru() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User before", userBefore);
AssignmentType currentAssignment = findAssignmentByTargetRequired(userBefore, ROLE_DARK_YELLOW_PERU_OID);
// WHEN
when();
unassign(UserType.class, USER_JACK_OID, currentAssignment.getId(), task, result);
// THEN
then();
assertSuccess(result);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User after", userAfter);
assertAssignments(userAfter, 0);
assertLiveLinks(userAfter, 2);
assertDummyAccount(RESOURCE_DUMMY_DARK_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false);
assertDummyAccount(RESOURCE_DUMMY_DARK_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method fillinUserAssignmentAccountConstruction.
protected void fillinUserAssignmentAccountConstruction(PrismObject<UserType> user, String resourceOid) {
AssignmentType assignmentType = new AssignmentType();
ConstructionType accountConstruntion = new ConstructionType();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resourceOid);
resourceRef.setType(ResourceType.COMPLEX_TYPE);
accountConstruntion.setResourceRef(resourceRef);
accountConstruntion.setKind(ShadowKindType.ACCOUNT);
assignmentType.setConstruction(accountConstruntion);
user.asObjectable().getAssignment().add(assignmentType);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method determineSingleInducedRuleId.
protected String determineSingleInducedRuleId(String roleOid, OperationResult result) throws CommonException {
RoleType role = repositoryService.getObject(RoleType.class, roleOid, null, result).asObjectable();
List<AssignmentType> ruleInducements = role.getInducement().stream().filter(i -> i.getPolicyRule() != null).collect(Collectors.toList());
assertThat(ruleInducements).as("policy rule inducements in " + role).hasSize(1);
Long id = ruleInducements.get(0).getId();
argCheck(id != null, "Policy rule inducement in %s has no PCV ID", roleOid);
return roleOid + ":" + id;
}
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 recomputeMembers, ModelExecuteOptions defaultOptions) throws CommonException {
OperationResult result = createSubresult("modifyRoleAddInducementTarget");
AssignmentType inducement = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(targetOid);
inducement.setTargetRef(targetRef);
ObjectDelta<RoleType> roleDelta = prismContext.deltaFactory().object().createModificationAddContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, inducement);
ModelExecuteOptions options = setRecomputeMembers(defaultOptions, recomputeMembers);
executeChanges(roleDelta, options, getTestTask(), result);
result.computeStatus();
if (recomputeMembers) {
TestUtil.assertInProgressOrSuccess(result);
} else {
TestUtil.assertSuccess(result);
}
}
Aggregations