use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method findInducementByTarget.
protected AssignmentType findInducementByTarget(String roleOid, String targetOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".findInducementByTarget");
OperationResult result = task.getResult();
PrismObject<RoleType> role = modelService.getObject(RoleType.class, roleOid, null, task, result);
for (AssignmentType inducement : role.asObjectable().getInducement()) {
ObjectReferenceType targetRef = inducement.getTargetRef();
if (targetRef != null && targetOid.equals(targetRef.getOid())) {
return inducement;
}
}
return null;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestProjectorRoleEntitlement method assertAssignEntitlementToPirate.
private void assertAssignEntitlementToPirate(LensContext<RoleType> context) {
display("Output context", context);
assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY);
assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "focus secondary delta", ActivationStatusType.ENABLED);
assertFalse("No projection changes", context.getProjectionContexts().isEmpty());
Collection<LensProjectionContext> projectionContexts = context.getProjectionContexts();
assertEquals(1, projectionContexts.size());
LensProjectionContext projContext = projectionContexts.iterator().next();
assertNull("Projection primary delta sneaked in", projContext.getPrimaryDelta());
ObjectDelta<ShadowType> projSecondaryDelta = projContext.getSecondaryDelta();
assertEquals("Wrong decision", SynchronizationPolicyDecision.ADD, projContext.getSynchronizationPolicyDecision());
assertEquals(ChangeType.MODIFY, projSecondaryDelta.getChangeType());
PrismAsserts.assertPropertyReplace(projSecondaryDelta, getIcfsNameAttributePath(), "Pirate");
PrismAsserts.assertPropertyReplace(projSecondaryDelta, getDummyResourceController().getAttributePath(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION), "Bloody pirates");
PrismAsserts.assertOrigin(projSecondaryDelta, OriginType.OUTBOUND);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestProjectorRoleEntitlement method test111AssignEntitlementToPirateBroken.
/**
* Same sa previous test but the deltas are slightly broken.
*/
@Test
public void test111AssignEntitlementToPirateBroken() 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);
// Let's break it a bit...
breakAssignmentDelta(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 TestProjectorRoleEntitlement method test100AddEntitlementToPirateDirect.
/**
* Add direct entitlement assignment to role "pirate". The entitlement projection
* context should appear in the lens context.
*/
@Test
public void test100AddEntitlementToPirateDirect() throws Exception {
final String TEST_NAME = "test100AddEntitlementToPirateDirect";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
LensContext<RoleType> context = createLensContext(RoleType.class);
fillContextWithFocus(context, RoleType.class, ROLE_PIRATE_OID, result);
// We want "shadow" so the fullname will be computed by outbound expression
addModificationToContextAddProjection(context, RoleType.class, ENTITLEMENT_SHADOW_PIRATE_DUMMY_FILE);
display("Input context", context);
assertFocusModificationSanity(context);
// WHEN
projector.project(context, "test", task, result);
// THEN
display("Output context", context);
assertNull("Unexpected focus primary changes " + context.getFocusContext().getPrimaryDelta(), context.getFocusContext().getPrimaryDelta());
assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "focus secondary delta", ActivationStatusType.ENABLED);
assertFalse("No entitlement changes", context.getProjectionContexts().isEmpty());
Collection<LensProjectionContext> accountContexts = context.getProjectionContexts();
assertEquals(1, accountContexts.size());
LensProjectionContext projContext = accountContexts.iterator().next();
assertEquals("Wrong policy decision", SynchronizationPolicyDecision.ADD, projContext.getSynchronizationPolicyDecision());
ObjectDelta<ShadowType> accountPrimaryDelta = projContext.getPrimaryDelta();
assertEquals(ChangeType.ADD, accountPrimaryDelta.getChangeType());
PrismObject<ShadowType> accountToAddPrimary = accountPrimaryDelta.getObjectToAdd();
assertNotNull("No object in projection primary add delta", accountToAddPrimary);
PrismProperty<Object> intentProperty = accountToAddPrimary.findProperty(ShadowType.F_INTENT);
assertNotNull("No intent type in projection primary add delta", intentProperty);
assertEquals("group", intentProperty.getRealValue());
assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "GroupObjectClass"), accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue());
PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF);
assertEquals(getDummyResourceType().getOid(), resourceRef.getOid());
accountToAddPrimary.checkConsistence();
ObjectDelta<ShadowType> projSecondaryDelta = projContext.getSecondaryDelta();
assertEquals(ChangeType.MODIFY, projSecondaryDelta.getChangeType());
PropertyDelta<String> groupDescriptionDelta = projSecondaryDelta.findPropertyDelta(getDummyResourceController().getAttributePath(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION));
assertNotNull("No group description delta", groupDescriptionDelta);
PrismAsserts.assertReplace(groupDescriptionDelta, "Bloody pirates");
PrismAsserts.assertOrigin(groupDescriptionDelta, OriginType.OUTBOUND);
PrismObject<ShadowType> projectionNew = projContext.getObjectNew();
IntegrationTestTools.assertIcfsNameAttribute(projectionNew, "pirate");
IntegrationTestTools.assertAttribute(projectionNew, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION), "Bloody pirates");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestRbac method test812AddGlobalImmutableDescriptionRole.
/**
* This should go well. The global immutable role has enforced modification,
* but not addition.
*/
@Test
public void test812AddGlobalImmutableDescriptionRole() throws Exception {
final String TEST_NAME = "test812AddGlobalImmutableDescriptionRole";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_FILE);
display("Role before", role);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(role, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<RoleType> roleAfter = getObject(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID);
display("Role after", roleAfter);
assertNotNull("No role added", roleAfter);
}
Aggregations