Search in sources :

Example 11 with LDIFModifyChangeRecord

use of com.unboundid.ldif.LDIFModifyChangeRecord in project ldapsdk by pingidentity.

the class ScrambleAttributeTransformationTestCase method testTransformModifyChangeRecord.

/**
 * Provides basic test coverage for the transformChangeRecord method for a
 * modify record.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTransformModifyChangeRecord() throws Exception {
    final Schema schema = Schema.getDefaultStandardSchema();
    final ScrambleAttributeTransformation t = new ScrambleAttributeTransformation(schema, 0L, true, Arrays.asList("uid", "ou"), null);
    final LDIFChangeRecord r = t.transformChangeRecord(new LDIFModifyChangeRecord(new ModifyRequest("dn: uid=user.1,ou=People,dc=example,dc=com", "changetype: modify", "add: uid", "uid: user.2", "-", "add: ou", "ou: foo", "-", "add: seeAlso", "seeAlso: uid=something,ou=something else,dc=example,dc=com")));
    assertNotNull(r);
}
Also used : LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) Schema(com.unboundid.ldap.sdk.schema.Schema) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) Test(org.testng.annotations.Test)

Example 12 with LDIFModifyChangeRecord

use of com.unboundid.ldif.LDIFModifyChangeRecord in project ldapsdk by pingidentity.

the class TransformLDIFTestCase method testExcludeRecordsWithoutChangeType.

/**
 * Tests the ability to exclude LDIF records without change types.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeRecordsWithoutChangeType() throws Exception {
    // Create the LDIF file to process.
    final File sourceLDIFFile = createTempFile("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example", "", "dn: ou=People,dc=example,dc=com", "changetype: add", "objectClass: top", "objectClass: organizationalUnit", "ou: People", "", "dn: ou=People,dc=example,dc=com", "changetype: modify", "add: description", "description: foo", "", "dn: ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: ou=Users", "deleteoldrdn: 1", "", "dn: ou=Users,dc=example,dc=com", "changetype: delete");
    final File outputFile = runTool("--sourceLDIF", sourceLDIFFile.getAbsolutePath(), "--excludeRecordsWithoutChangeType");
    final LDIFReader reader = new LDIFReader(outputFile);
    LDIFRecord r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof LDIFAddChangeRecord);
    r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof LDIFModifyChangeRecord);
    r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof LDIFModifyDNChangeRecord);
    r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof LDIFDeleteChangeRecord);
    assertNull(reader.readEntry());
    reader.close();
}
Also used : LDIFRecord(com.unboundid.ldif.LDIFRecord) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) LDIFReader(com.unboundid.ldif.LDIFReader) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) File(java.io.File) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 13 with LDIFModifyChangeRecord

use of com.unboundid.ldif.LDIFModifyChangeRecord in project ldapsdk by pingidentity.

the class TransformLDIFTestCase method testLargeChangeRecordFile.

/**
 * Tests the behavior with a file with a large number of LDIF change records.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testLargeChangeRecordFile() throws Exception {
    final File sourceLDIFFile = createTempFile();
    assertTrue(sourceLDIFFile.delete());
    final PrintStream w = new PrintStream(sourceLDIFFile);
    for (int i = 1; i <= 2500; i++) {
        w.println("dn: uid=user." + i + ",ou=People,dc=example,dc=com");
        w.println("changetype: modify");
        w.println("replace: description");
        w.println("description: foo");
        w.println();
    }
    w.close();
    final File targetLDIFFile = runTool("--sourceLDIF", sourceLDIFFile.getAbsolutePath(), "--sourceContainsChangeRecords", "--redactAttribute", "description", "--numThreads", "10");
    final LDIFReader reader = new LDIFReader(targetLDIFFile);
    int readCount = 0;
    while (true) {
        final LDIFChangeRecord r = reader.readChangeRecord();
        if (r == null) {
            break;
        }
        readCount++;
        assertTrue(r instanceof LDIFModifyChangeRecord);
    }
    reader.close();
    assertEquals(readCount, 2500);
}
Also used : PrintStream(java.io.PrintStream) LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) LDIFReader(com.unboundid.ldif.LDIFReader) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) File(java.io.File) Test(org.testng.annotations.Test)

Example 14 with LDIFModifyChangeRecord

use of com.unboundid.ldif.LDIFModifyChangeRecord in project ldapsdk by pingidentity.

the class TransformLDIFTestCase method testExcludeChangeType.

/**
 * Tests the ability to exclude LDIF records with a specified set of change
 * types.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeChangeType() throws Exception {
    // Create the LDIF file to process.
    final File sourceLDIFFile = createTempFile("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example", "", "dn: ou=People,dc=example,dc=com", "changetype: add", "objectClass: top", "objectClass: organizationalUnit", "ou: People", "", "dn: ou=People,dc=example,dc=com", "changetype: modify", "add: description", "description: foo", "", "dn: ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: ou=Users", "deleteoldrdn: 1", "", "dn: ou=Users,dc=example,dc=com", "changetype: delete");
    final File outputFile = runTool("--sourceLDIF", sourceLDIFFile.getAbsolutePath(), "--excludeChangeType", "add", "--excludeChangeType", "delete");
    final LDIFReader reader = new LDIFReader(outputFile);
    LDIFRecord r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof Entry);
    r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof LDIFModifyChangeRecord);
    r = reader.readLDIFRecord();
    assertNotNull(r);
    assertTrue(r instanceof LDIFModifyDNChangeRecord);
    assertNull(reader.readEntry());
    reader.close();
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) LDIFRecord(com.unboundid.ldif.LDIFRecord) LDIFReader(com.unboundid.ldif.LDIFReader) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) File(java.io.File) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 15 with LDIFModifyChangeRecord

use of com.unboundid.ldif.LDIFModifyChangeRecord in project ldapsdk by pingidentity.

the class RedactAttributeTransformationTestCase method testTransformModifyChangeRecordProcessDNsFalsePreserveCountFalse.

/**
 * Provides test coverage for the transformChangeRecord method for a modify
 * record with both processDNs and preserveValueCount arguments set to false.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTransformModifyChangeRecordProcessDNsFalsePreserveCountFalse() throws Exception {
    final Schema schema = Schema.getDefaultStandardSchema();
    final RedactAttributeTransformation t = new RedactAttributeTransformation(schema, false, false, "description", "displayName", "cn", "ou");
    final LDIFChangeRecord r = t.transformChangeRecord(new LDIFModifyChangeRecord(new ModifyRequest("dn: cn=Test,ou=People,dc=example,dc=com", "changetype: modify", "add: description", "description: First value", "description: Second value", "-", "replace: seeAlso", "seeAlso: uid=test,ou=People,dc=example,dc=com")));
    assertNotNull(r);
    assertEquals(r, new LDIFModifyChangeRecord(new ModifyRequest("dn: cn=Test,ou=People,dc=example,dc=com", "changetype: modify", "add: description", "description: ***REDACTED***", "-", "replace: seeAlso", "seeAlso: uid=test,ou=People,dc=example,dc=com")));
}
Also used : LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) Schema(com.unboundid.ldap.sdk.schema.Schema) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) Test(org.testng.annotations.Test)

Aggregations

LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)60 Test (org.testng.annotations.Test)40 Modification (com.unboundid.ldap.sdk.Modification)24 LDIFChangeRecord (com.unboundid.ldif.LDIFChangeRecord)23 LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)20 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)19 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)18 LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)18 Entry (com.unboundid.ldap.sdk.Entry)17 DN (com.unboundid.ldap.sdk.DN)15 File (java.io.File)11 Attribute (com.unboundid.ldap.sdk.Attribute)9 NotNull (com.unboundid.util.NotNull)9 LDAPException (com.unboundid.ldap.sdk.LDAPException)8 ArrayList (java.util.ArrayList)8 Calendar (java.util.Calendar)8 GregorianCalendar (java.util.GregorianCalendar)8 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)7 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)7 Nullable (com.unboundid.util.Nullable)7