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

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