Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1330,17 +1330,22 @@ private boolean removeObjectClassAttribute(Attribute attribute, Collection<? sup
{
String ocName = toLowerName(rule, v);

boolean matchFound = false;
for (ObjectClass oc : objectClasses.keySet())
{
if (oc.hasNameOrOID(ocName))
{
objectClasses.remove(oc);
return true;
matchFound = true;
break;
}
}

allSuccessful = false;
missingValues.add(v);
if (!matchFound)
{
allSuccessful = false;
missingValues.add(v);
}
}

return allSuccessful;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.server.types;

Expand All @@ -26,6 +27,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -108,6 +110,53 @@ public void setUp() throws Exception {
TestCaseUtils.startServer();
}

/** Returns an entry to delete object class values from. */
private Entry newTestUserEntry() throws Exception
{
return TestCaseUtils.makeEntry(
"dn: cn=Test User,ou=People,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"cn: Test User",
"sn: User");
}

/**
* A delete of several object class values must remove every one of them, the way a delete of
* several values of any other attribute does.
*/
@Test
public void testRemoveSeveralObjectClassValues() throws Exception
{
Entry e = newTestUserEntry();

List<ByteString> missingValues = new LinkedList<>();
assertTrue(e.removeAttribute(
Attributes.create("objectClass", "organizationalPerson", "inetOrgPerson"), missingValues));

assertThat(missingValues).isEmpty();
assertThat(e.getObjectClasses().values()).containsOnly("top", "person");
}

/**
* A delete of an object class value which the entry does not have must be reported as a missing
* value, whatever the other values of the same modification are.
*/
@Test
public void testRemoveObjectClassValuesOneOfWhichIsMissing() throws Exception
{
Entry e = newTestUserEntry();

List<ByteString> missingValues = new LinkedList<>();
assertFalse(e.removeAttribute(
Attributes.create("objectClass", "inetOrgPerson", "domain"), missingValues));

assertThat(missingValues).containsOnly(ByteString.valueOfUtf8("domain"));
assertThat(e.getObjectClasses().values()).containsOnly("top", "person", "organizationalPerson");
}

/**
* Test the {@link Entry#parseAttribute(String)} method.
*/
Expand Down
Loading