From 37820c6eb0a7061f62fbc7b540eda842cf455bf4 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 08 Mar 2007 20:20:21 +0000
Subject: [PATCH] Fix a bug in the schema backend that could cause problems when deleting one instance of an element and adding a different instance of the same element in the same modification that also depends on a third schema element which was added between the two.  For example, if you tried to have a single modify operation that deleted an existing object class, added a new attribute type, and added a new object class that depended on the new attribute type, the operation would fail because when processing the removal of the object class the server would attempt to determine whether it was going to be re-added later in the operation and therefore attempted to decode any object class additions later in the operation.  An error occurred when trying to decode the new object class because it depended on an attribute type that was not yet defined and the decode operation wasn't told to ignore unknown schema elements.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
index 922e5c5..265f827 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
@@ -5187,6 +5187,65 @@
 
 
   /**
+   * This test case covers the problem identified in issue #1318.  In that
+   * issue, a problem arose if the following elements occurred in the following
+   * order in a single modify request:
+   *
+   * <OL>
+   *   <LI>Delete an existing object class</LI>
+   *   <LI>Add a new attribute type</LI>
+   *   <LI>Add a new object class (different from the one that was removed) that
+   *       depends on the new attribute type</LI>
+   * </OL>
+   *
+   * The problem was that in the process of removing the object class in step 1,
+   * the server checks to see if the same object class is going to be re-added
+   * again later.  It does that by looking through the remaining modifications
+   * in the operation and for each modification that would add a new object
+   * class we decode it to see if it has the same OID.  The process of decoding
+   * that object class would fail because it depended on a new attribute type
+   * that wasn't yet defined in the schema, and the server wasn't told to ignore
+   * missing schema elements.
+   *
+   * @throws  Exception  If an unexpected problem occurs.
+   */
+  @Test()
+  public void testRemoveAndAddObjectClassIssue1318()
+         throws Exception
+  {
+    String path = TestCaseUtils.createTempFile(
+         "dn: cn=schema",
+         "changetype: modify",
+         "add: objectClasses",
+         "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )",
+         "",
+         "dn: cn=schema",
+         "changetype: modify",
+         "delete: objectClasses",
+         "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )",
+         "-",
+         "add: attributeTypes",
+         "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' )",
+         "-",
+         "add: objectClasses",
+         "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " +
+              "MUST testIssue1381AT )");
+
+    String[] args =
+    {
+      "-h", "127.0.0.1",
+      "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
+      "-D", "cn=Directory Manager",
+      "-w", "password",
+      "-f", path
+    };
+
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+  }
+
+
+
+  /**
    * Tests to ensure that the schema subentry includes the lastmod attributes
    * and that the modifiersName and modifyTimestamp attributes get updated when
    * the schema is modified.

--
Gitblit v1.10.0