From f157e19aea0407f268de1631cb7b6b60be27aa0a Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 30 Mar 2015 16:49:28 +0000
Subject: [PATCH] CR-6457 OPENDJ-453: use correct schema definitions for attributeTypes/objectClasses/etc
---
opendj-server-legacy/src/test/java/org/opends/server/types/DITStructureRuleTestCase.java | 29 ++--
opendj-server-legacy/resource/schema/00-core.ldif | 23 ++-
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java | 346 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 375 insertions(+), 23 deletions(-)
diff --git a/opendj-server-legacy/resource/schema/00-core.ldif b/opendj-server-legacy/resource/schema/00-core.ldif
index 61f2058..e27eec1 100644
--- a/opendj-server-legacy/resource/schema/00-core.ldif
+++ b/opendj-server-legacy/resource/schema/00-core.ldif
@@ -21,7 +21,7 @@
#
#
# Copyright 2006-2010 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
# Portions Copyright 2013-2014 Manuel Gaupp
#
#
@@ -198,16 +198,20 @@
EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.5 NAME 'attributeTypes' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.5 NAME 'attributeTypes'
+ EQUALITY objectIdentifierFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.6 NAME 'objectClasses' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.6 NAME 'objectClasses'
+ EQUALITY objectIdentifierFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.4 NAME 'matchingRules' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.4 NAME 'matchingRules'
+ EQUALITY objectIdentifierFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.8 NAME 'matchingRuleUse' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.8 NAME 'matchingRuleUse'
+ EQUALITY objectIdentifierFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
attributeTypes: ( 2.5.21.9 NAME 'structuralObjectClass' EQUALITY objectIdentifierMatch
@@ -234,13 +238,16 @@
attributeTypes: ( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.1 NAME 'dITStructureRules' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.1 NAME 'dITStructureRules'
+ EQUALITY IntegerFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.7 NAME 'nameForms' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.7 NAME 'nameForms'
+ EQUALITY objectIdentifierFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
-attributeTypes: ( 2.5.21.2 NAME 'dITContentRules' EQUALITY caseIgnoreMatch
+attributeTypes: ( 2.5.21.2 NAME 'dITContentRules'
+ EQUALITY objectIdentifierFirstComponentMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation
X-ORIGIN 'RFC 4512' )
attributeTypes: ( 0.9.2342.19200300.100.1.25 NAME ( 'dc' 'domainComponent' )
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
index e20c71d..1c7c8d4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -743,6 +743,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -793,6 +794,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -1707,6 +1709,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -2326,6 +2329,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -3151,6 +3155,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -4206,6 +4211,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -4774,6 +4780,8 @@
assertTrue(schemaFile.exists());
}
+
+
/**
* Tests the behavior of the schema backend when attempting to replace an
* existing matching rule use.
@@ -4810,6 +4818,7 @@
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-f", path
};
@@ -5155,6 +5164,342 @@
assertNull(mru);
}
+
+
+ /**
+ * Tests the behavior of the schema backend when attempting to add another
+ * value to attributeTypes that matches an existing one using the correct
+ * matching rules.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ @Test
+ public void testAttributeTypesMatchingRule()
+ throws Exception
+ {
+ String path = TestCaseUtils.createTempFile(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: attributeTypes",
+ "attributeTypes: ( testattributetypesmatchingrule-oid " +
+ "NAME 'testAttributeTypesMatchingRule' " +
+ "EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: attributeTypes",
+ "attributeTypes: ( testattributetypesmatchingrule-oid " +
+ "NAME 'testAttributeTypesMatchingRule' " +
+ "EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )");
+
+ String attrName = "testattributetypesmatchingrule";
+ assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
+
+ 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), 20);
+ }
+
+
+
+ /**
+ * Tests the behavior of the schema backend when attempting to add another
+ * value to objectClasses that matches an existing one using the correct
+ * matching rules.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ @Test
+ public void testObjectClassesMatchingRule()
+ throws Exception
+ {
+ String path = TestCaseUtils.createTempFile(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ "objectClasses: ( testobjectclassesmatchingrule-oid " +
+ "NAME 'testObjectClassesMatchingRule' " +
+ "SUP top STRUCTURAL MAY cn " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ "objectClasses: ( testobjectclassesmatchingrule-oid " +
+ "NAME 'testObjectClassesMatchingRule' " +
+ "SUP top AUXILIARY MAY mail " +
+ "X-ORIGIN 'SchemaBackendTestCase' )");
+
+ String objectClassName = "testobjectclassesmatchingrule";
+ assertFalse(DirectoryServer.getSchema().hasObjectClass(objectClassName));
+
+ 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), 20);
+ }
+
+
+
+ /**
+ * Tests the behavior of the schema backend when attempting to add another
+ * value to nameForms that matches an existing one using the correct
+ * matching rules.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ @Test
+ public void testNameFormsMatchingRule()
+ throws Exception
+ {
+ String path = TestCaseUtils.createTempFile(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ "objectClasses: ( testnameformsmatchingruleoc-oid " +
+ "NAME 'testNameFormsMatchingRuleOC' " +
+ "SUP top STRUCTURAL MAY ( cn $ mail ) " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: nameForms",
+ "nameForms: ( testnameformsmatchingrule-oid " +
+ "NAME 'testNameFormsMatchingRule' " +
+ "OC testNameFormsMatchingRuleOC MUST mail " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: nameForms",
+ "nameForms: ( testnameformsmatchingrule-oid " +
+ "NAME 'testNameFormsMatchingRule' " +
+ "OC testNameFormsMatchingRuleOC MUST cn " +
+ "X-ORIGIN 'SchemaBackendTestCase' )");
+
+ String nameFormName = "testnameformsmatchingrule";
+ assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
+
+ 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), 20);
+ }
+
+
+
+ /**
+ * Tests the behavior of the schema backend when attempting to add another
+ * value to dITContentRules that matches an existing one using the correct
+ * matching rules.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ @Test
+ public void testDitContentRulesMatchingRule()
+ throws Exception
+ {
+ String path = TestCaseUtils.createTempFile(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ "objectClasses: ( testditcontentrulesmatchingrule-oid " +
+ "NAME 'testDitContentRulesMatchingRuleOC' " +
+ "SUP top STRUCTURAL MAY ( cn $ mail ) " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: dITContentRules",
+ "dITContentRules: ( testditcontentrulesmatchingrule-oid " +
+ "NAME 'testDitContentRulesMatchingRule' " +
+ "MUST mail " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: dITContentRules",
+ "dITContentRules: ( testditcontentrulesmatchingrule-oid " +
+ "NAME 'testDitContentRulesMatchingRule' " +
+ "MUST cn " +
+ "X-ORIGIN 'SchemaBackendTestCase' )");
+
+ String objectClassName = "testditcontentrulesmatchingruleoc";
+ assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName));
+
+ 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), 20);
+ }
+
+
+
+ /**
+ * Tests the behavior of the schema backend when attempting to add another
+ * value to dITStructureRules that matches an existing one using the correct
+ * matching rules.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ @Test
+ public void testDitStructureRulesMatchingRule()
+ throws Exception
+ {
+ String path = TestCaseUtils.createTempFile(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ "objectClasses: ( testditstructurerulesmatchingruleoc1-oid " +
+ "NAME 'testDitStructureRulesMatchingRuleOC1' " +
+ "SUP top STRUCTURAL MAY ( cn $ mail ) " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ "objectClasses: ( testditstructurerulesmatchingruleoc2-oid " +
+ "NAME 'testDitStructureRulesMatchingRuleOC2' " +
+ "SUP top STRUCTURAL MAY ( cn $ mail ) " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: nameForms",
+ "nameForms: ( testditstructurerulesmatchingrulenf1-oid " +
+ "NAME 'testDitStructureRulesMatchingRuleNF1' " +
+ "OC testDitStructureRulesMatchingRuleOC1 MUST mail " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: nameForms",
+ "nameForms: ( testditstructurerulesmatchingrulenf2-oid " +
+ "NAME 'testDitStructureRulesMatchingRuleNF2' " +
+ "OC testDitStructureRulesMatchingRuleOC2 MUST mail " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: dITStructureRules",
+ "dITStructureRules: ( 999666 " +
+ "NAME 'testDitStructureRulesMatchingRule' " +
+ "FORM testDitStructureRulesMatchingRuleNF1 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: dITStructureRules",
+ "dITStructureRules: ( 999666 " +
+ "NAME 'testDitStructureRulesMatchingRule' " +
+ "FORM testDitStructureRulesMatchingRuleNF2 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )");
+
+ String objectClassName = "testditcontentrulesmatchingruleoc1";
+ assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName));
+
+ 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), 20);
+ }
+
+
+
+ /**
+ * Tests the behavior of the schema backend when attempting to add another
+ * value to matchingRuleUse that matches an existing one using the correct
+ * matching rules.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ @Test
+ public void testMatchingRuleUseMatchingRule()
+ throws Exception
+ {
+ String path = TestCaseUtils.createTempFile(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: attributeTypes",
+ "attributeTypes: ( testmatchingruleusematchingruleat1-oid " +
+ "NAME 'testMatchingRuleUseMatchingRuleAT1' " +
+ "EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: attributeTypes",
+ "attributeTypes: ( testmatchingruleusematchingruleat2-oid " +
+ "NAME 'testMatchingRuleUseMatchingRuleAT2' " +
+ "EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: matchingRuleUse",
+ "matchingRuleUse: ( booleanMatch " +
+ "NAME 'testMatchingRuleUseMatchingRule' " +
+ "APPLIES testMatchingRuleUseMatchingRuleAT1 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )",
+ "",
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: matchingRuleUse",
+ "matchingRuleUse: ( booleanMatch " +
+ "NAME 'testMatchingRuleUseMatchingRule' " +
+ "APPLIES testMatchingRuleUseMatchingRuleAT2 " +
+ "X-ORIGIN 'SchemaBackendTestCase' )");
+
+ String attrName = "testmatchingruleusematchingruleat1";
+ assertNull(DirectoryServer.getSchema().getAttributeType(attrName));
+
+ 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), 20);
+ }
+
+
+
/**
* This test case covers the problem identified in issue #1318. In that
* issue, a problem arose if the following elements occurred in the following
@@ -5455,4 +5800,3 @@
assertFalse(alerts.isEmpty());
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/DITContentRuleTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/types/DITStructureRuleTestCase.java
similarity index 88%
rename from opendj-server-legacy/src/test/java/org/opends/server/types/DITContentRuleTestCase.java
rename to opendj-server-legacy/src/test/java/org/opends/server/types/DITStructureRuleTestCase.java
index bdeaa5e..1a9533f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/DITContentRuleTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/DITStructureRuleTestCase.java
@@ -36,9 +36,9 @@
/**
- * This class provides a set of test cases for virtual attributes.
+ * This class provides a set of test cases for DIT Structure Rules
*/
-public class DITContentRuleTestCase
+public class DITStructureRuleTestCase
extends TypesTestCase
{
@@ -59,13 +59,13 @@
/**
- * Tests the addition of a new DITConentRule with a conflicting
+ * Tests the addition of a new DITContentRule with a conflicting
* rule identifier.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
- public void testInvalidDITContentRule()
+ public void testInvalidDITStructureRule()
throws Exception
{
String filePath = TestCaseUtils.createTempFile(
@@ -81,26 +81,27 @@
{
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D","cn=directory manager",
- "-w","password",
+ "-D", "cn=directory manager",
+ "-w", "password",
+ "-J", "1.2.840.113556.1.4.1413",
"-a",
"-f", filePath
};
int err = LDAPModify.mainModify(args, false, null,null);
//Shouldn't perform this operation.
- assertEquals(err,53);
+ assertEquals(err, 53);
}
/**
- * Tests the addition of new DITContentRules with unique rule ids.
+ * Tests the addition of new DITStructureRules with unique rule ids.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dependsOnMethods = {"org.opends.server.types."+
- "DITContentRuleTestCase.testInvalidDITContentRule"})
- public void testValidDITRContentRules()
+ "DITStructureRuleTestCase.testInvalidDITStructureRule"})
+ public void testValidDITStructureRules()
throws Exception
{
String filePath = TestCaseUtils.createTempFile(
@@ -135,13 +136,13 @@
/**
- * Cleans up the DITContentRules.
+ * Cleans up the DITStructureRules.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dependsOnMethods = {"org.opends.server.types."+
- "DITContentRuleTestCase.testValidDITRContentRules"})
- public void cleanUpDITRContentRules()
+ "DITStructureRuleTestCase.testValidDITStructureRules"})
+ public void cleanUpDITStructureRules()
throws Exception
{
String filePath = TestCaseUtils.createTempFile(
@@ -172,4 +173,4 @@
//Should delete the above entries.
assertEquals(err,0);
}
-}
\ No newline at end of file
+}
--
Gitblit v1.10.0