mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
24.40.2016 f154862f349bceea5180888b896fcb7e0aeec92a
OPENDJ-2987 Revert previous behavior on extensibleObject object classes wrt optional attributes
3 files modified
24 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java 4 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java 14 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java
@@ -724,7 +724,11 @@
     *         <code>false</code> if not.
     */
    public boolean isOptional(final AttributeType attributeType) {
        return optionalAttributes.contains(attributeType);
        // In theory, attribute types not defined in the schema (i.e place holder attributes) should
        // not be considered as optional.
        // However, in practice, some parts of the server have historically relied on non-defined
        // attributes to behave properly.
        return isExtensibleObject || optionalAttributes.contains(attributeType);
    }
    /**
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
@@ -958,7 +958,7 @@
    }
    @Test
    public void testExtensibleObjectAcceptsAnyAttributeButNotPlaceholderAttribute() throws Exception {
    public void testExtensibleObjectAcceptsAnyAttributeIncludingPlaceholderAttribute() throws Exception {
        // @formatter:off
        final Entry e2 = newEntry(
                "dn: dc=example,dc=com",
@@ -979,7 +979,7 @@
            "o: example",
            "dummy: unknown attribute!!");
        // @formatter:on
        assertDoesNotConformToSchema(e, defaultPolicy());
        assertConformsToSchema(e, defaultPolicy());
    }
    /**
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java
@@ -30,19 +30,19 @@
public class ObjectClassTestCase extends AbstractSchemaTestCase {
    @Test
    public void extensibleObjectShouldNotAcceptPlaceholderAttribute() {
    public void extensibleObjectShouldAcceptPlaceholderAttribute() {
        Schema schema = getCoreSchema();
        ObjectClass extensibleObject = schema.getObjectClass(EXTENSIBLE_OBJECT_OBJECTCLASS_OID);
        AttributeType dummy = schema.getAttributeType("dummy");
        assertThat(dummy.isPlaceHolder()).isTrue();
        assertThat(extensibleObject.isRequired(dummy)).isFalse();
        assertThat(extensibleObject.isOptional(dummy)).isFalse();
        assertThat(extensibleObject.isRequiredOrOptional(dummy)).isFalse();
        AttributeType attributeType = schema.getAttributeType("dummy");
        assertThat(attributeType.isPlaceHolder()).isTrue();
        assertThat(extensibleObject.isRequired(attributeType)).isFalse();
        assertThat(extensibleObject.isOptional(attributeType)).isTrue();
        assertThat(extensibleObject.isRequiredOrOptional(attributeType)).isTrue();
    }
    @Test
    public void extensibleObjectShouldAcceptAnyAttributeInTheSchema() {
    public void extensibleObjectShouldAcceptAnyAttribute() {
        Schema schema = getCoreSchema();
        ObjectClass extensibleObject = schema.getObjectClass(EXTENSIBLE_OBJECT_OBJECTCLASS_OID);