Search in sources :

Example 11 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummyCaseIgnore method test280EntitleAccountWillPiratesAlreadyThere.

/**
	 * Add will to the group pirates. But he is already there.
	 */
@Test
public void test280EntitleAccountWillPiratesAlreadyThere() throws Exception {
    final String TEST_NAME = "test280EntitleAccountWillPiratesAlreadyThere";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    DummyGroup groupPirates = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid);
    groupPirates.addMember(getWillRepoIcfName());
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ENTITLEMENT_GROUP_NAME), GROUP_PIRATES_OID, prismContext);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertMember(group, getWillRepoIcfName());
    syncServiceMock.assertNotifySuccessOnly();
    PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    display("Shadow after", shadow);
    assertEntitlementGroup(shadow, GROUP_PIRATES_OID);
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 12 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummy method test265DeleteAccountLeChuck.

/**
	 * LeChuck has both group and priv entitlement. If deleted it should be correctly removed from all
	 * the entitlements.
	 */
@Test
public void test265DeleteAccountLeChuck() throws Exception {
    final String TEST_NAME = "test265DeleteAccountLeChuck";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    // WHEN
    provisioningService.deleteObject(ShadowType.class, ACCOUNT_LECHUCK_OID, null, null, task, result);
    // THEN
    result.computeStatus();
    display("add object result", result);
    TestUtil.assertSuccess("addObject has failed (result)", result);
    syncServiceMock.assertNotifySuccessOnly();
    // Check if the account is gone and that group membership is gone as well
    DummyAccount dummyAccount = getDummyAccount(ACCOUNT_LECHUCK_NAME, leChuckIcfUid);
    assertNull("Dummy account is NOT gone", dummyAccount);
    // Make sure that privilege object is still there
    DummyPrivilege priv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid);
    assertNotNull("Privilege object is gone!", priv);
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertNoMember(group, ACCOUNT_LECHUCK_NAME);
    try {
        repositoryService.getObject(ShadowType.class, ACCOUNT_LECHUCK_OID, null, result);
        AssertJUnit.fail("Shadow (repo) is not gone");
    } catch (ObjectNotFoundException e) {
    // This is expected
    }
    try {
        provisioningService.getObject(ShadowType.class, ACCOUNT_LECHUCK_OID, null, task, result);
        AssertJUnit.fail("Shadow (provisioning) is not gone");
    } catch (ObjectNotFoundException e) {
    // This is expected
    }
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 13 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummy method test205ModifyGroupReplace.

@Test
public void test205ModifyGroupReplace() throws Exception {
    final String TEST_NAME = "test205ModifyGroupReplace";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    rememberDummyResourceGroupMembersReadCount(null);
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, GROUP_PIRATES_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION), prismContext, "Bloodthirsty pirates");
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertDummyAttributeValues(group, DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION, "Bloodthirsty pirates");
    if (isAvoidDuplicateValues()) {
        assertDummyResourceGroupMembersReadCountIncrement(null, 1);
    } else {
        assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    }
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 14 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummy method test222EntitleAccountWillPillage.

@Test
public void test222EntitleAccountWillPillage() throws Exception {
    final String TEST_NAME = "test222EntitleAccountWillPillage";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    rememberDummyResourceGroupMembersReadCount(null);
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_WILL_OID, ASSOCIATION_PRIV_NAME, PRIVILEGE_PILLAGE_OID, prismContext);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    assertNotNull("Account will is gone!", dummyAccount);
    Set<String> accountProvileges = dummyAccount.getAttributeValues(DummyAccount.ATTR_PRIVILEGES_NAME, String.class);
    PrismAsserts.assertSets("account privileges", accountProvileges, PRIVILEGE_PILLAGE_NAME);
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    // Make sure that privilege object is still there
    DummyPrivilege priv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid);
    assertNotNull("Privilege object is gone!", priv);
    delta.checkConsistence();
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    // Make sure that the groups is still there and will is a member
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertMember(group, transformNameToResource(ACCOUNT_WILL_USERNAME));
    syncServiceMock.assertNotifySuccessOnly();
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    display("Shadow after", shadow);
    assertEntitlementGroup(shadow, GROUP_PIRATES_OID);
    assertEntitlementPriv(shadow, PRIVILEGE_PILLAGE_OID);
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 15 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestSynchronizationService method test210AddedGroupPirates.

@Test
public void test210AddedGroupPirates() throws Exception {
    final String TEST_NAME = "test210AddedGroupPirates";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestSynchronizationService.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    MockLensDebugListener mockListener = new MockLensDebugListener();
    clockwork.setDebugListener(mockListener);
    PrismObject<ShadowType> shadowPirates = repoAddObjectFromFile(SHADOW_PIRATES_DUMMY_FILE, result);
    provisioningService.applyDefinition(shadowPirates, task, result);
    assertNotNull("No oid in shadow", shadowPirates.getOid());
    DummyGroup dummyGroup = new DummyGroup();
    dummyGroup.setName(GROUP_PIRATES_DUMMY_NAME);
    dummyGroup.setEnabled(true);
    dummyGroup.addAttributeValues(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION, "Scurvy Pirates");
    getDummyResource().addGroup(dummyGroup);
    ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
    change.setCurrentShadow(shadowPirates);
    change.setResource(getDummyResourceObject());
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    synchronizationService.notifyChange(change, task, result);
    // THEN
    TestUtil.displayWhen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    LensContext<UserType> context = mockListener.getLastSyncContext();
    display("Resulting context (as seen by debug listener)", context);
    assertNotNull("No resulting context (as seen by debug listener)", context);
    assertNotNull("No focus primary delta", context.getFocusContext().getPrimaryDelta());
    //        assertNotNull("No focus secondary delta", context.getFocusContext().getSecondaryDelta());
    assertFalse("No executed focus deltas", context.getFocusContext().getExecutedDeltas().isEmpty());
    ObjectDelta<UserType> userSecondaryDelta = (ObjectDelta<UserType>) context.getFocusContext().getExecutedDeltas().iterator().next().getObjectDelta();
    ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ENTITLEMENT, INTENT_GROUP);
    LensProjectionContext projCtx = context.findProjectionContext(rat);
    assertNotNull("No projection sync context for " + rat, projCtx);
    assertEquals("Wrong detected situation in context", SynchronizationSituationType.UNMATCHED, projCtx.getSynchronizationSituationDetected());
    assertEquals("Wrong resolved situation in context", SynchronizationSituationType.LINKED, projCtx.getSynchronizationSituationResolved());
    PrismAsserts.assertNoDelta("Unexpected projection primary delta", projCtx.getPrimaryDelta());
    //it this really expected?? delta was already executed, should we expect it in the secondary delta?
    //		assertNotNull("Missing account secondary delta", accCtx.getSecondaryDelta());
    //		assertIterationDelta(accCtx.getSecondaryDelta(), 0, "");
    assertLinked(RoleType.class, context.getFocusContext().getOid(), shadowPirates.getOid());
    PrismObject<ShadowType> shadow = getShadowModelNoFetch(shadowPirates.getOid());
    assertIteration(shadow, 0, "");
    assertSituation(shadow, SynchronizationSituationType.LINKED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MockLensDebugListener(com.evolveum.midpoint.model.impl.util.mock.MockLensDebugListener) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)38 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 Task (com.evolveum.midpoint.task.api.Task)23 Test (org.testng.annotations.Test)23 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)20 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)18 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)16 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)11 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)7 GuardedString (org.identityconnectors.common.security.GuardedString)7 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)6 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)6 ObjectAlreadyExistsException (com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException)6 FileNotFoundException (java.io.FileNotFoundException)6 ConnectException (java.net.ConnectException)6 AlreadyExistsException (org.identityconnectors.framework.common.exceptions.AlreadyExistsException)6 ConnectionFailedException (org.identityconnectors.framework.common.exceptions.ConnectionFailedException)6 ConnectorIOException (org.identityconnectors.framework.common.exceptions.ConnectorIOException)6 InvalidAttributeValueException (org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException)6 QName (javax.xml.namespace.QName)5