From 5088b52fb83d5c81d65daaff4d4727744dbcfeda Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 30 Sep 2026 10:56:07 +0000
Subject: [PATCH] [#1117] Correct the default class of the governing-structure-rule virtual attribute, and check every default class exists (#1122)
---
opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/GoverningStructureRuleVirtualAttributeConfiguration.xml | 3 +
opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java | 3 +
opendj-server-legacy/src/test/java/org/opends/server/config/DefaultClassPropertyValuesTestCase.java | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+), 2 deletions(-)
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java
index ca29270..55844d0 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java
@@ -12,6 +12,7 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2013-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
package org.forgerock.opendj.config;
@@ -37,7 +38,7 @@
public void testPropertyWithStringReturnValue() {
GoverningStructureRuleVirtualAttributeCfg mock = mockCfg(GoverningStructureRuleVirtualAttributeCfg.class);
assertThat(mock.getJavaClass()).
- isEqualTo("org.opends.server.extensions.GoverningSturctureRuleVirtualAttributeProvider");
+ isEqualTo("org.opends.server.extensions.GoverningStructureRuleVirtualAttributeProvider");
}
@Test
diff --git a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/GoverningStructureRuleVirtualAttributeConfiguration.xml b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/GoverningStructureRuleVirtualAttributeConfiguration.xml
index aa1d952..ecf2613 100644
--- a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/GoverningStructureRuleVirtualAttributeConfiguration.xml
+++ b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/GoverningStructureRuleVirtualAttributeConfiguration.xml
@@ -13,6 +13,7 @@
information: "Portions Copyright [year] [name of copyright owner]".
Copyright 2009 Sun Microsystems, Inc.
+ Portions Copyright 2026 3A Systems, LLC.
! -->
<adm:managed-object name="governing-structure-rule-virtual-attribute"
plural-name="governing-structure-rule-virtual-attributes"
@@ -36,7 +37,7 @@
<adm:default-behavior>
<adm:defined>
<adm:value>
- org.opends.server.extensions.GoverningSturctureRuleVirtualAttributeProvider
+ org.opends.server.extensions.GoverningStructureRuleVirtualAttributeProvider
</adm:value>
</adm:defined>
</adm:default-behavior>
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/config/DefaultClassPropertyValuesTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/config/DefaultClassPropertyValuesTestCase.java
new file mode 100644
index 0000000..ef8535b
--- /dev/null
+++ b/opendj-server-legacy/src/test/java/org/opends/server/config/DefaultClassPropertyValuesTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development and
+ * Distribution License (the License). You may not use this file except in compliance with the
+ * License.
+ *
+ * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
+ * specific language governing permission and limitations under the License.
+ *
+ * When distributing Covered Software, include this CDDL Header Notice in each file and include
+ * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
+ * Header, with the fields enclosed by brackets [] replaced by your own identifying
+ * information: "Portions copyright [year] [name of copyright owner]".
+ *
+ * Copyright 2026 3A Systems, LLC.
+ */
+package org.opends.server.config;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.forgerock.opendj.config.AbstractManagedObjectDefinition;
+import org.forgerock.opendj.config.ClassPropertyDefinition;
+import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
+import org.forgerock.opendj.config.PropertyDefinition;
+import org.forgerock.opendj.config.TopCfgDefn;
+import org.opends.server.DirectoryServerTestCase;
+import org.opends.server.TestCaseUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Checks that the default value of every class property in the configuration definitions names
+ * a class the server ships.
+ * <p>
+ * {@code java-class} is mandatory, so {@code dsconfig} writes its default into every entry it
+ * creates without an explicit value. The client does not load the class, so a default naming a
+ * class that does not exist is only noticed when the server refuses the new entry.
+ */
+@SuppressWarnings("javadoc")
+@Test(groups = { "precommit" }, sequential = true)
+public class DefaultClassPropertyValuesTestCase extends DirectoryServerTestCase {
+
+ /** Definitions whose default class is not part of the code base, with the reason. */
+ private static final Map<String, String> DEFINITIONS_WITHOUT_A_SHIPPED_DEFAULT_CLASS = new HashMap<>();
+ static {
+ DEFINITIONS_WITHOUT_A_SHIPPED_DEFAULT_CLASS.put("static-service-discovery-mechanism",
+ "The proxy backend these mechanisms belong to is not part of this code base.");
+ DEFINITIONS_WITHOUT_A_SHIPPED_DEFAULT_CLASS.put("replication-service-discovery-mechanism",
+ "The proxy backend these mechanisms belong to is not part of this code base.");
+ }
+
+ @BeforeClass
+ public void startServer() throws Exception {
+ TestCaseUtils.startServer();
+ }
+
+ @DataProvider
+ public Object[][] defaultClasses() {
+ List<Object[]> rows = new ArrayList<>();
+ Set<PropertyDefinition<?>> seen = Collections.newSetFromMap(new IdentityHashMap<>());
+ for (AbstractManagedObjectDefinition<?, ?> definition : TopCfgDefn.getInstance().getAllChildren()) {
+ if (DEFINITIONS_WITHOUT_A_SHIPPED_DEFAULT_CLASS.containsKey(definition.getName())) {
+ continue;
+ }
+ for (PropertyDefinition<?> property : definition.getAllPropertyDefinitions()) {
+ if (property instanceof ClassPropertyDefinition
+ && property.getDefaultBehaviorProvider() instanceof DefinedDefaultBehaviorProvider
+ && seen.add(property)) {
+ for (String className
+ : ((DefinedDefaultBehaviorProvider<?>) property.getDefaultBehaviorProvider())
+ .getDefaultValues()) {
+ rows.add(new Object[] { definition.getName(), property.getName(), className.trim(),
+ property });
+ }
+ }
+ }
+ }
+ return rows.toArray(new Object[rows.size()][]);
+ }
+
+ @Test(dataProvider = "defaultClasses")
+ public void theDefaultClassLoadsAndImplementsTheRequiredInterfaces(String definitionName, String propertyName,
+ String className, ClassPropertyDefinition property) {
+ property.loadClass(className, Object.class);
+ }
+
+ @Test
+ public void everyDefinitionLeftOutExists() {
+ List<String> names = new ArrayList<>();
+ for (AbstractManagedObjectDefinition<?, ?> definition : TopCfgDefn.getInstance().getAllChildren()) {
+ names.add(definition.getName());
+ }
+ assertThat(names).containsAll(DEFINITIONS_WITHOUT_A_SHIPPED_DEFAULT_CLASS.keySet());
+ }
+}
--
Gitblit v1.10.0