use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestProjectorRoleEntitlement method test110AssignEntitlementToPirate.
@Test
public void test110AssignEntitlementToPirate() throws Exception {
final String TEST_NAME = "test110AssignEntitlementToPirate";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
LensContext<RoleType> context = createLensContext(RoleType.class);
fillContextWithFocus(context, RoleType.class, ROLE_PIRATE_OID, result);
ObjectDelta<RoleType> roleAssignmentDelta = createAssignmentDelta(RoleType.class, ROLE_PIRATE_OID, RESOURCE_DUMMY_OID, ShadowKindType.ENTITLEMENT, "group", true);
addFocusDeltaToContext(context, roleAssignmentDelta);
display("Input context", context);
assertFocusModificationSanity(context);
// WHEN
projector.project(context, "test", task, result);
// THEN
assertAssignEntitlementToPirate(context);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method assertAllowRequestItems.
protected void assertAllowRequestItems(String userOid, String targetRoleOid, AuthorizationDecisionType expectedDefaultDecision, QName... expectedAllowedItemQNames) throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException {
PrismObject<UserType> user = getUser(userOid);
PrismObject<RoleType> target = getRole(targetRoleOid);
ItemSecurityDecisions decisions = modelInteractionService.getAllowedRequestAssignmentItems(user, target);
display("Request decisions for " + target, decisions);
assertEquals("Wrong assign default decision", expectedDefaultDecision, decisions.getDefaultDecision());
assertEquals("Unexpected number of allowed items", expectedAllowedItemQNames.length, decisions.getItemDecisionMap().size());
decisions.getItemDecisionMap().forEach((path, decision) -> {
assertEquals("wrong item " + path + " decision", AuthorizationDecisionType.ALLOW, decision);
QName lastPathName = path.lastNamed().getName();
if (!Arrays.stream(expectedAllowedItemQNames).anyMatch(qname -> QNameUtil.match(qname, lastPathName))) {
AssertJUnit.fail("Unexpected path " + path);
}
});
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method getRole.
protected PrismObject<RoleType> getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getRole");
OperationResult result = task.getResult();
PrismObject<RoleType> role = modelService.getObject(RoleType.class, oid, null, task, result);
result.computeStatus();
TestUtil.assertSuccess("getObject(Role) result not success", result);
return role;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleDeleteInducement.
protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
if (task == null) {
task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducement");
}
OperationResult result = task.getResult();
AssignmentType inducement = new AssignmentType();
inducement.setId(inducementId);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, roleOid, 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.RoleType in project midpoint by Evolveum.
the class AbstractAdLdapMultidomainTest method test515AddOrgGroupMeleeIslandPirates.
/**
* Create role under the Melee Island org. This creates group in the orgstruct.
*/
@Test
public void test515AddOrgGroupMeleeIslandPirates() throws Exception {
final String TEST_NAME = "test515AddOrgGroupMeleeIslandPirates";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
PrismObject<RoleType> role = instantiateObject(RoleType.class);
RoleType roleType = role.asObjectable();
roleType.setName(new PolyStringType(GROUP_MELEE_ISLAND_PIRATES_NAME));
AssignmentType metaroleAssignment = new AssignmentType();
ObjectReferenceType metaroleRef = new ObjectReferenceType();
metaroleRef.setOid(ROLE_META_ORG_GROUP_OID);
metaroleRef.setType(RoleType.COMPLEX_TYPE);
metaroleAssignment.setTargetRef(metaroleRef);
roleType.getAssignment().add(metaroleAssignment);
AssignmentType orgAssignment = new AssignmentType();
ObjectReferenceType orgRef = new ObjectReferenceType();
orgRef.setOid(orgMeleeIslandOid);
orgRef.setType(OrgType.COMPLEX_TYPE);
orgAssignment.setTargetRef(orgRef);
roleType.getAssignment().add(orgAssignment);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(role, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
roleMeleeIslandPiratesOid = role.getOid();
// TODO: assert LDAP object
Entry entryOrgGroup = assertLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_NAME);
PrismObject<RoleType> roleAfter = getObject(RoleType.class, roleMeleeIslandPiratesOid);
display("Role after", roleAfter);
groupMeleeIslandPiratesOid = getSingleLinkOid(roleAfter);
PrismObject<ShadowType> shadow = getShadowModel(groupMeleeIslandPiratesOid);
display("Shadow (model)", shadow);
// assertLdapConnectorInstances(2);
}
Aggregations