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

Ian Packer
08.18.2015 3de0b3b664e0839dccba13536052750fa1769041
CR-6874: fix OPENDJ-1797 Possible to add entries with invalid objectclass if structural objectclass checking is off
2 files modified
43 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/EntrySchemaCheckingTestCase.java 36 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -1750,6 +1750,13 @@
      {
        logger.error(message);
      }
      if (! checkAttributesAndObjectClasses(null,
              structuralPolicy, invalidReason))
      {
          return false;
      }
    }
    else
    {
opendj-server-legacy/src/test/java/org/opends/server/types/EntrySchemaCheckingTestCase.java
@@ -75,6 +75,36 @@
    }
  }
    /**
     * Ensures that the provided entry fails schema checking validation irrespective
     * of relaxed compliance configured. Added due to unique niche case described
     * in OPENDJ-1797
     *
     * @param  e  The entry to be tested.
     */
    private void failAlwaysStrictEvaluation(Entry e)
    {
        try
        {
            LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
            DirectoryServer.setSingleStructuralObjectClassPolicy(REJECT);
            assertFalse(e.conformsToSchema(null, false, true, true, invalidReason),
                    "Entry validation succeeded with REJECT policy");
            DirectoryServer.setSingleStructuralObjectClassPolicy(WARN);
            assertFalse(e.conformsToSchema(null, false, true, true, invalidReason),
                    "Entry validation failed with WARN policy:  " + invalidReason);
            DirectoryServer.setSingleStructuralObjectClassPolicy(ACCEPT);
            assertFalse(e.conformsToSchema(null, false, true, true, invalidReason),
                    "Entry validation failed with ACCEPT policy:  " + invalidReason);
        }
        finally
        {
            DirectoryServer.setSingleStructuralObjectClassPolicy(REJECT);
        }
    }
  /**
@@ -194,8 +224,7 @@
         "objectClass: xxxundefinedstructuralxxx",
         "cn: test");
    assertFalse(e.conformsToSchema(null, false, true, true,
                                   new LocalizableMessageBuilder()));
    failAlwaysStrictEvaluation(e);
  }
@@ -219,8 +248,7 @@
         "objectClass: xxxundefinedauxiliaryxxx",
         "cn: test");
    assertFalse(e.conformsToSchema(null, false, true, true,
                                   new LocalizableMessageBuilder()));
    failAlwaysStrictEvaluation(e);
  }