Search in sources :

Example 56 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testRevertibleSoftDelete.

/**
 * Tests the behavior for a revertible delete audit log message that reflects
 * a soft delete operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testRevertibleSoftDelete() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage("# 27/Aug/2018:13:55:32.217 -0500; conn=41; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4RIvA==; threadID=8; " + "clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001657CBDB56B1DD50000000C\"; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"; " + "isSoftDelete=true; softDeletedEntryDN=\"entryUUID=b4004999-" + "f0cf-4b6b-9d9d-1b2ee06a0b38+ou=People,dc=example,dc=com\"; " + "requestControlOIDs=\"1.3.6.1.4.1.30221.2.5.20," + "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=2\", " + "\"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# Deleted entry real attributes", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: People", "# createTimestamp: 20180827185532.195Z", "# creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "# modifyTimestamp: 20180827185532.195Z", "# modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "# entryUUID: b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38", "# 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("# 27/Aug/2018:13:55:32.217 -0500; conn=41; op=1; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("27/Aug/2018:13:55:32.217 -0500; conn=41; 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(), "W4RIvA==");
    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(), 41L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001657CBDB56B1DD50000000C");
    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.3.6.1.4.1.30221.2.5.20", "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");
    assertNull(m.getIsSubtreeDelete());
    assertNull(m.getDeletedAsPartOfSubtreeDelete());
    assertNotNull(m.getIsSoftDelete());
    assertTrue(m.getIsSoftDelete());
    assertNotNull(m.getSoftDeletedEntryDN());
    assertDNsEqual(m.getSoftDeletedEntryDN(), "entryUUID=b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38+ou=People," + "dc=example,dc=com");
    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: 20180827185532.195Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180827185532.195Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38"));
    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.toLDIFString(), UndeleteRequestControl.createUndeleteRequest("ou=People,dc=example,dc=com", "entryUUID=b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38+ou=People," + "dc=example,dc=com").toLDIFString());
    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 57 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testDeleteNonRevertibleLogMessageFromListAndChangeRecord.

/**
 * Tests the behavior for a non-revertible delete audit log message created
 * from a string list and a change record.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDeleteNonRevertibleLogMessageFromListAndChangeRecord() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage(Arrays.asList("# 24/Aug/2018:12:11:50 -0500; conn=33; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"", "dn: ou=People,dc=example,dc=com", "changetype: delete"), new LDIFDeleteChangeRecord("ou=People,dc=example,dc=com"));
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertEquals(m.getCommentedHeaderLine(), "# 24/Aug/2018:12:11:50 -0500; conn=33; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"");
    assertNotNull(m.getUncommentedHeaderLine());
    assertEquals(m.getUncommentedHeaderLine(), "24/Aug/2018:12:11:50 -0500; conn=33; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"");
    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(), 33L);
    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");
    assertNull(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 when trying to revert a non-revertible " + "delete audit log message");
    } 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)

Example 58 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testNonRevertibleSoftDelete.

/**
 * Tests the behavior for a non-revertible delete audit log message that
 * reflects a soft delete operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testNonRevertibleSoftDelete() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage("# 27/Aug/2018:13:55:32.217 -0500; conn=41; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4RIvA==; threadID=8; " + "clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001657CBDB56B1DD50000000C\"; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"; " + "isSoftDelete=true; " + "requestControlOIDs=\"1.3.6.1.4.1.30221.2.5.20," + "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=2\", " + "\"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# Deleted entry real attributes", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: People", "# createTimestamp: 20180827185532.195Z", "# creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "# modifyTimestamp: 20180827185532.195Z", "# modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "# entryUUID: b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38", "# 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("# 27/Aug/2018:13:55:32.217 -0500; conn=41; op=1; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("27/Aug/2018:13:55:32.217 -0500; conn=41; 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(), "W4RIvA==");
    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(), 41);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001657CBDB56B1DD50000000C");
    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.3.6.1.4.1.30221.2.5.20", "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");
    assertNull(m.getIsSubtreeDelete());
    assertNull(m.getDeletedAsPartOfSubtreeDelete());
    assertNotNull(m.getIsSoftDelete());
    assertTrue(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: 20180827185532.195Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180827185532.195Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: b4004999-f0cf-4b6b-9d9d-1b2ee06a0b38"));
    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 when trying to revert a non-revertible " + "soft delete audit log message");
    } 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 59 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testDeleteRevertibleLogMessageFromListAndChangeRecord.

/**
 * Tests the behavior for a revertible delete audit log message created from a
 * string list and a change record.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDeleteRevertibleLogMessageFromListAndChangeRecord() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage(Arrays.asList("# 24/Aug/2018:12:11:50 -0500; conn=33; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"", "# Deleted entry real attributes", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: People", "# createTimestamp: 20180827185604.369Z", "# creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "# modifyTimestamp: 20180827185604.369Z", "# modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "# entryUUID: ce51184a-67a0-49ac-99a8-1b856c10d057", "# Deleted entry virtual attributes", "# ds-entry-checksum: 2457931569", "# subschemaSubentry: cn=schema", "dn: ou=People,dc=example,dc=com", "changetype: delete"), new LDIFDeleteChangeRecord("ou=People,dc=example,dc=com"));
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertEquals(m.getCommentedHeaderLine(), "# 24/Aug/2018:12:11:50 -0500; conn=33; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"");
    assertNotNull(m.getUncommentedHeaderLine());
    assertEquals(m.getUncommentedHeaderLine(), "24/Aug/2018:12:11:50 -0500; conn=33; op=1; " + "authzDN=\"cn=Directory Manager,cn=Root DNs,cn=config\"");
    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(), 33L);
    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");
    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: 20180827185604.369Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180827185604.369Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: ce51184a-67a0-49ac-99a8-1b856c10d057"));
    assertNotNull(m.getDeletedEntryVirtualAttributes());
    assertEquals(m.getDeletedEntryVirtualAttributes(), Arrays.asList(new Attribute("ds-entry-checksum", "2457931569"), 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 60 with LDIFDeleteChangeRecord

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

the class DeleteAuditLogMessageTestCase method testBasicReversibleSubordinateOfSubtreeDelete.

/**
 * Tests the behavior for a reversible delete audit log message that reflects
 * the deletion of a subordinate (non-base) entry for a subtree delete
 * operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBasicReversibleSubordinateOfSubtreeDelete() throws Exception {
    final DeleteAuditLogMessage m = new DeleteAuditLogMessage("# --- INCREMENTAL SIGNED CONTENT ---  " + "signature='C007Rb525K46wqbg1dw5EwDHOxFEhi8Uiw/8pXZcxXU='", "# 27/Aug/2018:13:56:04.386 -0500; conn=-27; op=1195; " + "triggeredByConn=43; triggeredByOp=1; origin=\"internal\"; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4RIvA==; threadID=10; " + "clientIP=internal; requesterDN=\"cn=Directory " + "Manager,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001657CBE331B1DD500000016\"; " + "deletedAsPartOfSubtreeDelete=true; " + "requestControlOIDs=\"2.16.840.1.113730.3.4.2\"", "# Deleted entry real attributes", "# objectClass: top", "# objectClass: person", "# objectClass: organizationalPerson", "# objectClass: inetOrgPerson", "# sn: 4", "# cn: User 4", "# givenName: User", "# uid: user.4", "# createTimestamp: 20180827185604.369Z", "# creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "# modifyTimestamp: 20180827185604.369Z", "# modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "# entryUUID: ce51184a-67a0-49ac-99a8-1b856c10d057", "# Deleted entry virtual attributes", "# ds-entry-checksum: 2457931569", "# subschemaSubentry: cn=schema", "dn: uid=user.4,ou=people,dc=example,dc=com", "changetype: delete");
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# 27/Aug/2018:13:56:04.386 -0500; conn=-27; op=1195; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("27/Aug/2018:13:56:04.386 -0500; conn=-27; op=1195; "));
    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(), "W4RIvA==");
    assertNotNull(m.getThreadID());
    assertEquals(m.getThreadID().longValue(), 10L);
    assertNotNull(m.getRequesterDN());
    assertDNsEqual(m.getRequesterDN(), "cn=Directory Manager,cn=Root DNs,cn=config");
    assertNotNull(m.getRequesterIPAddress());
    assertEquals(m.getRequesterIPAddress(), "internal");
    assertNotNull(m.getConnectionID());
    assertEquals(m.getConnectionID().longValue(), -27L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1195L);
    assertNotNull(m.getTriggeredByConnectionID());
    assertEquals(m.getTriggeredByConnectionID().longValue(), 43L);
    assertNotNull(m.getTriggeredByOperationID());
    assertEquals(m.getTriggeredByOperationID().longValue(), 1L);
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001657CBE331B1DD500000016");
    assertNull(m.getAlternateAuthorizationDN());
    assertNull(m.getTransactionID());
    assertNotNull(m.getOrigin());
    assertEquals(m.getOrigin(), "internal");
    assertNull(m.getUsingAdminSessionWorkerThread());
    assertNotNull(m.getRequestControlOIDs());
    assertEquals(m.getRequestControlOIDs(), Collections.singletonList("2.16.840.1.113730.3.4.2"));
    assertNull(m.getOperationPurposeRequestControl());
    assertNull(m.getIntermediateClientRequestControl());
    assertNotNull(m.getDN());
    assertDNsEqual(m.getDN(), "uid=user.4,ou=People,dc=example,dc=com");
    assertNull(m.getIsSubtreeDelete());
    assertNotNull(m.getDeletedAsPartOfSubtreeDelete());
    assertEquals(m.getDeletedAsPartOfSubtreeDelete(), Boolean.TRUE);
    assertNull(m.getIsSoftDelete());
    assertNull(m.getSoftDeletedEntryDN());
    assertNull(m.getIsSoftDeletedEntry());
    assertNotNull(m.getDeletedEntry());
    assertEquals(m.getDeletedEntry(), new ReadOnlyEntry("dn: uid=user.4,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "sn: 4", "cn: User 4", "givenName: User", "uid: user.4", "createTimestamp: 20180827185604.369Z", "creatorsName: cn=Directory Manager,cn=Root DNs,cn=config", "modifyTimestamp: 20180827185604.369Z", "modifiersName: cn=Directory Manager,cn=Root DNs,cn=config", "entryUUID: ce51184a-67a0-49ac-99a8-1b856c10d057"));
    assertNotNull(m.getDeletedEntryVirtualAttributes());
    assertFalse(m.getDeletedEntryVirtualAttributes().isEmpty());
    assertEquals(m.getDeletedEntryVirtualAttributes(), Arrays.asList(new Attribute("ds-entry-checksum", "2457931569"), 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)

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