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);
}
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();
}
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);
}
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();
}
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")));
}
Aggregations