Search in sources :

Example 21 with LDIFDeleteChangeRecord

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

the class AddAuditLogMessageTestCase method testUndeleteAuditLogMessage.

/**
 * Tests the behavior for an add audit log message that describes an undelete
 * operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testUndeleteAuditLogMessage() throws Exception {
    final AddAuditLogMessage m = new AddAuditLogMessage("# 24/Aug/2018:12:11:51.006 -0500; conn=56; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4A77w==; threadID=14; " + "clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001656CEBB3D55DE30000000D\"; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"; " + "isUndelete=true; " + "requestControlOIDs=\"1.3.6.1.4.1.30221.2.5.23," + "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=9\", \"clientRequestID\":\"op=3\", " + "\"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# Undelete request entry", "# dn: ou=People,dc=example,dc=com", "# ds-undelete-from-dn: " + "entryUUID=b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38+ou=People," + "dc=example,dc=com", "dn: ou=People,dc=example,dc=com", "changetype: add", "objectClass: top", "objectClass: organizationalUnit", "ou: People", "createTimestamp: 20180824171150.975Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180824171150.975Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: d7fc4a73-3338-4a99-b26e-9e971297445e");
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertFalse(m.getUncommentedHeaderLine().isEmpty());
    assertFalse(m.getUncommentedHeaderLine().startsWith("# "));
    assertEquals(m.getUncommentedHeaderLine(), m.getCommentedHeaderLine().substring(2));
    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());
    assertNotNull(m.getProductName());
    assertEquals(m.getProductName(), "Directory Server");
    assertNotNull(m.getInstanceName());
    assertEquals(m.getInstanceName(), "ReplicaOne");
    assertNotNull(m.getStartupID());
    assertEquals(m.getStartupID(), "W4A77w==");
    assertNotNull(m.getThreadID());
    assertEquals(m.getThreadID().longValue(), 14L);
    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(), 56L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001656CEBB3D55DE30000000D");
    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());
    assertFalse(m.getRequestControlOIDs().isEmpty());
    assertEquals(m.getRequestControlOIDs(), Arrays.asList("1.3.6.1.4.1.30221.2.5.23", "1.3.6.1.4.1.30221.2.5.2"));
    assertNull(m.getOperationPurposeRequestControl());
    assertNotNull(m.getIntermediateClientRequestControl());
    assertNotNull(m.getDN());
    assertDNsEqual(m.getDN(), "ou=People,dc=example,dc=com");
    assertNotNull(m.getEntry());
    assertNotNull(m.getIsUndelete());
    assertTrue(m.getIsUndelete());
    assertNotNull(m.getUndeleteRequestEntry());
    assertEquals(m.getUndeleteRequestEntry(), new ReadOnlyEntry("dn: ou=People,dc=example,dc=com", "ds-undelete-from-dn: " + "entryUUID=b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38+ou=People," + "dc=example,dc=com"));
    assertNotNull(m.getChangeType());
    assertEquals(m.getChangeType(), ChangeType.ADD);
    assertNotNull(m.getChangeRecord());
    assertTrue(m.getChangeRecord() instanceof LDIFAddChangeRecord);
    assertTrue(m.isRevertible());
    assertNotNull(m.getRevertChangeRecords());
    assertFalse(m.getRevertChangeRecords().isEmpty());
    assertEquals(m.getRevertChangeRecords().size(), 1);
    assertTrue(m.getRevertChangeRecords().get(0) instanceof LDIFDeleteChangeRecord);
    final LDIFDeleteChangeRecord revertChangeRecord = (LDIFDeleteChangeRecord) m.getRevertChangeRecords().get(0);
    assertDNsEqual(revertChangeRecord.getDN(), "ou=People,dc=example,dc=com");
    assertNotNull(revertChangeRecord.getControls());
    assertFalse(revertChangeRecord.getControls().isEmpty());
    final SoftDeleteRequestControl softDeleteRequestControl = (SoftDeleteRequestControl) revertChangeRecord.toDeleteRequest().getControl(SoftDeleteRequestControl.SOFT_DELETE_REQUEST_OID);
    assertNotNull(softDeleteRequestControl);
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : ReadOnlyEntry(com.unboundid.ldap.sdk.ReadOnlyEntry) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) SoftDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl) GregorianCalendar(java.util.GregorianCalendar) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Example 22 with LDIFDeleteChangeRecord

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

the class AddAuditLogMessageTestCase method testBasicLogMessageFromList.

/**
 * Tests the behavior for a basic add audit log message read from a list of
 * strings.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBasicLogMessageFromList() throws Exception {
    final AddAuditLogMessage m = new AddAuditLogMessage(Arrays.asList("# 23/Aug/2018:14:02:40 -0500; conn=28; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"", "dn: ou=People,dc=example,dc=com", "changetype: add", "objectClass: top", "objectClass: organizationalUnit", "ou: People", "createTimestamp: 20180823190240.967Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180823190240.967Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: b58849bd-2032-4077-ba10-2cd9be8166e0"));
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertFalse(m.getUncommentedHeaderLine().isEmpty());
    assertFalse(m.getUncommentedHeaderLine().startsWith("# "));
    assertEquals(m.getUncommentedHeaderLine(), m.getCommentedHeaderLine().substring(2));
    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(), 28L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNull(m.getReplicationChangeID());
    assertNotNull(m.getAlternateAuthorizationDN());
    assertDNsEqual(m.getAlternateAuthorizationDN(), "cn=Directory Manager,cn=Root DNs,cn=config");
    assertNull(m.getTransactionID());
    assertNull(m.getOrigin());
    assertNull(m.getUsingAdminSessionWorkerThread());
    assertNull(m.getRequestControlOIDs());
    assertNull(m.getOperationPurposeRequestControl());
    assertNull(m.getIntermediateClientRequestControl());
    assertNotNull(m.getDN());
    assertDNsEqual(m.getDN(), "ou=People,dc=example,dc=com");
    assertNotNull(m.getEntry());
    assertNull(m.getIsUndelete());
    assertNotNull(m.getChangeType());
    assertEquals(m.getChangeType(), ChangeType.ADD);
    assertNotNull(m.getChangeRecord());
    assertTrue(m.getChangeRecord() instanceof LDIFAddChangeRecord);
    assertTrue(m.isRevertible());
    assertNotNull(m.getRevertChangeRecords());
    assertFalse(m.getRevertChangeRecords().isEmpty());
    assertEquals(m.getRevertChangeRecords().size(), 1);
    assertTrue(m.getRevertChangeRecords().get(0) instanceof LDIFDeleteChangeRecord);
    final LDIFDeleteChangeRecord revertChangeRecord = (LDIFDeleteChangeRecord) m.getRevertChangeRecords().get(0);
    assertDNsEqual(revertChangeRecord.getDN(), "ou=People,dc=example,dc=com");
    assertNotNull(revertChangeRecord.getControls());
    assertTrue(revertChangeRecord.getControls().isEmpty());
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Example 23 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testBaseOfSubtreeDeleteWithDeletedEntry.

/**
 * Tests the behavior for a reversible delete audit log message that reflects
 * the deletion of the base entry for a subtree delete operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBaseOfSubtreeDeleteWithDeletedEntry() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage("# 24/Aug/2018:15:07:59.457 -0500; conn=59; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4BlNw==; " + "threadID=13; clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001656D8CF6C70D3F00000016\"; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"; " + "isSubtreeDelete=true; " + "requestControlOIDs=\"1.2.840.113556.1.4.805," + "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=10\", " + "\"clientRequestID\":\"op=7\", \"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# Deleted entry real attributes", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: People", "# createTimestamp: 20180824200759.380Z", "# creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "# modifyTimestamp: 20180824200759.380Z", "# modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "# entryUUID: 5f06efca-2796-4d2a-9b14-a543dbd322e0", "# Deleted entry virtual attributes", "# ds-entry-checksum: 419234829", "# subschemaSubentry: cn=schema", "dn: ou=People,dc=example,dc=com", "changetype: delete");
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# 24/Aug/2018:15:07:59.457 -0500; conn=59; op=1; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("24/Aug/2018:15:07:59.457 -0500; conn=59; 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(), "W4BlNw==");
    assertNotNull(m.getThreadID());
    assertEquals(m.getThreadID().longValue(), 13L);
    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(), 59L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001656D8CF6C70D3F00000016");
    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(), Arrays.asList("1.2.840.113556.1.4.805", "1.3.6.1.4.1.30221.2.5.2"));
    assertNull(m.getOperationPurposeRequestControl());
    assertNotNull(m.getIntermediateClientRequestControl());
    assertNotNull(m.getDN());
    assertDNsEqual(m.getDN(), "ou=People,dc=example,dc=com");
    assertNotNull(m.getIsSubtreeDelete());
    assertTrue(m.getIsSubtreeDelete());
    assertNull(m.getDeletedAsPartOfSubtreeDelete());
    assertNull(m.getIsSoftDelete());
    assertNull(m.getSoftDeletedEntryDN());
    assertNull(m.getIsSoftDeletedEntry());
    assertNotNull(m.getDeletedEntry());
    assertEquals(m.getDeletedEntry(), new ReadOnlyEntry("dn: ou=People,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: People", "createTimestamp: 20180824200759.380Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180824200759.380Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: 5f06efca-2796-4d2a-9b14-a543dbd322e0"));
    assertNotNull(m.getDeletedEntryVirtualAttributes());
    assertFalse(m.getDeletedEntryVirtualAttributes().isEmpty());
    assertEquals(m.getDeletedEntryVirtualAttributes(), Arrays.asList(new Attribute("ds-entry-checksum", "419234829"), new Attribute("subschemaSubentry", "cn=schema")));
    assertNotNull(m.getChangeType());
    assertEquals(m.getChangeType(), ChangeType.DELETE);
    assertNotNull(m.getChangeRecord());
    assertTrue(m.getChangeRecord() instanceof LDIFDeleteChangeRecord);
    assertFalse(m.isRevertible());
    try {
        m.getRevertChangeRecords();
        fail("Expected an exception because a subtree delete base entry is not " + "revertible.");
    } catch (final AuditLogException e) {
    // This was expected.
    }
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : ReadOnlyEntry(com.unboundid.ldap.sdk.ReadOnlyEntry) Attribute(com.unboundid.ldap.sdk.Attribute) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Example 24 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testBasicReversibleDeleteLogMessageFromList.

/**
 * Tests the behavior for a basic, reversible delete audit log message read
 * from a list of strings.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBasicReversibleDeleteLogMessageFromList() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage(Arrays.asList("# --- INCREMENTAL SIGNED CONTENT ---  " + "signature='p1WyKjniyWSaZVmuhNRhPI3v/wpzLmTTr04bnW4Drs4='", "# 24/Aug/2018:12:11:50.949 -0500; conn=-18; op=757; " + "origin=\"replication\"; productName=\"Directory Server\"; " + "instanceName=\"ReplicaTwo\"; startupID=W4A8Ew==; " + "threadID=232; clientIP=internal; " + "requesterDN=\"cn=Internal Client,cn=Internal,cn=Root " + "DNs,cn=config\"; " + "replicationChangeID=\"000001656CEBB3525DE300000007\"", "# Deleted entry real attributes", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: People", "# createTimestamp: 20180824200759.380Z", "# creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "# modifyTimestamp: 20180824200759.380Z", "# modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "# entryUUID: 5f06efca-2796-4d2a-9b14-a543dbd322e0", "# Deleted entry virtual attributes", "# ds-entry-checksum: 419234829", "# subschemaSubentry: cn=schema", "dn: ou=People,dc=example,dc=com", "changetype: delete"));
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# 24/Aug/2018:12:11:50.949 -0500; conn=-18; op=757; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("24/Aug/2018:12:11:50.949 -0500; conn=-18; op=757; "));
    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(), "ReplicaTwo");
    assertNotNull(m.getStartupID());
    assertEquals(m.getStartupID(), "W4A8Ew==");
    assertNotNull(m.getThreadID());
    assertEquals(m.getThreadID().longValue(), 232L);
    assertNotNull(m.getRequesterDN());
    assertDNsEqual(m.getRequesterDN(), "cn=Internal Client,cn=Internal,cn=Root DNs,cn=config");
    assertNotNull(m.getRequesterIPAddress());
    assertEquals(m.getRequesterIPAddress(), "internal");
    assertNotNull(m.getConnectionID());
    assertEquals(m.getConnectionID().longValue(), -18L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 757L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001656CEBB3525DE300000007");
    assertNull(m.getAlternateAuthorizationDN());
    assertNull(m.getTransactionID());
    assertNotNull(m.getOrigin());
    assertEquals(m.getOrigin(), "replication");
    assertNull(m.getUsingAdminSessionWorkerThread());
    assertNull(m.getRequestControlOIDs());
    assertNull(m.getOperationPurposeRequestControl());
    assertNull(m.getIntermediateClientRequestControl());
    assertNotNull(m.getDN());
    assertDNsEqual(m.getDN(), "ou=People,dc=example,dc=com");
    assertNull(m.getIsSubtreeDelete());
    assertNull(m.getDeletedAsPartOfSubtreeDelete());
    assertNull(m.getIsSoftDelete());
    assertNull(m.getSoftDeletedEntryDN());
    assertNull(m.getIsSoftDeletedEntry());
    assertNotNull(m.getDeletedEntry());
    assertEquals(m.getDeletedEntry(), new ReadOnlyEntry("dn: ou=People,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: People", "createTimestamp: 20180824200759.380Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180824200759.380Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: 5f06efca-2796-4d2a-9b14-a543dbd322e0"));
    assertNotNull(m.getDeletedEntryVirtualAttributes());
    assertFalse(m.getDeletedEntryVirtualAttributes().isEmpty());
    assertEquals(m.getDeletedEntryVirtualAttributes(), Arrays.asList(new Attribute("ds-entry-checksum", "419234829"), new Attribute("subschemaSubentry", "cn=schema")));
    assertNotNull(m.getChangeType());
    assertEquals(m.getChangeType(), ChangeType.DELETE);
    assertNotNull(m.getChangeRecord());
    assertTrue(m.getChangeRecord() instanceof LDIFDeleteChangeRecord);
    assertTrue(m.isRevertible());
    final List<LDIFChangeRecord> revertChangeRecords = m.getRevertChangeRecords();
    assertNotNull(revertChangeRecords);
    assertFalse(revertChangeRecords.isEmpty());
    assertEquals(revertChangeRecords.size(), 1);
    assertTrue(revertChangeRecords.get(0) instanceof LDIFAddChangeRecord);
    final LDIFAddChangeRecord revertChangeRecord = (LDIFAddChangeRecord) revertChangeRecords.get(0);
    assertEquals(revertChangeRecord.getEntryToAdd(), m.getDeletedEntry());
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : ReadOnlyEntry(com.unboundid.ldap.sdk.ReadOnlyEntry) LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) Attribute(com.unboundid.ldap.sdk.Attribute) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Example 25 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testBaseOfSubtreeDeleteWithoutDeletedEntry.

/**
 * Tests the behavior for a reversible delete audit log message that reflects
 * the deletion of the base entry for a subtree delete operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBaseOfSubtreeDeleteWithoutDeletedEntry() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage("# 24/Aug/2018:15:07:59.457 -0500; conn=59; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4BlNw==; " + "threadID=13; clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001656D8CF6C70D3F00000016\"; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"; " + "isSubtreeDelete=true; " + "requestControlOIDs=\"1.2.840.113556.1.4.805," + "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=10\", " + "\"clientRequestID\":\"op=7\", \"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "dn: ou=People,dc=example,dc=com", "changetype: delete");
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# 24/Aug/2018:15:07:59.457 -0500; conn=59; op=1; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("24/Aug/2018:15:07:59.457 -0500; conn=59; 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(), "W4BlNw==");
    assertNotNull(m.getThreadID());
    assertEquals(m.getThreadID().longValue(), 13L);
    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(), 59L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001656D8CF6C70D3F00000016");
    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(), Arrays.asList("1.2.840.113556.1.4.805", "1.3.6.1.4.1.30221.2.5.2"));
    assertNull(m.getOperationPurposeRequestControl());
    assertNotNull(m.getIntermediateClientRequestControl());
    assertNotNull(m.getDN());
    assertDNsEqual(m.getDN(), "ou=People,dc=example,dc=com");
    assertNotNull(m.getIsSubtreeDelete());
    assertTrue(m.getIsSubtreeDelete());
    assertNull(m.getDeletedAsPartOfSubtreeDelete());
    assertNull(m.getIsSoftDelete());
    assertNull(m.getSoftDeletedEntryDN());
    assertNull(m.getIsSoftDeletedEntry());
    assertNull(m.getDeletedEntry());
    assertNull(m.getDeletedEntryVirtualAttributes());
    assertNotNull(m.getChangeType());
    assertEquals(m.getChangeType(), ChangeType.DELETE);
    assertNotNull(m.getChangeRecord());
    assertTrue(m.getChangeRecord() instanceof LDIFDeleteChangeRecord);
    assertFalse(m.isRevertible());
    try {
        m.getRevertChangeRecords();
        fail("Expected an exception because a subtree delete base entry is not " + "revertible.");
    } catch (final AuditLogException e) {
    // This was expected.
    }
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Aggregations

LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)67 Test (org.testng.annotations.Test)58 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)29 LDIFChangeRecord (com.unboundid.ldif.LDIFChangeRecord)20 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)18 LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)17 Calendar (java.util.Calendar)17 GregorianCalendar (java.util.GregorianCalendar)17 Entry (com.unboundid.ldap.sdk.Entry)10 Attribute (com.unboundid.ldap.sdk.Attribute)9 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)9 ReadOnlyEntry (com.unboundid.ldap.sdk.ReadOnlyEntry)9 DN (com.unboundid.ldap.sdk.DN)7 LDAPException (com.unboundid.ldap.sdk.LDAPException)6 File (java.io.File)5 Schema (com.unboundid.ldap.sdk.schema.Schema)4 Nullable (com.unboundid.util.Nullable)4 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)3 ChangeLogEntry (com.unboundid.ldap.sdk.ChangeLogEntry)3 Modification (com.unboundid.ldap.sdk.Modification)3