use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageNotRevertibleMissingMods.
/**
* Tests the behavior for a modify DN audit log message that is not revertible
* because there are no modifications and deleteOldRDN is true.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageNotRevertibleMissingMods() throws Exception {
final ModifyDNAuditLogMessage m = new ModifyDNAuditLogMessage(Arrays.asList("# 27/Aug/2018:16:33:47.019 -0500; conn=31; op=1", "dn: uid=jdoe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: uid=john.doe", "deleteoldrdn: 1"), new LDIFModifyDNChangeRecord("uid=jdoe,ou=People,dc=example,dc=com", "uid=john.doe", true, null));
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());
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());
assertNull(m.getAttributeModifications());
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 testModifyAuditLogMessageWithoutNecessaryModifications.
/**
* Tests the behavior for a modify DN audit log message that cannot be
* reverted because the message doesn't include modifications, delete old RDN
* is true, and the new RDN is not the same as the old RDN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageWithoutNecessaryModifications() 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: 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());
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 ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithMalformedCurrentDN.
/**
* Tests the behavior for a modify DN audit log message that cannot be
* reverted because it has a malformed current DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageWithMalformedCurrentDN() 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: malformed", "changetype: moddn", "newrdn: uid=john.doe", "deleteoldrdn: 0");
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(), "malformed");
assertNotNull(m.getNewRDN());
assertDNsEqual(m.getNewRDN(), "uid=john.doe");
assertFalse(m.deleteOldRDN());
assertNull(m.getNewSuperiorDN());
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 ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithNewSuperior.
/**
* 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 testModifyAuditLogMessageWithNewSuperior() throws Exception {
final ModifyDNAuditLogMessage m = new ModifyDNAuditLogMessage(Arrays.asList("# 27/Aug/2018:16:33:47.033 -0500; conn=32; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4Rt1g==; threadID=9; " + "clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001657D4E968C214B00000006\"; " + "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=6\", " + "\"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# ModifyDN attribute modifications (count=0)", "dn: uid=john.doe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: uid=john.doe", "deleteoldrdn: 1", "newsuperior: ou=Users,dc=example,dc=com"));
assertNotNull(m.getLogMessageLines());
assertFalse(m.getLogMessageLines().isEmpty());
assertNotNull(m.getCommentedHeaderLine());
assertTrue(m.getCommentedHeaderLine().startsWith("# 27/Aug/2018:16:33:47.033 -0500; conn=32; op=1; "));
assertNotNull(m.getUncommentedHeaderLine());
assertTrue(m.getUncommentedHeaderLine().startsWith("27/Aug/2018:16:33:47.033 -0500; conn=32; 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(), 9L);
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(), 32L);
assertNotNull(m.getOperationID());
assertEquals(m.getOperationID().longValue(), 1L);
assertNull(m.getTriggeredByConnectionID());
assertNull(m.getTriggeredByOperationID());
assertNotNull(m.getReplicationChangeID());
assertEquals(m.getReplicationChangeID(), "000001657D4E968C214B00000006");
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=john.doe,ou=People,dc=example,dc=com");
assertNotNull(m.getNewRDN());
assertDNsEqual(m.getNewRDN(), "uid=john.doe");
assertTrue(m.deleteOldRDN());
assertNotNull(m.getNewSuperiorDN());
assertDNsEqual(m.getNewSuperiorDN(), "ou=Users,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);
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=Users,dc=example,dc=com");
assertDNsEqual(revertChangeRecord.getNewRDN(), "uid=john.doe");
assertFalse(revertChangeRecord.deleteOldRDN());
assertDNsEqual(revertChangeRecord.getNewSuperiorDN(), "ou=People,dc=Example,dc=com");
assertNotNull(m.toString());
assertNotNull(m.toMultiLineString());
}
use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.
the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithMalformedNewSuperior.
/**
* Tests the behavior for a modify DN audit log message that cannot be
* reverted because it has a malformed new superior DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyAuditLogMessageWithMalformedNewSuperior() 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: uid=jdoe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: uid=jdoe", "deleteoldrdn: 0", "newsuperior: malformed");
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());
assertDNsEqual(m.getDN(), "uid=jdoe,ou=People,dc=example,dc=com");
assertNotNull(m.getNewRDN());
assertDNsEqual(m.getNewRDN(), "uid=jdoe");
assertFalse(m.deleteOldRDN());
assertNotNull(m.getNewSuperiorDN());
assertEquals(m.getNewSuperiorDN(), "malformed");
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());
}
Aggregations