use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithNonRevertibleModifications.
/**
* Tests the behavior for a modify DN audit log message that cannot be
* reverted because the message includes non-revertible modifications.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageWithNonRevertibleModifications() throws Exception {
final ModifyDNAuditLogMessage m = new ModifyDNAuditLogMessage("# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1", "# ModifyDN attribute modifications (count=1)", "# replace: uid", "# uid: john.doe", "dn: uid=jdoe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: uid=john.doe", "deleteoldrdn: 1");
assertNotNull(m.getLogMessageLines());
assertFalse(m.getLogMessageLines().isEmpty());
assertNotNull(m.getCommentedHeaderLine());
assertEquals(m.getCommentedHeaderLine(), "# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1");
assertNotNull(m.getUncommentedHeaderLine());
assertEquals(m.getUncommentedHeaderLine(), "27/Aug/2018:16:33:47.019 -0500; conn=31; op=1");
assertNotNull(m.getTimestamp());
final Calendar calendar = new GregorianCalendar();
calendar.setTime(m.getTimestamp());
assertEquals(calendar.get(Calendar.YEAR), 2018);
assertEquals(calendar.get(Calendar.MONTH), Calendar.AUGUST);
assertNotNull(m.getHeaderNamedValues());
assertFalse(m.getHeaderNamedValues().isEmpty());
assertTrue(m.getHeaderNamedValues().containsKey("conn"));
assertNull(m.getProductName());
assertNull(m.getInstanceName());
assertNull(m.getStartupID());
assertNull(m.getThreadID());
assertNull(m.getRequesterDN());
assertNull(m.getRequesterIPAddress());
assertNotNull(m.getConnectionID());
assertEquals(m.getConnectionID().longValue(), 31L);
assertNotNull(m.getOperationID());
assertEquals(m.getOperationID().longValue(), 1L);
assertNull(m.getTriggeredByConnectionID());
assertNull(m.getTriggeredByOperationID());
assertNull(m.getReplicationChangeID());
assertNull(m.getAlternateAuthorizationDN());
assertNull(m.getTransactionID());
assertNull(m.getOrigin());
assertNull(m.getUsingAdminSessionWorkerThread());
assertNull(m.getRequestControlOIDs());
assertNull(m.getOperationPurposeRequestControl());
assertNull(m.getIntermediateClientRequestControl());
assertNotNull(m.getDN());
assertEquals(m.getDN(), "uid=jdoe,ou=People,dc=example,dc=com");
assertNotNull(m.getNewRDN());
assertDNsEqual(m.getNewRDN(), "uid=john.doe");
assertTrue(m.deleteOldRDN());
assertNull(m.getNewSuperiorDN());
assertNotNull(m.getAttributeModifications());
assertEquals(m.getAttributeModifications(), Collections.singletonList(new Modification(ModificationType.REPLACE, "uid", "john.doe")));
assertNotNull(m.getChangeType());
assertEquals(m.getChangeType(), ChangeType.MODIFY_DN);
assertNotNull(m.getChangeRecord());
assertTrue(m.getChangeRecord() instanceof LDIFModifyDNChangeRecord);
assertFalse(m.isRevertible());
try {
m.getRevertChangeRecords();
fail("Expected an exception when trying to revert a non-revertible " + "modify DN audit log message");
} catch (final AuditLogException e) {
// This was expected.
}
assertNotNull(m.toString());
assertNotNull(m.toMultiLineString());
}
use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithoutNewSuperior.
/**
* Tests the behavior for a revertible modify DN audit log message that does
* not have a new superior DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageWithoutNewSuperior() throws Exception {
final ModifyDNAuditLogMessage m = new ModifyDNAuditLogMessage("# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4Rt1g==; threadID=8; " + "clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001657D4E9677214B00000005\"; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"; " + "requestControlOIDs=\"1.3.6.1.4.1.30221.2.5.2\"; " + "intermediateClientRequestControl={ " + "\"clientIdentity\":\"dn:cn=Directory Manager,cn=Root " + "DNs,cn=config\", \"downstreamClientAddress\":\"127.0.0.1\", " + "\"downstreamClientSecure\":false, " + "\"clientName\":\"PingDirectory\", " + "\"clientSessionID\":\"conn=8\", \"clientRequestID\":\"op=5\", " + "\"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# ModifyDN attribute modifications (count=2)", "# delete: uid", "# uid: jdoe", "# -", "# add: uid", "# uid: john.doe", "dn: uid=jdoe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: uid=john.doe", "deleteoldrdn: 1");
assertNotNull(m.getLogMessageLines());
assertFalse(m.getLogMessageLines().isEmpty());
assertNotNull(m.getCommentedHeaderLine());
assertTrue(m.getCommentedHeaderLine().startsWith("# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1; "));
assertNotNull(m.getUncommentedHeaderLine());
assertTrue(m.getUncommentedHeaderLine().startsWith("27/Aug/2018:16:33:47.019 -0500; conn=31; op=1; "));
assertNotNull(m.getTimestamp());
final Calendar calendar = new GregorianCalendar();
calendar.setTime(m.getTimestamp());
assertEquals(calendar.get(Calendar.YEAR), 2018);
assertEquals(calendar.get(Calendar.MONTH), Calendar.AUGUST);
assertNotNull(m.getHeaderNamedValues());
assertFalse(m.getHeaderNamedValues().isEmpty());
assertTrue(m.getHeaderNamedValues().containsKey("conn"));
assertNotNull(m.getProductName());
assertEquals(m.getProductName(), "Directory Server");
assertNotNull(m.getInstanceName());
assertEquals(m.getInstanceName(), "ReplicaOne");
assertNotNull(m.getStartupID());
assertEquals(m.getStartupID(), "W4Rt1g==");
assertNotNull(m.getThreadID());
assertEquals(m.getThreadID().longValue(), 8L);
assertNotNull(m.getRequesterDN());
assertDNsEqual(m.getRequesterDN(), "cn=Proxy User,cn=Root DNs,cn=config");
assertNotNull(m.getRequesterIPAddress());
assertEquals(m.getRequesterIPAddress(), "127.0.0.1");
assertNotNull(m.getConnectionID());
assertEquals(m.getConnectionID().longValue(), 31L);
assertNotNull(m.getOperationID());
assertEquals(m.getOperationID().longValue(), 1L);
assertNull(m.getTriggeredByConnectionID());
assertNull(m.getTriggeredByOperationID());
assertNotNull(m.getReplicationChangeID());
assertEquals(m.getReplicationChangeID(), "000001657D4E9677214B00000005");
assertNotNull(m.getAlternateAuthorizationDN());
assertDNsEqual(m.getAlternateAuthorizationDN(), "cn=Directory Manager,cn=Root DNs,cn=config");
assertNull(m.getTransactionID());
assertNull(m.getOrigin());
assertNull(m.getUsingAdminSessionWorkerThread());
assertNotNull(m.getRequestControlOIDs());
assertEquals(m.getRequestControlOIDs(), Collections.singletonList("1.3.6.1.4.1.30221.2.5.2"));
assertNull(m.getOperationPurposeRequestControl());
assertNotNull(m.getIntermediateClientRequestControl());
assertNotNull(m.getDN());
assertDNsEqual(m.getDN(), "uid=jdoe,ou=People,dc=example,dc=com");
assertNotNull(m.getNewRDN());
assertDNsEqual(m.getNewRDN(), "uid=john.doe");
assertTrue(m.deleteOldRDN());
assertNull(m.getNewSuperiorDN());
assertNotNull(m.getAttributeModifications());
assertEquals(m.getAttributeModifications(), Arrays.asList(new Modification(ModificationType.DELETE, "uid", "jdoe"), new Modification(ModificationType.ADD, "uid", "john.doe")));
assertNotNull(m.getChangeType());
assertEquals(m.getChangeType(), ChangeType.MODIFY_DN);
assertNotNull(m.getChangeRecord());
assertTrue(m.getChangeRecord() instanceof LDIFModifyDNChangeRecord);
assertTrue(m.isRevertible());
final List<LDIFChangeRecord> revertChangeRecords = m.getRevertChangeRecords();
assertNotNull(revertChangeRecords);
assertFalse(revertChangeRecords.isEmpty());
assertEquals(revertChangeRecords.size(), 1);
assertTrue(revertChangeRecords.get(0) instanceof LDIFModifyDNChangeRecord);
final LDIFModifyDNChangeRecord revertChangeRecord = (LDIFModifyDNChangeRecord) revertChangeRecords.get(0);
assertDNsEqual(revertChangeRecord.getDN(), "uid=john.doe,ou=People,dc=example,dc=com");
assertDNsEqual(revertChangeRecord.getNewRDN(), "uid=jdoe");
assertTrue(revertChangeRecord.deleteOldRDN());
assertNull(revertChangeRecord.getNewSuperiorDN());
assertNotNull(m.toString());
assertNotNull(m.toMultiLineString());
}
use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithCurrentDNIsNullDN.
/**
* Tests the behavior for a modify DN audit log message that cannot be
* reverted because the current DN is the null DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageWithCurrentDNIsNullDN() throws Exception {
final ModifyDNAuditLogMessage m = new ModifyDNAuditLogMessage("# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1", "# ModifyDN attribute modifications (count=0)", "dn: ", "changetype: moddn", "newrdn: uid=john.doe", "deleteoldrdn: 0", "newsuperior: ou=People,dc=example,dc=com");
assertNotNull(m.getLogMessageLines());
assertFalse(m.getLogMessageLines().isEmpty());
assertNotNull(m.getCommentedHeaderLine());
assertEquals(m.getCommentedHeaderLine(), "# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1");
assertNotNull(m.getUncommentedHeaderLine());
assertEquals(m.getUncommentedHeaderLine(), "27/Aug/2018:16:33:47.019 -0500; conn=31; op=1");
assertNotNull(m.getTimestamp());
final Calendar calendar = new GregorianCalendar();
calendar.setTime(m.getTimestamp());
assertEquals(calendar.get(Calendar.YEAR), 2018);
assertEquals(calendar.get(Calendar.MONTH), Calendar.AUGUST);
assertNotNull(m.getHeaderNamedValues());
assertFalse(m.getHeaderNamedValues().isEmpty());
assertTrue(m.getHeaderNamedValues().containsKey("conn"));
assertNull(m.getProductName());
assertNull(m.getInstanceName());
assertNull(m.getStartupID());
assertNull(m.getThreadID());
assertNull(m.getRequesterDN());
assertNull(m.getRequesterIPAddress());
assertNotNull(m.getConnectionID());
assertEquals(m.getConnectionID().longValue(), 31L);
assertNotNull(m.getOperationID());
assertEquals(m.getOperationID().longValue(), 1L);
assertNull(m.getTriggeredByConnectionID());
assertNull(m.getTriggeredByOperationID());
assertNull(m.getReplicationChangeID());
assertNull(m.getAlternateAuthorizationDN());
assertNull(m.getTransactionID());
assertNull(m.getOrigin());
assertNull(m.getUsingAdminSessionWorkerThread());
assertNull(m.getRequestControlOIDs());
assertNull(m.getOperationPurposeRequestControl());
assertNull(m.getIntermediateClientRequestControl());
assertNotNull(m.getDN());
assertEquals(m.getDN(), "");
assertNotNull(m.getNewRDN());
assertDNsEqual(m.getNewRDN(), "uid=john.doe");
assertFalse(m.deleteOldRDN());
assertNotNull(m.getNewSuperiorDN());
assertDNsEqual(m.getNewSuperiorDN(), "ou=People,dc=example,dc=com");
assertNotNull(m.getAttributeModifications());
assertTrue(m.getAttributeModifications().isEmpty());
assertNotNull(m.getChangeType());
assertEquals(m.getChangeType(), ChangeType.MODIFY_DN);
assertNotNull(m.getChangeRecord());
assertTrue(m.getChangeRecord() instanceof LDIFModifyDNChangeRecord);
assertFalse(m.isRevertible());
try {
m.getRevertChangeRecords();
fail("Expected an exception when trying to revert a non-revertible " + "modify DN audit log message");
} catch (final AuditLogException e) {
// This was expected.
}
assertNotNull(m.toString());
assertNotNull(m.toMultiLineString());
}
use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class UnboundIDChangeLogEntryTestCase method testExtendedModifyDNChangeLogEntry.
/**
* Provides coverage for cases in which an UnboundID changelog entry is
* created for a modify DN operation an extended set of content.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testExtendedModifyDNChangeLogEntry() throws Exception {
final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyDNChangeRecord("uid=test.1,ou=People,dc=example,dc=com", "uid=test.2", true, "ou=Users,o=example.com"));
assertNotNull(e);
// Construct before values for the uid attribute.
final StringBuilder beforeBuffer = new StringBuilder();
beforeBuffer.append("uid: test.1");
beforeBuffer.append(StaticUtils.EOL);
// Construct after values for the uid attribute.
final StringBuilder afterBuffer = new StringBuilder();
afterBuffer.append("uid: test.2");
afterBuffer.append(StaticUtils.EOL);
// Construct a key attribute value for the "cn" attribute.
final StringBuilder keyAttrBuffer = new StringBuilder();
keyAttrBuffer.append("cn: Test User");
keyAttrBuffer.append(StaticUtils.EOL);
final Entry extendedEntry = e.duplicate();
extendedEntry.addAttribute("ds-changelog-before-values", beforeBuffer.toString());
extendedEntry.addAttribute("ds-changelog-after-values", afterBuffer.toString());
extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
extendedEntry.addAttribute("ds-changelog-num-excluded-operational-attributes", "2");
extendedEntry.addAttribute("ds-changelog-excluded-operational-attribute", "modifiersName", "modifyTimestamp");
extendedEntry.addAttribute("targetUniqueID", "468c6887-4fcc-38ea-9425-abcaa3c88be6");
extendedEntry.addAttribute("localCSN", "00000131EDEDD535000000000006");
extendedEntry.addAttribute("changeTime", "20110821200012Z");
extendedEntry.addAttribute("ds-changelog-target-attribute", "uid");
extendedEntry.addAttribute("ds-notification-destination-entry-uuid", "12345678-90ab-cdef-1234-567890abcdef", "23456789-0abC-def1-2345-67890abcdef1");
extendedEntry.addAttribute("ds-changelog-notification-properties", "notification-property-1", "notification-property-2", "notification-property-3");
final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(extendedEntry);
assertNotNull(ue);
assertEquals(ue.getChangeNumber(), 4L);
assertNotNull(ue.getTargetDN());
assertEquals(new DN(ue.getTargetDN()), new DN("uid=test.1,ou=People,dc=example,dc=com"));
assertNotNull(ue.getChangeType());
assertEquals(ue.getChangeType(), ChangeType.MODIFY_DN);
assertNull(ue.getAddAttributes());
assertNull(ue.getDeletedEntryAttributes());
assertNull(ue.getModifications());
assertNotNull(ue.getNewRDN());
assertEquals(new RDN(ue.getNewRDN()), new RDN("uid=test.2"));
assertTrue(ue.deleteOldRDN());
assertNotNull(ue.getNewSuperior());
assertEquals(new DN(ue.getNewSuperior()), new DN("ou=Users,o=example.com"));
assertNull(ue.getSoftDeleteToDN());
assertNull(ue.getUndeleteFromDN());
assertNull(ue.getChangeToSoftDeletedEntry());
assertNotNull(ue.getNewDN());
assertEquals(new DN(ue.getNewDN()), new DN("uid=test.2,ou=Users,o=example.com"));
assertNotNull(ue.getUpdatedAttributesBeforeChange());
assertEquals(ue.getUpdatedAttributesBeforeChange().size(), 1);
assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("uid", "test.1")));
assertNotNull(ue.getUpdatedAttributesAfterChange());
assertEquals(ue.getUpdatedAttributesAfterChange().size(), 1);
assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("uid", "test.2")));
assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
assertTrue(ue.getAttributesThatExceededMaxValuesCount().isEmpty());
assertNotNull(ue.getKeyEntryAttributes());
assertEquals(ue.getKeyEntryAttributes().size(), 1);
assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test User")));
assertEquals(ue.getNumExcludedUserAttributes(), -1);
assertEquals(ue.getNumExcludedOperationalAttributes(), 2);
assertNotNull(ue.getExcludedUserAttributeNames());
assertTrue(ue.getExcludedUserAttributeNames().isEmpty());
assertNotNull(ue.getExcludedOperationalAttributeNames());
assertFalse(ue.getExcludedOperationalAttributeNames().isEmpty());
assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifiersName"));
assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifyTimestamp"));
assertNotNull(ue.getAttributeBeforeChange("uid"));
assertEquals(ue.getAttributeBeforeChange("uid"), new Attribute("uid", "test.1"));
assertNotNull(ue.getAttributeBeforeChange("cn"));
assertEquals(ue.getAttributeBeforeChange("cn"), new Attribute("cn", "Test User"));
assertNull(ue.getAttributeBeforeChange("description"));
assertNotNull(ue.getAttributeAfterChange("uid"));
assertEquals(ue.getAttributeAfterChange("uid"), new Attribute("uid", "test.2"));
assertNotNull(ue.getAttributeAfterChange("cn"));
assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test User"));
assertNull(ue.getAttributeAfterChange("description"));
assertNotNull(ue.constructPartialEntryBeforeChange());
assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: uid=test.1,ou=People,dc=example,dc=com", "uid: test.1", "cn: Test User"));
assertNotNull(ue.constructPartialEntryAfterChange());
assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: uid=test.2,ou=Users,o=example.com", "uid: test.2", "cn: Test User"));
assertNotNull(ue.getTargetUniqueID());
assertEquals(ue.getTargetUniqueID(), "468c6887-4fcc-38ea-9425-abcaa3c88be6");
assertNotNull(ue.getLocalCSN());
assertEquals(ue.getLocalCSN(), "00000131EDEDD535000000000006");
assertNotNull(ue.getChangeTime());
assertEquals(ue.getChangeTime().getTime(), StaticUtils.decodeGeneralizedTime("20110821200012Z").getTime());
assertNotNull(ue.getTargetAttributeNames());
assertFalse(ue.getTargetAttributeNames().isEmpty());
assertEquals(ue.getTargetAttributeNames().size(), 1);
assertNotNull(ue.getNotificationDestinationEntryUUIDs());
assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
assertNotNull(ue.getNotificationProperties());
assertFalse(ue.getNotificationProperties().isEmpty());
assertEquals(ue.getNotificationProperties().size(), 3);
}
use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class ScrambleAttributeTransformationTestCase method testTransformModifyDNChangeRecord.
/**
* Provides basic test coverage for the transformChangeRecord method for a
* modify DN record.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testTransformModifyDNChangeRecord() 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 LDIFModifyDNChangeRecord("uid=user.1,ou=People,dc=example,dc=com", "uid=user.2", true, "ou=Users,dc=example,dc=com"));
assertNotNull(r);
}
Aggregations