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

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