From 1659f5f448f9cdd8cbc11b60fca88c1a67a4b3ef Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 17 Aug 2015 10:47:12 +0000
Subject: [PATCH] OPENDJ-2241 Backport OPENDJ-2240: AttributeTypes parser mishandles characters after usage field
---
opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java | 78 ++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 1 deletions(-)
diff --git a/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java b/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
index b50e04c..2988baa 100644
--- a/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
+++ b/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Portions copyright 2012-2013 ForgeRock AS.
+ * Portions copyright 2012-2015 ForgeRock AS.
*/
package org.forgerock.opendj.ldap.schema;
@@ -472,6 +472,82 @@
}
/**
+ * Adds an attribute to the schema, without a space between the usage and the
+ * right paren.
+ *
+ * @throws Exception
+ */
+ @Test
+ public final void testSchemaBuilderAttributeWithoutSpace() throws Exception {
+ // @formatter:off
+ final String[] strEntry = {
+ "dn: cn=schema",
+ "objectClass: top",
+ "objectClass: ldapSubentry",
+ "objectClass: subschema",
+ "cn: schema",
+ "attributeTypes: ( foo-oid NAME 'foo' SUP name DESC 'No trailing space' USAGE userApplications)"
+ };
+ // @formatter:on
+ final Entry e = new LinkedHashMapEntry(strEntry);
+ final SchemaBuilder builder = new SchemaBuilder();
+ builder.addSchema(Schema.getCoreSchema(), false);
+ builder.addSchema(e, true);
+
+ assertThat(e.getAttribute(Schema.ATTR_LDAP_SYNTAXES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_ATTRIBUTE_TYPES)).isNotNull();
+ assertThat(e.getAttribute(Schema.ATTR_OBJECT_CLASSES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_MATCHING_RULE_USE)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_MATCHING_RULES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_DIT_CONTENT_RULES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_DIT_STRUCTURE_RULES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_NAME_FORMS)).isNull();
+
+ Schema schema = builder.toSchema();
+ // No warnings
+ assertThat(schema.getWarnings()).isEmpty();
+ assertThat(schema.getAttributeType("foo").getDescription()).isEqualTo("No trailing space");
+ }
+
+ /**
+ * Adds an attribute to the schema, without a space between an extension and the
+ * right paren.
+ *
+ * @throws Exception
+ */
+ @Test
+ public final void testSchemaBuilderAttributeExtensionWithoutSpace() throws Exception {
+ // @formatter:off
+ final String[] strEntry = {
+ "dn: cn=schema",
+ "objectClass: top",
+ "objectClass: ldapSubentry",
+ "objectClass: subschema",
+ "cn: schema",
+ "attributeTypes: ( foo-oid NAME 'foo' SUP name DESC 'No trailing space' X-SCHEMA-FILE '99-test.ldif')"
+ };
+ // @formatter:on
+ final Entry e = new LinkedHashMapEntry(strEntry);
+ final SchemaBuilder builder = new SchemaBuilder();
+ builder.addSchema(Schema.getCoreSchema(), false);
+ builder.addSchema(e, true);
+
+ assertThat(e.getAttribute(Schema.ATTR_LDAP_SYNTAXES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_ATTRIBUTE_TYPES)).isNotNull();
+ assertThat(e.getAttribute(Schema.ATTR_OBJECT_CLASSES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_MATCHING_RULE_USE)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_MATCHING_RULES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_DIT_CONTENT_RULES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_DIT_STRUCTURE_RULES)).isNull();
+ assertThat(e.getAttribute(Schema.ATTR_NAME_FORMS)).isNull();
+
+ Schema schema = builder.toSchema();
+ // No warnings
+ assertThat(schema.getWarnings()).isEmpty();
+ assertThat(schema.getAttributeType("foo").getDescription()).isEqualTo("No trailing space");
+ }
+
+ /**
* Adds a ldapsyntax to the schema. Ldapsyntaxes define allowable values can
* be used for an attribute.
*
--
Gitblit v1.10.0