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

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