Search in sources :

Example 71 with RoleType

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 72 with RoleType

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);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext)

Example 73 with RoleType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 74 with RoleType

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");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismReference(com.evolveum.midpoint.prism.PrismReference) PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test)

Example 75 with RoleType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)67 Test (org.testng.annotations.Test)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)39 Task (com.evolveum.midpoint.task.api.Task)34 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)18 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)9 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)8 AbstractRoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType)8 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)8 QName (javax.xml.namespace.QName)7 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)5 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)5 File (java.io.File)5 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4