Blame SOURCES/0021-Issue-4791-Missing-dependency-for-RetroCL-RFE.patch

5d81fc
From 964a153b420b26140e0bbddfbebb4a51aaa0e4ea Mon Sep 17 00:00:00 2001
5d81fc
From: James Chapman <jachapma@redhat.com>
5d81fc
Date: Thu, 3 Jun 2021 15:16:22 +0000
5d81fc
Subject: [PATCH 1/7] Issue 4791 - Missing dependency for RetroCL RFE
5d81fc
5d81fc
Description: The RetroCL exclude attribute RFE is dependent on functionality of the
5d81fc
	     EntryUUID bug fix, that didn't make into the latest build. This breaks the
5d81fc
             RetroCL exclude attr feature so we need to provide a workaround.
5d81fc
5d81fc
Fixes: https://github.com/389ds/389-ds-base/issues/4791
5d81fc
5d81fc
Relates: https://github.com/389ds/389-ds-base/pull/4723
5d81fc
5d81fc
Relates: https://github.com/389ds/389-ds-base/issues/4224
5d81fc
5d81fc
Reviewed by: tbordaz, droideck (Thank you)
5d81fc
---
5d81fc
 .../tests/suites/retrocl/basic_test.py        |  6 ++--
5d81fc
 .../lib389/cli_conf/plugins/retrochangelog.py | 35 +++++++++++++++++--
5d81fc
 2 files changed, 36 insertions(+), 5 deletions(-)
5d81fc
5d81fc
diff --git a/dirsrvtests/tests/suites/retrocl/basic_test.py b/dirsrvtests/tests/suites/retrocl/basic_test.py
5d81fc
index 112c73cb9..f3bc50f29 100644
5d81fc
--- a/dirsrvtests/tests/suites/retrocl/basic_test.py
5d81fc
+++ b/dirsrvtests/tests/suites/retrocl/basic_test.py
5d81fc
@@ -17,7 +17,7 @@ from lib389.utils import *
5d81fc
 from lib389.tasks import *
5d81fc
 from lib389.cli_base import FakeArgs, connect_instance, disconnect_instance
5d81fc
 from lib389.cli_base.dsrc import dsrc_arg_concat
5d81fc
-from lib389.cli_conf.plugins.retrochangelog import retrochangelog_add
5d81fc
+from lib389.cli_conf.plugins.retrochangelog import retrochangelog_add_attr
5d81fc
 from lib389.idm.user import UserAccount, UserAccounts, nsUserAccounts
5d81fc
 
5d81fc
 pytestmark = pytest.mark.tier1
5d81fc
@@ -122,7 +122,7 @@ def test_retrocl_exclude_attr_add(topology_st):
5d81fc
     args.bindpw = None
5d81fc
     args.prompt = False
5d81fc
     args.exclude_attrs = ATTR_HOMEPHONE
5d81fc
-    args.func = retrochangelog_add
5d81fc
+    args.func = retrochangelog_add_attr
5d81fc
     dsrc_inst = dsrc_arg_concat(args, None)
5d81fc
     inst = connect_instance(dsrc_inst, False, args)
5d81fc
     result = args.func(inst, None, log, args)
5d81fc
@@ -255,7 +255,7 @@ def test_retrocl_exclude_attr_mod(topology_st):
5d81fc
     args.bindpw = None
5d81fc
     args.prompt = False
5d81fc
     args.exclude_attrs = ATTR_CARLICENSE
5d81fc
-    args.func = retrochangelog_add
5d81fc
+    args.func = retrochangelog_add_attr
5d81fc
     dsrc_inst = dsrc_arg_concat(args, None)
5d81fc
     inst = connect_instance(dsrc_inst, False, args)
5d81fc
     result = args.func(inst, None, log, args)
5d81fc
diff --git a/src/lib389/lib389/cli_conf/plugins/retrochangelog.py b/src/lib389/lib389/cli_conf/plugins/retrochangelog.py
5d81fc
index 9940c6532..160fbb82d 100644
5d81fc
--- a/src/lib389/lib389/cli_conf/plugins/retrochangelog.py
5d81fc
+++ b/src/lib389/lib389/cli_conf/plugins/retrochangelog.py
5d81fc
@@ -6,8 +6,13 @@
5d81fc
 # See LICENSE for details.
5d81fc
 # --- END COPYRIGHT BLOCK ---
5d81fc
 
5d81fc
+# JC Work around for missing dependency on https://github.com/389ds/389-ds-base/pull/4344
5d81fc
+import ldap
5d81fc
+
5d81fc
 from lib389.plugins import RetroChangelogPlugin
5d81fc
-from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit
5d81fc
+# JC Work around for missing dependency https://github.com/389ds/389-ds-base/pull/4344
5d81fc
+# from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit, generic_object_add_attr
5d81fc
+from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit, _args_to_attrs
5d81fc
 
5d81fc
 arg_to_attr = {
5d81fc
     'is_replicated': 'isReplicated',
5d81fc
@@ -18,12 +23,38 @@ arg_to_attr = {
5d81fc
     'exclude_attrs': 'nsslapd-exclude-attrs'
5d81fc
 }
5d81fc
 
5d81fc
-
5d81fc
 def retrochangelog_edit(inst, basedn, log, args):
5d81fc
     log = log.getChild('retrochangelog_edit')
5d81fc
     plugin = RetroChangelogPlugin(inst)
5d81fc
     generic_object_edit(plugin, log, args, arg_to_attr)
5d81fc
 
5d81fc
+# JC Work around for missing dependency https://github.com/389ds/389-ds-base/pull/4344
5d81fc
+def retrochangelog_add_attr(inst, basedn, log, args):
5d81fc
+    log = log.getChild('retrochangelog_add_attr')
5d81fc
+    plugin = RetroChangelogPlugin(inst)
5d81fc
+    generic_object_add_attr(plugin, log, args, arg_to_attr)
5d81fc
+
5d81fc
+# JC Work around for missing dependency https://github.com/389ds/389-ds-base/pull/4344
5d81fc
+def generic_object_add_attr(dsldap_object, log, args, arg_to_attr):
5d81fc
+    """Add an attribute to the entry. This differs to 'edit' as edit uses replace,
5d81fc
+    and this allows multivalues to be added.
5d81fc
+
5d81fc
+    dsldap_object should be a single instance of DSLdapObject with a set dn
5d81fc
+    """
5d81fc
+    log = log.getChild('generic_object_add_attr')
5d81fc
+    # Gather the attributes
5d81fc
+    attrs = _args_to_attrs(args, arg_to_attr)
5d81fc
+
5d81fc
+    modlist = []
5d81fc
+    for attr, value in attrs.items():
5d81fc
+        if not isinstance(value, list):
5d81fc
+            value = [value]
5d81fc
+        modlist.append((ldap.MOD_ADD, attr, value))
5d81fc
+    if len(modlist) > 0:
5d81fc
+        dsldap_object.apply_mods(modlist)
5d81fc
+        log.info("Successfully changed the %s", dsldap_object.dn)
5d81fc
+    else:
5d81fc
+        raise ValueError("There is nothing to set in the %s plugin entry" % dsldap_object.dn)
5d81fc
 
5d81fc
 def _add_parser_args(parser):
5d81fc
     parser.add_argument('--is-replicated', choices=['TRUE', 'FALSE'], type=str.upper,
5d81fc
-- 
5d81fc
2.31.1
5d81fc