Search in sources :

Example 21 with LDIFModifyChangeRecord

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

the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageMultipleNewRDNComponentsOneAlreadyThere.

/**
 * Tests the behavior for a revertible modify DN audit log message that has
 * multiple components in the new RDN, one of which is already present in the
 * entry and one that is not.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testModifyAuditLogMessageMultipleNewRDNComponentsOneAlreadyThere() throws Exception {
    final ModifyDNAuditLogMessage m = new ModifyDNAuditLogMessage("# 27/Aug/2018:22:42:11.929 -0500; conn=33; op=1; " + "productName=\"Directory Server\"; " + "instanceName=\"ReplicaOne\"; startupID=W4TELw==; threadID=13; " + "clientIP=127.0.0.1; " + "requesterDN=\"cn=Proxy User,cn=Root DNs,cn=config\"; " + "replicationChangeID=\"000001657E9FE1D473A700000007\"; " + "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=7\", " + "\"downstreamRequest\":{ " + "\"clientName\":\"Unidentified Directory Application\" } }", "# ModifyDN attribute modifications (count=1)", "# add: sn", "# sn: Smith", "dn: uid=jane.doe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: givenName=Jane+sn=Smith", "deleteoldrdn: 0");
    assertNotNull(m.getLogMessageLines());
    assertFalse(m.getLogMessageLines().isEmpty());
    assertNotNull(m.getCommentedHeaderLine());
    assertTrue(m.getCommentedHeaderLine().startsWith("# 27/Aug/2018:22:42:11.929 -0500; conn=33; op=1; "));
    assertNotNull(m.getUncommentedHeaderLine());
    assertTrue(m.getUncommentedHeaderLine().startsWith("27/Aug/2018:22:42:11.929 -0500; conn=33; 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(), "W4TELw==");
    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(), 33L);
    assertNotNull(m.getOperationID());
    assertEquals(m.getOperationID().longValue(), 1L);
    assertNull(m.getTriggeredByConnectionID());
    assertNull(m.getTriggeredByOperationID());
    assertNotNull(m.getReplicationChangeID());
    assertEquals(m.getReplicationChangeID(), "000001657E9FE1D473A700000007");
    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=jane.doe,ou=People,dc=example,dc=com");
    assertNotNull(m.getNewRDN());
    assertDNsEqual(m.getNewRDN(), "givenName=Jane+sn=Smith");
    assertFalse(m.deleteOldRDN());
    assertNull(m.getNewSuperiorDN());
    assertNotNull(m.getAttributeModifications());
    assertEquals(m.getAttributeModifications(), Collections.singletonList(new Modification(ModificationType.ADD, "sn", "Smith")));
    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(), 2);
    assertTrue(revertChangeRecords.get(0) instanceof LDIFModifyDNChangeRecord);
    assertTrue(revertChangeRecords.get(1) instanceof LDIFModifyChangeRecord);
    final LDIFModifyDNChangeRecord revertModifyDNChangeRecord = (LDIFModifyDNChangeRecord) revertChangeRecords.get(0);
    assertDNsEqual(revertModifyDNChangeRecord.getDN(), "givenName=Jane+sn=Smith,ou=People,dc=example,dc=com");
    assertDNsEqual(revertModifyDNChangeRecord.getNewRDN(), "uid=jane.doe");
    assertFalse(revertModifyDNChangeRecord.deleteOldRDN());
    assertNull(revertModifyDNChangeRecord.getNewSuperiorDN());
    final LDIFModifyChangeRecord revertModifyChangeRecord = (LDIFModifyChangeRecord) revertChangeRecords.get(1);
    assertDNsEqual(revertModifyChangeRecord.getDN(), "uid=jane.doe,ou=People,dc=example,dc=com");
    assertEquals(revertModifyChangeRecord.getModifications(), new Modification[] { new Modification(ModificationType.DELETE, "sn", "Smith") });
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 22 with LDIFModifyChangeRecord

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

the class ModifyDNAuditLogMessageTestCase method testModifyAuditLogMessageWithAdditionalMods.

/**
 * Tests the behavior for a revertible modify DN audit log message that has
 * additional modifications not related to the RDN change.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testModifyAuditLogMessageWithAdditionalMods() 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=6)", "# delete: givenName", "# givenName: John", "# givenName: Johnny", "# -", "# delete: sn", "# sn: Doe", "# sn: A Female Deer", "# -", "# add: uid", "# uid: jdoe", "# uid: john.doe", "# -", "# delete: displayName", "# displayName: foo", "# -", "# add: description", "# description: bar", "# -", "# increment: intAttr", "# intAttr: 1", "dn: givenName=John+sn=Doe,ou=People,dc=example,dc=com", "changetype: moddn", "newrdn: uid=jdoe", "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(), "givenName=John+sn=Doe,ou=People,dc=example,dc=com");
    assertNotNull(m.getNewRDN());
    assertDNsEqual(m.getNewRDN(), "uid=jdoe");
    assertTrue(m.deleteOldRDN());
    assertNull(m.getNewSuperiorDN());
    assertNotNull(m.getAttributeModifications());
    assertEquals(m.getAttributeModifications(), Arrays.asList(new Modification(ModificationType.DELETE, "givenName", "John", "Johnny"), new Modification(ModificationType.DELETE, "sn", "Doe", "A Female Deer"), new Modification(ModificationType.ADD, "uid", "jdoe", "john.doe"), new Modification(ModificationType.DELETE, "displayName", "foo"), new Modification(ModificationType.ADD, "description", "bar"), new Modification(ModificationType.INCREMENT, "intAttr", "1")));
    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(), 2);
    assertTrue(revertChangeRecords.get(0) instanceof LDIFModifyDNChangeRecord);
    assertTrue(revertChangeRecords.get(1) instanceof LDIFModifyChangeRecord);
    final LDIFModifyDNChangeRecord revertModifyDNChangeRecord = (LDIFModifyDNChangeRecord) revertChangeRecords.get(0);
    assertDNsEqual(revertModifyDNChangeRecord.getDN(), "uid=jdoe,ou=People,dc=example,dc=com");
    assertDNsEqual(revertModifyDNChangeRecord.getNewRDN(), "givenName=John+sn=Doe");
    assertTrue(revertModifyDNChangeRecord.deleteOldRDN());
    assertNull(revertModifyDNChangeRecord.getNewSuperiorDN());
    final LDIFModifyChangeRecord revertModifyChangeRecord = (LDIFModifyChangeRecord) revertChangeRecords.get(1);
    assertDNsEqual(revertModifyChangeRecord.getDN(), "givenName=John+sn=Doe,ou=People,dc=example,dc=com");
    assertEquals(revertModifyChangeRecord.getModifications(), new Modification[] { new Modification(ModificationType.INCREMENT, "intAttr", "-1"), new Modification(ModificationType.DELETE, "description", "bar"), new Modification(ModificationType.ADD, "displayName", "foo"), new Modification(ModificationType.DELETE, "uid", "john.doe"), new Modification(ModificationType.ADD, "sn", "A Female Deer"), new Modification(ModificationType.ADD, "givenName", "Johnny") });
    assertNotNull(m.toString());
    assertNotNull(m.toMultiLineString());
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 23 with LDIFModifyChangeRecord

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

the class UnboundIDChangeLogEntryTestCase method testExtendedModifyChangeLogEntryNoExceededValues.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for a modify operation without an extended set of content that
 * does not have any attributes with an exceeded value count.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedModifyChangeLogEntryNoExceededValues() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyChangeRecord("uid=test.user,ou=People,dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "bar"), new Modification(ModificationType.ADD, "cn", "User, Test"), new Modification(ModificationType.DELETE, "mail")));
    assertNotNull(e);
    // Construct before values for the description, cn and mail attributes.
    final StringBuilder beforeBuffer = new StringBuilder();
    beforeBuffer.append("description: foo");
    beforeBuffer.append(StaticUtils.EOL);
    beforeBuffer.append("cn: Test User");
    beforeBuffer.append(StaticUtils.EOL);
    beforeBuffer.append("mail: test.user@example.com");
    beforeBuffer.append(StaticUtils.EOL);
    // Construct virtual before values for the description and cn attributes.
    final StringBuilder virtualBeforeBuffer = new StringBuilder();
    virtualBeforeBuffer.append("description: Virtual description");
    virtualBeforeBuffer.append(StaticUtils.EOL);
    virtualBeforeBuffer.append("cn: Virtual cn");
    virtualBeforeBuffer.append(StaticUtils.EOL);
    // Construct after values for the description and cn attributes.
    final StringBuilder afterBuffer = new StringBuilder();
    afterBuffer.append("description: bar");
    afterBuffer.append(StaticUtils.EOL);
    afterBuffer.append("cn: Test User");
    afterBuffer.append(StaticUtils.EOL);
    afterBuffer.append("cn: User, Test");
    afterBuffer.append(StaticUtils.EOL);
    // Construct virtual after values for the description and cn attributes.
    final StringBuilder virtualAfterBuffer = new StringBuilder();
    virtualAfterBuffer.append("description: Virtual description");
    virtualAfterBuffer.append(StaticUtils.EOL);
    virtualAfterBuffer.append("cn: Virtual cn");
    virtualAfterBuffer.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);
    keyAttrBuffer.append("cn: User, Test");
    keyAttrBuffer.append(StaticUtils.EOL);
    // Construct a key virtual attribute value for the "cn" attribute.
    final StringBuilder keyVirtualAttrBuffer = new StringBuilder();
    keyVirtualAttrBuffer.append("cn: Virtual cn");
    keyVirtualAttrBuffer.append(StaticUtils.EOL);
    final Entry extendedEntry = e.duplicate();
    extendedEntry.addAttribute("ds-changelog-before-values", beforeBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-before-virtual-values", virtualBeforeBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-after-values", afterBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-after-virtual-values", virtualAfterBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-entry-key-virtual-values", keyVirtualAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-num-excluded-user-attributes", "1");
    extendedEntry.addAttribute("ds-changelog-num-excluded-operational-attributes", "2");
    extendedEntry.addAttribute("ds-changelog-excluded-user-attribute", "userPassword");
    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-change-to-soft-deleted-entry", "false");
    extendedEntry.addAttribute("ds-changelog-target-attribute", "description", "cn", "mail");
    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.user,ou=People,dc=example,dc=com"));
    assertNotNull(ue.getChangeType());
    assertEquals(ue.getChangeType(), ChangeType.MODIFY);
    assertNull(ue.getAddAttributes());
    assertNull(ue.getAddAttributes(true));
    assertNull(ue.getAddVirtualAttributes());
    assertNull(ue.getDeletedEntryAttributes());
    assertNull(ue.getDeletedEntryAttributes(true));
    assertNull(ue.getDeletedEntryVirtualAttributes());
    assertNotNull(ue.getModifications());
    assertEquals(ue.getModifications().size(), 3);
    assertTrue(ue.getModifications().contains(new Modification(ModificationType.REPLACE, "description", "bar")));
    assertTrue(ue.getModifications().contains(new Modification(ModificationType.ADD, "cn", "User, Test")));
    assertTrue(ue.getModifications().contains(new Modification(ModificationType.DELETE, "mail")));
    assertNull(ue.getNewRDN());
    assertFalse(ue.deleteOldRDN());
    assertNull(ue.getNewSuperior());
    assertNull(ue.getSoftDeleteToDN());
    assertNull(ue.getUndeleteFromDN());
    assertNotNull(ue.getChangeToSoftDeletedEntry());
    assertFalse(ue.getChangeToSoftDeletedEntry());
    assertNotNull(ue.getNewDN());
    assertEquals(new DN(ue.getNewDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
    assertNotNull(ue.getUpdatedAttributesBeforeChange());
    assertEquals(ue.getUpdatedAttributesBeforeChange().size(), 3);
    assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("description", "foo")));
    assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("cn", "Test User")));
    assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("mail", "test.user@example.com")));
    assertNotNull(ue.getUpdatedAttributesBeforeChange(true));
    assertEquals(ue.getUpdatedAttributesBeforeChange(true).size(), 3);
    assertTrue(ue.getUpdatedAttributesBeforeChange(true).contains(new Attribute("description", "foo", "Virtual description")));
    assertTrue(ue.getUpdatedAttributesBeforeChange(true).contains(new Attribute("cn", "Test User", "Virtual cn")));
    assertTrue(ue.getUpdatedAttributesBeforeChange(true).contains(new Attribute("mail", "test.user@example.com")));
    assertNotNull(ue.getUpdatedVirtualAttributesBeforeChange());
    assertEquals(ue.getUpdatedVirtualAttributesBeforeChange().size(), 2);
    assertTrue(ue.getUpdatedVirtualAttributesBeforeChange().contains(new Attribute("description", "Virtual description")));
    assertTrue(ue.getUpdatedVirtualAttributesBeforeChange().contains(new Attribute("cn", "Virtual cn")));
    assertNotNull(ue.getUpdatedAttributesAfterChange());
    assertEquals(ue.getUpdatedAttributesAfterChange().size(), 2);
    assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("description", "bar")));
    assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("cn", "Test User", "User, Test")));
    assertNotNull(ue.getUpdatedAttributesAfterChange(true));
    assertEquals(ue.getUpdatedAttributesAfterChange(true).size(), 2);
    assertTrue(ue.getUpdatedAttributesAfterChange(true).contains(new Attribute("description", "bar", "Virtual description")));
    assertTrue(ue.getUpdatedAttributesAfterChange(true).contains(new Attribute("cn", "Test User", "User, Test", "Virtual cn")));
    assertNotNull(ue.getUpdatedVirtualAttributesAfterChange());
    assertEquals(ue.getUpdatedVirtualAttributesAfterChange().size(), 2);
    assertTrue(ue.getUpdatedVirtualAttributesAfterChange().contains(new Attribute("description", "Virtual description")));
    assertTrue(ue.getUpdatedVirtualAttributesAfterChange().contains(new Attribute("cn", "Virtual cn")));
    assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getVirtualAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getVirtualAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getKeyEntryAttributes());
    assertEquals(ue.getKeyEntryAttributes().size(), 1);
    assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test User", "User, Test")));
    assertNotNull(ue.getKeyEntryAttributes(true));
    assertEquals(ue.getKeyEntryAttributes(true).size(), 1);
    assertTrue(ue.getKeyEntryAttributes(true).contains(new Attribute("cn", "Test User", "User, Test", "Virtual cn")));
    assertNotNull(ue.getKeyEntryVirtualAttributes());
    assertEquals(ue.getKeyEntryVirtualAttributes().size(), 1);
    assertTrue(ue.getKeyEntryVirtualAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertEquals(ue.getNumExcludedUserAttributes(), 1);
    assertEquals(ue.getNumExcludedOperationalAttributes(), 2);
    assertNotNull(ue.getExcludedUserAttributeNames());
    assertFalse(ue.getExcludedUserAttributeNames().isEmpty());
    assertTrue(ue.getExcludedUserAttributeNames().contains("userPassword"));
    assertNotNull(ue.getExcludedOperationalAttributeNames());
    assertFalse(ue.getExcludedOperationalAttributeNames().isEmpty());
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifiersName"));
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifyTimestamp"));
    assertNull(ue.getAttributeBeforeChange("uid"));
    assertNull(ue.getAttributeBeforeChange("uid", true));
    assertNotNull(ue.getAttributeBeforeChange("description"));
    assertEquals(ue.getAttributeBeforeChange("description"), new Attribute("description", "foo"));
    assertNotNull(ue.getAttributeBeforeChange("description", true));
    assertEquals(ue.getAttributeBeforeChange("description", true), new Attribute("description", "foo", "Virtual description"));
    assertNotNull(ue.getAttributeBeforeChange("cn"));
    assertEquals(ue.getAttributeBeforeChange("cn"), new Attribute("cn", "Test User"));
    assertNotNull(ue.getAttributeBeforeChange("cn", true));
    assertEquals(ue.getAttributeBeforeChange("cn", true), new Attribute("cn", "Test User", "Virtual cn"));
    assertNotNull(ue.getAttributeBeforeChange("mail"));
    assertEquals(ue.getAttributeBeforeChange("mail"), new Attribute("mail", "test.user@example.com"));
    assertNotNull(ue.getAttributeBeforeChange("mail", true));
    assertEquals(ue.getAttributeBeforeChange("mail", true), new Attribute("mail", "test.user@example.com"));
    assertNull(ue.getAttributeAfterChange("uid"));
    assertNull(ue.getAttributeAfterChange("uid", true));
    assertNull(ue.getAttributeAfterChange("mail"));
    assertNull(ue.getAttributeAfterChange("mail", true));
    assertNotNull(ue.getAttributeAfterChange("description"));
    assertEquals(ue.getAttributeAfterChange("description"), new Attribute("description", "bar"));
    assertNotNull(ue.getAttributeAfterChange("description", true));
    assertEquals(ue.getAttributeAfterChange("description", true), new Attribute("description", "bar", "Virtual description"));
    assertNotNull(ue.getAttributeAfterChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test User", "User, Test"));
    assertNotNull(ue.getAttributeAfterChange("cn", true));
    assertEquals(ue.getAttributeAfterChange("cn", true), new Attribute("cn", "Test User", "User, Test", "Virtual cn"));
    assertNotNull(ue.constructPartialEntryBeforeChange());
    assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: foo", "cn: Test User", "mail: test.user@example.com"));
    assertNotNull(ue.constructPartialEntryBeforeChange(true));
    assertEquals(ue.constructPartialEntryBeforeChange(true), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: foo", "description: Virtual description", "cn: Test User", "cn: Virtual cn", "mail: test.user@example.com"));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: bar", "cn: Test User", "cn: User, Test"));
    assertNotNull(ue.constructPartialEntryAfterChange(true));
    assertEquals(ue.constructPartialEntryAfterChange(true), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: bar", "description: Virtual description", "cn: Test User", "cn: User, Test", "cn: Virtual cn"));
    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(), 3);
    assertNotNull(ue.getNotificationDestinationEntryUUIDs());
    assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
    assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
    assertNotNull(ue.getNotificationProperties());
    assertFalse(ue.getNotificationProperties().isEmpty());
    assertEquals(ue.getNotificationProperties().size(), 3);
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Attribute(com.unboundid.ldap.sdk.Attribute) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) Test(org.testng.annotations.Test)

Example 24 with LDIFModifyChangeRecord

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

the class LDAPDiffTestCase method testCompareServersWithJustNonIdenticalBaseEntries.

/**
 * Tests the behavior when trying to compare the contents of two servers with
 * just a base entry when that entry is not identical.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testCompareServersWithJustNonIdenticalBaseEntries() throws Exception {
    try (InMemoryDirectoryServer sourceDS = createTestDS(true, false, 0);
        InMemoryDirectoryServer targetDS = createTestDS(true, false, 0)) {
        sourceDS.modify("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: source");
        targetDS.modify("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: target");
        final File outputFile = runTool(sourceDS, targetDS, ResultCode.COMPARE_FALSE, "--numPasses", "3");
        final List<LDIFChangeRecord> changeRecords = readChangeRecords(outputFile);
        assertFalse(changeRecords.isEmpty());
        assertEquals(changeRecords.size(), 1, String.valueOf(changeRecords));
        assertEquals(changeRecords.get(0), new LDIFModifyChangeRecord("dc=example,dc=com", new Modification(ModificationType.DELETE, "description", "source"), new Modification(ModificationType.ADD, "description", "target")));
    }
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) File(java.io.File) Test(org.testng.annotations.Test)

Example 25 with LDIFModifyChangeRecord

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

the class LDAPModifySearchListenerTestCase method testSearchReferenceReceived.

/**
 * Provides test coverage for the {@code searchReferenceReceived} method.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSearchReferenceReceived() throws Exception {
    final InMemoryDirectoryServer ds = getTestDS();
    final LDAPConnectionPool pool = ds.getConnectionPool(1);
    final LDIFModifyChangeRecord changeRecord = new LDIFModifyChangeRecord("dn: dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "foo"));
    final LDAPModify ldapModify = new LDAPModify(null, null, null);
    ldapModify.runTool("--help");
    final LDAPModifySearchListener listener = new LDAPModifySearchListener(ldapModify, changeRecord, Filter.createPresenceFilter("objectClass"), Collections.<Control>emptyList(), pool, null, null, new HashSet<DN>(0));
    listener.searchReferenceReturned(new SearchResultReference(new String[] { "ldap://ds1.example.com:389/dc=example,dc=com", "ldap://ds2.example.com:389/dc=example,dc=com" }, StaticUtils.NO_CONTROLS));
    pool.close();
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) LDAPConnectionPool(com.unboundid.ldap.sdk.LDAPConnectionPool) InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) SearchResultReference(com.unboundid.ldap.sdk.SearchResultReference) DN(com.unboundid.ldap.sdk.DN) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) Test(org.testng.annotations.Test)

Aggregations

LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)60 Test (org.testng.annotations.Test)40 Modification (com.unboundid.ldap.sdk.Modification)24 LDIFChangeRecord (com.unboundid.ldif.LDIFChangeRecord)23 LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)20 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)19 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)18 LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)18 Entry (com.unboundid.ldap.sdk.Entry)17 DN (com.unboundid.ldap.sdk.DN)15 File (java.io.File)11 Attribute (com.unboundid.ldap.sdk.Attribute)9 NotNull (com.unboundid.util.NotNull)9 LDAPException (com.unboundid.ldap.sdk.LDAPException)8 ArrayList (java.util.ArrayList)8 Calendar (java.util.Calendar)8 GregorianCalendar (java.util.GregorianCalendar)8 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)7 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)7 Nullable (com.unboundid.util.Nullable)7