From df0af76ae6838013c0e66bf5d17c7e7aae44dac2 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 01 Oct 2026 09:35:55 +0000
Subject: [PATCH] [#1120] Apply a change to plugin-type on an enabled plugin without disabling and enabling it again (#1127)

---
 opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java
index 177f587..7fa59db 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java
@@ -13,6 +13,7 @@
  *
  * Copyright 2011-2012 profiq s.r.o.
  * Portions Copyright 2011-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
  */
 package org.opends.server.plugins;
 
@@ -794,4 +795,37 @@
       plugin.setTimeStampProvider(null);
     }
   }
+
+  /**
+   * A change of the plugin types re-creates the plugin, and the finalized instance no longer
+   * listens to the configuration entry.
+   */
+  @Test
+  public void testPluginTypeChangeLeavesNoChangeListenerBehind() throws Exception
+  {
+    DN pluginDN = DN.valueOf("cn=samba password,cn=Plugins,cn=config");
+    int changeListeners = countChangeListeners(pluginDN);
+    try
+    {
+      assertEquals(setPluginTypes(pluginDN, "preoperationmodify"), ResultCode.SUCCESS);
+      assertEquals(countChangeListeners(pluginDN), changeListeners);
+    }
+    finally
+    {
+      assertEquals(setPluginTypes(pluginDN, "postoperationextended", "preoperationmodify"), ResultCode.SUCCESS);
+    }
+    assertEquals(countChangeListeners(pluginDN), changeListeners);
+  }
+
+  private static int countChangeListeners(DN pluginDN)
+  {
+    return TestCaseUtils.getServerContext().getConfigurationHandler().getChangeListeners(pluginDN).size();
+  }
+
+  private static ResultCode setPluginTypes(DN pluginDN, String... pluginTypes)
+  {
+    ModifyRequest request = Requests.newModifyRequest(pluginDN)
+        .addModification(REPLACE, "ds-cfg-plugin-type", pluginTypes);
+    return getRootConnection().processModify(request).getResultCode();
+  }
 }

--
Gitblit v1.10.0