Search in sources :

Example 6 with LDIFReader

use of org.opends.server.util.LDIFReader in project midpoint by Evolveum.

the class TestGenericSynchronization method createUserEntry.

private Entry createUserEntry(String uid, String suffix, String sn) throws IOException, LDIFException {
    StringBuilder sb = new StringBuilder();
    String dn = "uid=" + uid + "," + suffix;
    sb.append("dn: ").append(dn).append('\n');
    sb.append("objectClass: inetOrgPerson\n");
    sb.append("uid: ").append(uid).append('\n');
    sb.append("givenName: ").append("John").append('\n');
    sb.append("cn: ").append("John " + sn).append('\n');
    sb.append("sn: ").append(sn).append('\n');
    LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb.toString(), "utf-8"));
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry ldifEntry = ldifReader.readEntry();
    return ldifEntry;
}
Also used : Entry(org.opends.server.types.Entry) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader)

Example 7 with LDIFReader

use of org.opends.server.util.LDIFReader in project midpoint by Evolveum.

the class TestSynchronization method test100SyncAddWill.

@Test
public void test100SyncAddWill() throws Exception {
    final String TEST_NAME = "test100SyncAddWill";
    TestUtil.displayTestTile(TEST_NAME);
    final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME);
    Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
    AssertJUnit.assertNotNull(syncTask);
    assertSyncToken(syncTask, 0, result);
    ((SynchornizationServiceMock) syncServiceMock).reset();
    // create add change in embeded LDAP
    LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_WILL_FILE.getPath());
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry entry = ldifReader.readEntry();
    display("Entry from LDIF", entry);
    AddOperation addOperation = openDJController.getInternalConnection().processAdd(entry);
    AssertJUnit.assertEquals("LDAP add operation failed", ResultCode.SUCCESS, addOperation.getResultCode());
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(resourceType.getOid(), AbstractOpenDjTest.RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
    // WHEN
    provisioningService.synchronize(coords, syncTask, result);
    // THEN
    SynchornizationServiceMock mock = (SynchornizationServiceMock) syncServiceMock;
    assertEquals("Unexpected number of synchronization service calls", 1, mock.getCallCount());
    ResourceObjectShadowChangeDescription lastChange = mock.getLastChange();
    //			ObjectDelta<? extends ShadowType> objectDelta = lastChange.getObjectDelta();
    //			assertNotNull("Null object delta in change notification", objectDelta);
    //			assertEquals("Wrong change type in delta in change notification", ChangeType.ADD, objectDelta.getChangeType());
    PrismObject<? extends ShadowType> currentShadow = lastChange.getCurrentShadow();
    assertNotNull("No current shadow in change notification", currentShadow);
    assertNotNull("No old shadow in change notification", lastChange.getOldShadow());
    assertEquals("Wrong shadow name", PrismTestUtil.createPolyStringType(ACCOUNT_WILL_NAME), currentShadow.asObjectable().getName());
    assertSyncToken(SYNC_TASK_OID, 1, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) SynchornizationServiceMock(com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) AddOperation(org.opends.server.core.AddOperation) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 8 with LDIFReader

use of org.opends.server.util.LDIFReader in project midpoint by Evolveum.

the class TestSynchronization method test500SyncAddProtected.

@Test
public void test500SyncAddProtected() throws Exception {
    final String TEST_NAME = "test500SyncAddProtected";
    TestUtil.displayTestTile(TEST_NAME);
    final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME);
    Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
    AssertJUnit.assertNotNull(syncTask);
    assertSyncToken(syncTask, 1, result);
    ((SynchornizationServiceMock) syncServiceMock).reset();
    // create add change in embedded LDAP
    LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_CALYPSO_FILE.getPath());
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry entry = ldifReader.readEntry();
    ldifReader.close();
    display("Entry from LDIF", entry);
    AddOperation addOperation = openDJController.getInternalConnection().processAdd(entry);
    AssertJUnit.assertEquals("LDAP add operation failed", ResultCode.SUCCESS, addOperation.getResultCode());
    ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(resourceType.getOid(), AbstractOpenDjTest.RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
    // WHEN
    provisioningService.synchronize(coords, syncTask, result);
    // THEN
    SynchornizationServiceMock mock = (SynchornizationServiceMock) syncServiceMock;
    assertEquals("Unexpected number of synchronization service calls", 0, mock.getCallCount());
    //		ResourceObjectShadowChangeDescription lastChange = mock.getLastChange();
    //		PrismObject<? extends ShadowType> currentShadow = lastChange.getCurrentShadow();
    //		assertNotNull("No current shadow in change notification", currentShadow);
    //		assertNotNull("No old shadow in change notification", lastChange.getOldShadow());
    //		
    //		assertEquals("Wrong shadow name", PrismTestUtil.createPolyStringType(ACCOUNT_CALYPSO_NAME), currentShadow.asObjectable().getName());
    //		
    //		assertNotNull("Calypso is not protected", currentShadow.asObjectable().isProtectedObject());
    //		assertTrue("Calypso is not protected", currentShadow.asObjectable().isProtectedObject());
    assertSyncToken(SYNC_TASK_OID, 2, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) SynchornizationServiceMock(com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) AddOperation(org.opends.server.core.AddOperation) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 9 with LDIFReader

use of org.opends.server.util.LDIFReader in project midpoint by Evolveum.

the class TestGenericSynchronization method createOrgEntry.

private Entry createOrgEntry(String ou, String suffix) throws IOException, LDIFException {
    StringBuilder sb = new StringBuilder();
    String dn = "ou=" + ou + "," + suffix;
    sb.append("dn: ").append(dn).append("\n");
    sb.append("objectClass: organizationalUnit\n");
    sb.append("ou: ").append(ou).append("\n");
    sb.append("description: ").append("This is sparta! ...or " + ou).append("\n");
    LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb.toString(), "utf-8"));
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry ldifEntry = ldifReader.readEntry();
    return ldifEntry;
}
Also used : Entry(org.opends.server.types.Entry) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader)

Example 10 with LDIFReader

use of org.opends.server.util.LDIFReader in project midpoint by Evolveum.

the class OpenDJController method addEntriesFromLdifFile.

public List<Entry> addEntriesFromLdifFile(String filename) throws IOException, LDIFException {
    List<Entry> retval = new ArrayList<>();
    LDIFImportConfig importConfig = new LDIFImportConfig(filename);
    LDIFReader ldifReader = new LDIFReader(importConfig);
    for (; ; ) {
        Entry ldifEntry = ldifReader.readEntry();
        if (ldifEntry == null) {
            break;
        }
        addEntry(ldifEntry);
        retval.add(ldifEntry);
    }
    return retval;
}
Also used : Entry(org.opends.server.types.Entry) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) ModifyChangeRecordEntry(org.opends.server.util.ModifyChangeRecordEntry) SearchResultEntry(org.opends.server.types.SearchResultEntry) ModifyDNChangeRecordEntry(org.opends.server.util.ModifyDNChangeRecordEntry) JarEntry(java.util.jar.JarEntry) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader) ArrayList(java.util.ArrayList)

Aggregations

LDIFImportConfig (org.opends.server.types.LDIFImportConfig)13 LDIFReader (org.opends.server.util.LDIFReader)13 Entry (org.opends.server.types.Entry)10 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)6 ModifyChangeRecordEntry (org.opends.server.util.ModifyChangeRecordEntry)6 ModifyDNChangeRecordEntry (org.opends.server.util.ModifyDNChangeRecordEntry)6 JarEntry (java.util.jar.JarEntry)3 SearchResultEntry (org.opends.server.types.SearchResultEntry)3 SynchornizationServiceMock (com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock)2 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)2 AddOperation (org.opends.server.core.AddOperation)2 ModifyOperation (org.opends.server.core.ModifyOperation)2 Test (org.testng.annotations.Test)2 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 MessageBuilder (org.opends.messages.MessageBuilder)1