Search in sources :

Example 1 with DummyTokenStorageImpl

use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.

the class TestOpenDjNegative method test195SynchronizeAllClasses.

@Test
public void test195SynchronizeAllClasses() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, null, null, null);
    try {
        mockLiveSyncTaskHandler.synchronize(coords, new DummyTokenStorageImpl(), task, result);
        AssertJUnit.fail("synchronize succeeded unexpectedly");
    } catch (CommunicationException e) {
        // Now the problem is right in the sync ConnId call.
        displayExpectedException(e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyTokenStorageImpl(com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl) Test(org.testng.annotations.Test)

Example 2 with DummyTokenStorageImpl

use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.

the class TestOpenDjNegative method test190Synchronize.

@Test
public void test190Synchronize() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, new QName(RESOURCE_NS, OBJECT_CLASS_INETORGPERSON_NAME));
    try {
        mockLiveSyncTaskHandler.synchronize(coords, new DummyTokenStorageImpl(), task, result);
        AssertJUnit.fail("synchronize succeeded unexpectedly");
    } catch (ConfigurationException e) {
        // When asking for specific object class, we expect configuration exception.
        // (Because there's no schema.)
        displayExpectedException(e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyTokenStorageImpl(com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl) Test(org.testng.annotations.Test)

Example 3 with DummyTokenStorageImpl

use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.

the class TestDummyNegative method test270LiveSyncBrokenAccountsExternalUid.

@Test
public void test270LiveSyncBrokenAccountsExternalUid() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    DummyTokenStorageImpl tokenStorage = new DummyTokenStorageImpl();
    cleanupAccounts(RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID, result);
    RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.controller.setSyncStyle(DummySyncStyle.SMART);
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.oid, SchemaConstants.RI_ACCOUNT_OBJECT_CLASS);
    List<LiveSyncEvent> events = new ArrayList<>();
    LiveSyncEventHandler handler = new LiveSyncEventHandler() {

        @Override
        public void allEventsSubmitted(OperationResult result) {
        }

        @Override
        public boolean handle(LiveSyncEvent event, OperationResult opResult) {
            events.add(event);
            event.acknowledge(true, opResult);
            return true;
        }
    };
    provisioningService.synchronize(coords, null, tokenStorage, handler, task, result);
    assertThat(events).isEmpty();
    createAccountExternalUid(GOOD_ACCOUNT, 1, null);
    createAccountExternalUid(INCONVERTIBLE_ACCOUNT, 2, "WRONG");
    createAccountExternalUid(UNSTORABLE_ACCOUNT, "WRONG", null);
    createAccountExternalUid(TOTALLY_UNSTORABLE_ACCOUNT, 4, null);
    when();
    provisioningService.synchronize(coords, null, tokenStorage, handler, task, result);
    then();
    display("events", events);
    assertThat(events.size()).as("events found").isEqualTo(4);
    List<PrismObject<ShadowType>> objects = events.stream().filter(event -> event.getChangeDescription() != null).map(event -> event.getChangeDescription().getShadowedResourceObject()).collect(Collectors.toList());
    assertSelectedAccountByName(objects, GOOD_ACCOUNT).assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(GOOD_ACCOUNT_UID).assertName(GOOD_ACCOUNT).attributes().assertSize(3).end().assertSuccessOrNoFetchResult();
    PrismObject<ShadowType> goodAfter = findShadowByPrismName(GOOD_ACCOUNT, RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.object, result);
    assertShadow(goodAfter, GOOD_ACCOUNT).display().assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(GOOD_ACCOUNT_UID).attributes().assertSize(3).end();
    assertSelectedAccountByName(objects, INCONVERTIBLE_ACCOUNT_UID).assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(INCONVERTIBLE_ACCOUNT_UID).assertName(INCONVERTIBLE_ACCOUNT_UID).attributes().assertSize(// uid=uid:inconvertible (for some reason number=2 is not there)
    1).end();
    // name is now derived from UID
    PrismObject<ShadowType> inconvertibleAfter = findShadowByPrismName(INCONVERTIBLE_ACCOUNT_UID, RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.object, result);
    assertShadow(inconvertibleAfter, INCONVERTIBLE_ACCOUNT).display().assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(INCONVERTIBLE_ACCOUNT_UID).attributes().assertSize(1).end();
    assertSelectedAccountByName(objects, UNSTORABLE_ACCOUNT_UID).assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(UNSTORABLE_ACCOUNT_UID).assertName(UNSTORABLE_ACCOUNT_UID).attributes().assertSize(// uid=unstorable
    1).end();
    // name is now derived from UID
    PrismObject<ShadowType> unstorableAfter = findShadowByPrismName(UNSTORABLE_ACCOUNT_UID, RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.object, result);
    assertShadow(unstorableAfter, UNSTORABLE_ACCOUNT).display().assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(UNSTORABLE_ACCOUNT_UID).attributes().assertSize(1).end();
    // The fetch result is not in the shadows. The exception is recorded in events.
    List<LiveSyncEvent> noChangeEvents = events.stream().filter(event -> event.getChangeDescription() == null).collect(Collectors.toList());
    if (isSqaleRepository()) {
        // Totally unstorable account is storable
        return;
    }
    assertThat(noChangeEvents).hasSize(1);
    LiveSyncEvent failedEvent = noChangeEvents.get(0);
    displayDumpable("failed event", failedEvent);
    assertThat(failedEvent.isError()).isTrue();
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) AssertJUnit(org.testng.AssertJUnit) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LiveSyncEventHandler(com.evolveum.midpoint.provisioning.api.LiveSyncEventHandler) Autowired(org.springframework.beans.factory.annotation.Autowired) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) DummyTestResource(com.evolveum.midpoint.test.DummyTestResource) com.evolveum.icf.dummy.resource(com.evolveum.icf.dummy.resource) DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) DummyTokenStorageImpl(com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools) LiveSyncEvent(com.evolveum.midpoint.provisioning.api.LiveSyncEvent) ConnectException(java.net.ConnectException) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions) ENABLE_DATE_NAME(org.identityconnectors.framework.common.objects.OperationalAttributes.ENABLE_DATE_NAME) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) ContextConfiguration(org.springframework.test.context.ContextConfiguration) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) NotNull(org.jetbrains.annotations.NotNull) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) LiveSyncEventHandler(com.evolveum.midpoint.provisioning.api.LiveSyncEventHandler) LiveSyncEvent(com.evolveum.midpoint.provisioning.api.LiveSyncEvent) DummyTokenStorageImpl(com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl) Test(org.testng.annotations.Test)

Example 4 with DummyTokenStorageImpl

use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.

the class TestOpenDjNegative method test590Synchronize.

@Test
public void test590Synchronize() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, new QName(RESOURCE_NS, OBJECT_CLASS_INETORGPERSON_NAME));
    try {
        mockLiveSyncTaskHandler.synchronize(coords, new DummyTokenStorageImpl(), task, result);
        AssertJUnit.fail("addObject succeeded unexpectedly");
    } catch (CommunicationException e) {
        // The schema is there. So we expect the exception when contacting the resource.
        displayExpectedException(e);
    }
    assertFailure(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyTokenStorageImpl(com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl) Test(org.testng.annotations.Test)

Aggregations

DummyTokenStorageImpl (com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 Test (org.testng.annotations.Test)4 QName (javax.xml.namespace.QName)2 com.evolveum.icf.dummy.resource (com.evolveum.icf.dummy.resource)1 Containerable (com.evolveum.midpoint.prism.Containerable)1 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismTestUtil (com.evolveum.midpoint.prism.util.PrismTestUtil)1 LiveSyncEvent (com.evolveum.midpoint.provisioning.api.LiveSyncEvent)1 LiveSyncEventHandler (com.evolveum.midpoint.provisioning.api.LiveSyncEventHandler)1 ProvisioningOperationOptions (com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions)1 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)1 SqaleRepositoryService (com.evolveum.midpoint.repo.sqale.SqaleRepositoryService)1 com.evolveum.midpoint.schema (com.evolveum.midpoint.schema)1 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)1 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)1 DummyResourceContoller (com.evolveum.midpoint.test.DummyResourceContoller)1 DummyTestResource (com.evolveum.midpoint.test.DummyTestResource)1