706194
From ff4152539b96d309dcceaf854a3e0a49f435acff Mon Sep 17 00:00:00 2001
706194
From: Florence Blanc-Renaud <flo@redhat.com>
706194
Date: Mon, 20 Jun 2022 09:09:11 +0200
706194
Subject: [PATCH] Preserve user: fix the confusing summary
706194
706194
When ipa user-del --preserve is called, the command output
706194
prints a summary with:
706194
    Deleted user: user1
706194
although the user was preserved.
706194
Replace the summary with
706194
    Preserved user: user1
706194
to reflect what was actually done.
706194
706194
Fixes: https://pagure.io/freeipa/issue/9187
706194
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
706194
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
706194
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
706194
---
706194
 ipaserver/plugins/user.py | 4 ++++
706194
 1 file changed, 4 insertions(+)
706194
706194
diff --git a/ipaserver/plugins/user.py b/ipaserver/plugins/user.py
706194
index 25d2bb6aa..fa8a67d3d 100644
706194
--- a/ipaserver/plugins/user.py
706194
+++ b/ipaserver/plugins/user.py
706194
@@ -56,6 +56,7 @@ from .idviews import remove_ipaobject_overrides
706194
 from ipalib.plugable import Registry
706194
 from .baseldap import (
706194
     LDAPObject,
706194
+    pkey_to_unicode,
706194
     pkey_to_value,
706194
     LDAPCreate,
706194
     LDAPSearch,
706194
@@ -701,6 +702,7 @@ class user_del(baseuser_del):
706194
     __doc__ = _('Delete a user.')
706194
 
706194
     msg_summary = _('Deleted user "%(value)s"')
706194
+    msg_summary_preserved = _('Preserved user "%(value)s"')
706194
 
706194
     takes_options = baseuser_del.takes_options + (
706194
         Bool('preserve?',
706194
@@ -831,6 +833,8 @@ class user_del(baseuser_del):
706194
                     failed.append(pkey_to_value(pkey, options))
706194
 
706194
             val = dict(result=dict(failed=failed), value=preserved)
706194
+            val['summary'] = self.msg_summary_preserved % dict(
706194
+                value=pkey_to_unicode(preserved))
706194
             return val
706194
         else:
706194
             return super(user_del, self).execute(*keys, **options)
706194
-- 
706194
2.36.1
706194
706194
From 4984ff210a169129e4e56b10e54e9c795520855c Mon Sep 17 00:00:00 2001
706194
From: Florence Blanc-Renaud <flo@redhat.com>
706194
Date: Mon, 20 Jun 2022 09:12:14 +0200
706194
Subject: [PATCH] xmlrpc tests: updated expected output for preserved user
706194
706194
Update the expected summary for the command
706194
ipa user-del --preserve
706194
706194
The command now displays: Preserved user: user1
706194
instead of                Deleted user: user1
706194
706194
Related: https://pagure.io/freeipa/issue/9187
706194
706194
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
706194
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
706194
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
706194
---
706194
 ipatests/test_xmlrpc/test_stageuser_plugin.py | 5 ++++-
706194
 ipatests/test_xmlrpc/tracker/user_plugin.py   | 7 ++++++-
706194
 2 files changed, 10 insertions(+), 2 deletions(-)
706194
706194
diff --git a/ipatests/test_xmlrpc/test_stageuser_plugin.py b/ipatests/test_xmlrpc/test_stageuser_plugin.py
706194
index bc606b093..fd146876c 100644
706194
--- a/ipatests/test_xmlrpc/test_stageuser_plugin.py
706194
+++ b/ipatests/test_xmlrpc/test_stageuser_plugin.py
706194
@@ -479,11 +479,12 @@ class TestActive(XMLRPC_test):
706194
 
706194
     def test_delete_preserve(self, user):
706194
         user.ensure_exists()
706194
-        user.track_delete()
706194
+        user.track_delete(preserve=True)
706194
         command = user.make_delete_command(no_preserve=False, preserve=True)
706194
         result = command()
706194
         user.check_delete(result)
706194
 
706194
+        user.track_delete(preserve=False)
706194
         command = user.make_delete_command()
706194
         result = command()
706194
         user.check_delete(result)
706194
@@ -622,6 +623,7 @@ class TestCustomAttr(XMLRPC_test):
706194
         assert 'BusinessCat' in result['result'][u'businesscategory']
706194
 
706194
         # delete the user with --preserve
706194
+        user_customattr.track_delete(preserve=True)
706194
         command = user_customattr.make_delete_command(no_preserve=False,
706194
                                                       preserve=True)
706194
         result = command()
706194
@@ -763,6 +765,7 @@ class TestGroups(XMLRPC_test):
706194
         result = command()
706194
         group.check_retrieve(result)
706194
 
706194
+        user.track_delete(preserve=True)
706194
         command = user.make_delete_command(no_preserve=False, preserve=True)
706194
         result = command()
706194
         user.check_delete(result)
706194
diff --git a/ipatests/test_xmlrpc/tracker/user_plugin.py b/ipatests/test_xmlrpc/tracker/user_plugin.py
706194
index 03c106250..b04be4c19 100644
706194
--- a/ipatests/test_xmlrpc/tracker/user_plugin.py
706194
+++ b/ipatests/test_xmlrpc/tracker/user_plugin.py
706194
@@ -273,9 +273,14 @@ class UserTracker(CertmapdataMixin, KerberosAliasMixin, Tracker):
706194
 
706194
     def check_delete(self, result):
706194
         """ Check 'user-del' command result """
706194
+        if u'preserved' in self.attrs and self.attrs[u'preserved']:
706194
+            summary = u'Preserved user "%s"' % self.uid
706194
+        else:
706194
+            summary = u'Deleted user "%s"' % self.uid
706194
+
706194
         assert_deepequal(dict(
706194
             value=[self.uid],
706194
-            summary=u'Deleted user "%s"' % self.uid,
706194
+            summary=summary,
706194
             result=dict(failed=[]),
706194
             ), result)
706194
 
706194
-- 
706194
2.36.1
706194