Blame SOURCES/0003-stageuser-add-ipauserauthtypeclass-when-required_rhbz#1979605.patch

c14a06
From 06468b2f604c56b02231904072cb57412966a701 Mon Sep 17 00:00:00 2001
c14a06
From: Florence Blanc-Renaud <flo@redhat.com>
c14a06
Date: Mon, 5 Jul 2021 09:51:41 +0200
c14a06
Subject: [PATCH] stageuser: add ipauserauthtypeclass when required
c14a06
c14a06
The command
c14a06
ipa stageuser-add --user-auth-type=xxx
c14a06
is currently failing because the objectclass ipauserauthtypeclass
c14a06
is missing from the created entry.
c14a06
c14a06
There is code adding the missing objectclass in the
c14a06
pre_common_callback method of user_add, and this code should
c14a06
be common to user_add and stageuser_add. In order to avoid code
c14a06
duplication, it makes more sense to move the existing code to
c14a06
pre_common_callback of baseuser_add, that is called by both
c14a06
classes.
c14a06
c14a06
Fixes: https://pagure.io/freeipa/issue/8909
c14a06
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
c14a06
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
c14a06
---
c14a06
 ipaserver/plugins/baseuser.py | 3 +++
c14a06
 ipaserver/plugins/user.py     | 4 ----
c14a06
 2 files changed, 3 insertions(+), 4 deletions(-)
c14a06
c14a06
diff --git a/ipaserver/plugins/baseuser.py b/ipaserver/plugins/baseuser.py
c14a06
index ae16a978a..6035228f1 100644
c14a06
--- a/ipaserver/plugins/baseuser.py
c14a06
+++ b/ipaserver/plugins/baseuser.py
c14a06
@@ -539,6 +539,9 @@ class baseuser_add(LDAPCreate):
c14a06
         if entry_attrs.get('ipatokenradiususername', None):
c14a06
             add_missing_object_class(ldap, u'ipatokenradiusproxyuser', dn,
c14a06
                                      entry_attrs, update=False)
c14a06
+        if entry_attrs.get('ipauserauthtype', None):
c14a06
+            add_missing_object_class(ldap, u'ipauserauthtypeclass', dn,
c14a06
+                                     entry_attrs, update=False)
c14a06
 
c14a06
     def post_common_callback(self, ldap, dn, entry_attrs, *keys, **options):
c14a06
         assert isinstance(dn, DN)
c14a06
diff --git a/ipaserver/plugins/user.py b/ipaserver/plugins/user.py
c14a06
index 6f7facb53..e4ee572b2 100644
c14a06
--- a/ipaserver/plugins/user.py
c14a06
+++ b/ipaserver/plugins/user.py
c14a06
@@ -617,10 +617,6 @@ class user_add(baseuser_add):
c14a06
            'ipauser' not in entry_attrs['objectclass']:
c14a06
             entry_attrs['objectclass'].append('ipauser')
c14a06
 
c14a06
-        if 'ipauserauthtype' in entry_attrs and \
c14a06
-           'ipauserauthtypeclass' not in entry_attrs['objectclass']:
c14a06
-            entry_attrs['objectclass'].append('ipauserauthtypeclass')
c14a06
-
c14a06
         rcl = entry_attrs.get('ipatokenradiusconfiglink', None)
c14a06
         if rcl:
c14a06
             if 'ipatokenradiusproxyuser' not in entry_attrs['objectclass']:
c14a06
-- 
c14a06
2.31.1
c14a06
c14a06
From 4a5a0fe7d25209a41a2eadd159f7f4c771e5d7fc Mon Sep 17 00:00:00 2001
c14a06
From: Florence Blanc-Renaud <flo@redhat.com>
c14a06
Date: Mon, 5 Jul 2021 10:22:31 +0200
c14a06
Subject: [PATCH] XMLRPC test: add a test for stageuser-add --user-auth-type
c14a06
c14a06
Related: https://pagure.io/freeipa/issue/8909
c14a06
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
c14a06
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
c14a06
---
c14a06
 ipatests/test_xmlrpc/test_stageuser_plugin.py | 6 ++++++
c14a06
 1 file changed, 6 insertions(+)
c14a06
c14a06
diff --git a/ipatests/test_xmlrpc/test_stageuser_plugin.py b/ipatests/test_xmlrpc/test_stageuser_plugin.py
c14a06
index 5586fc607..bc606b093 100644
c14a06
--- a/ipatests/test_xmlrpc/test_stageuser_plugin.py
c14a06
+++ b/ipatests/test_xmlrpc/test_stageuser_plugin.py
c14a06
@@ -343,6 +343,12 @@ class TestStagedUser(XMLRPC_test):
c14a06
         result = command()
c14a06
         assert result['count'] == 1
c14a06
 
c14a06
+    def test_create_withuserauthtype(self, stageduser):
c14a06
+        stageduser.ensure_missing()
c14a06
+        command = stageduser.make_create_command(
c14a06
+            options={u'ipauserauthtype': u'password'})
c14a06
+        command()
c14a06
+
c14a06
 
c14a06
 @pytest.mark.tier1
c14a06
 class TestCreateInvalidAttributes(XMLRPC_test):
c14a06
-- 
c14a06
2.31.1
c14a06