URL: https://github.com/freeipa/freeipa/pull/6143
Author: rcritten
 Title: #6143: [Backport][ipa-4-9] Config plugin: return EmptyModlist when no 
change is applied
Action: opened

PR body:
"""
This PR was opened automatically because PR #6126 was pushed to master and 
backport to ipa-4-9 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/6143/head:pr6143
git checkout pr6143
From 0c1948446e08b6e0db725b3b56724393f1e298f4 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <f...@redhat.com>
Date: Wed, 15 Dec 2021 10:47:02 +0100
Subject: [PATCH 1/2] Config plugin: return EmptyModlist when no change is
 applied

When ipa config-mod is called with the option --enable-sid,
the code needs to trap EmptyModlist exception (it is expected
that no LDAP attribute is modified by this operation).
The code had a flaw and was checking:
    'enable_sid' in options
instead of
    options['enable_sid']

"'enable_sid' in options" always returns true as this option
is a Flag with a default value, hence always present even if
not specified on the command line.

Fixes: https://pagure.io/freeipa/issue/9063
---
 ipaserver/plugins/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaserver/plugins/config.py b/ipaserver/plugins/config.py
index eae401fc3f7..24446beb0b0 100644
--- a/ipaserver/plugins/config.py
+++ b/ipaserver/plugins/config.py
@@ -707,7 +707,7 @@ def exc_callback(self, keys, options, exc, call_func,
         if (isinstance(exc, errors.EmptyModlist) and
                 call_func.__name__ == 'update_entry' and
                 ('ca_renewal_master_server' in options or
-                 'enable_sid' in options)):
+                 options['enable_sid'])):
             return
 
         super(config_mod, self).exc_callback(

From c3d7ff6c856fb6d32e5828f9e8a585703e9c79d2 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <f...@redhat.com>
Date: Wed, 15 Dec 2021 10:51:05 +0100
Subject: [PATCH 2/2] config plugin: add a test ensuring EmptyModlist is
 returned

Add a test to test_config_plugin, that calls ipa config-mod
with the same value as already present in LDAP.
The call must return EmptyModlist.

Related: https://pagure.io/freeipa/issue/9063
---
 ipatests/test_xmlrpc/test_config_plugin.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ipatests/test_xmlrpc/test_config_plugin.py b/ipatests/test_xmlrpc/test_config_plugin.py
index e981bb4a03d..a8ec9f0e558 100644
--- a/ipatests/test_xmlrpc/test_config_plugin.py
+++ b/ipatests/test_xmlrpc/test_config_plugin.py
@@ -312,4 +312,13 @@ class test_config(Declarative):
                 'value': None,
             },
         ),
+        dict(
+            desc='Set the value to the already set value, no modifications',
+            command=(
+                'config_mod', [], {
+                    'ipasearchrecordslimit': u'100',
+                },
+            ),
+            expected=errors.EmptyModlist(),
+        ),
     ]
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to