|
|
6ec482 |
From bcfbeef0ca7f69ff50f40990e783d58fb9a83d30 Mon Sep 17 00:00:00 2001
|
|
|
6ec482 |
From: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
6ec482 |
Date: Fri, 26 Jul 2019 15:44:58 +0200
|
|
|
6ec482 |
Subject: [PATCH] xmlrpc test: add test for preserved > stage user
|
|
|
6ec482 |
|
|
|
6ec482 |
When moving a preserved user to the stage area, check that the
|
|
|
6ec482 |
custom attributes are not lost ( = the attr for which there is
|
|
|
6ec482 |
no specific user_stage option).
|
|
|
6ec482 |
|
|
|
6ec482 |
Test scenario:
|
|
|
6ec482 |
- add a stage user with --setattr "businesscategory=value"
|
|
|
6ec482 |
- activate the user, check that businesscategory is still present
|
|
|
6ec482 |
- delete (preserve) the user, check that attr is still present
|
|
|
6ec482 |
- stage the user, check that attr is still present
|
|
|
6ec482 |
|
|
|
6ec482 |
Related: https://pagure.io/freeipa/issue/7597
|
|
|
6ec482 |
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
6ec482 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
6ec482 |
---
|
|
|
6ec482 |
ipatests/test_xmlrpc/test_stageuser_plugin.py | 64 +++++++++++++++++++
|
|
|
6ec482 |
.../test_xmlrpc/tracker/stageuser_plugin.py | 5 +-
|
|
|
6ec482 |
2 files changed, 67 insertions(+), 2 deletions(-)
|
|
|
6ec482 |
|
|
|
6ec482 |
diff --git a/ipatests/test_xmlrpc/test_stageuser_plugin.py b/ipatests/test_xmlrpc/test_stageuser_plugin.py
|
|
|
6ec482 |
index 9a869259d06a65722f019a19405baf53c03917e1..cc6a3b1a880acab1ffba06061be6eae229f80237 100644
|
|
|
6ec482 |
--- a/ipatests/test_xmlrpc/test_stageuser_plugin.py
|
|
|
6ec482 |
+++ b/ipatests/test_xmlrpc/test_stageuser_plugin.py
|
|
|
6ec482 |
@@ -128,6 +128,17 @@ def stageduser_notposix(request):
|
|
|
6ec482 |
return tracker.make_fixture(request)
|
|
|
6ec482 |
|
|
|
6ec482 |
|
|
|
6ec482 |
+@pytest.fixture(scope='class')
|
|
|
6ec482 |
+def stageduser_customattr(request):
|
|
|
6ec482 |
+ tracker = StageUserTracker(u'customattr', u'customattr', u'customattr',
|
|
|
6ec482 |
+ setattr=u'businesscategory=BusinessCat')
|
|
|
6ec482 |
+ tracker.track_create()
|
|
|
6ec482 |
+ tracker.attrs.update(
|
|
|
6ec482 |
+ businesscategory=[u'BusinessCat']
|
|
|
6ec482 |
+ )
|
|
|
6ec482 |
+ return tracker.make_fixture(request)
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+
|
|
|
6ec482 |
@pytest.fixture(scope='class')
|
|
|
6ec482 |
def user(request):
|
|
|
6ec482 |
tracker = UserTracker(u'auser1', u'active', u'user')
|
|
|
6ec482 |
@@ -573,6 +584,59 @@ class TestPreserved(XMLRPC_test):
|
|
|
6ec482 |
stageduser.delete()
|
|
|
6ec482 |
|
|
|
6ec482 |
|
|
|
6ec482 |
+@pytest.mark.tier1
|
|
|
6ec482 |
+class TestCustomAttr(XMLRPC_test):
|
|
|
6ec482 |
+ """Test for pagure ticket 7597
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ When a staged user is activated, preserved and finally staged again,
|
|
|
6ec482 |
+ the custom attributes are lost.
|
|
|
6ec482 |
+ """
|
|
|
6ec482 |
+ def test_stageduser_customattr(self, stageduser_customattr):
|
|
|
6ec482 |
+ # Create a staged user with attributes not accessible
|
|
|
6ec482 |
+ # through the options
|
|
|
6ec482 |
+ # --setattr is needed here
|
|
|
6ec482 |
+ command = stageduser_customattr.make_create_command()
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ stageduser_customattr.check_create(result, [u'businesscategory'])
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ # Activate the staged user
|
|
|
6ec482 |
+ user_customattr = UserTracker(
|
|
|
6ec482 |
+ stageduser_customattr.uid, stageduser_customattr.givenname,
|
|
|
6ec482 |
+ stageduser_customattr.sn)
|
|
|
6ec482 |
+ user_customattr.create_from_staged(stageduser_customattr)
|
|
|
6ec482 |
+ user_customattr.attrs[u'businesscategory'] = [u'BusinessCat']
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ command = stageduser_customattr.make_activate_command()
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ user_customattr.check_activate(result)
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ # Check that the user contains businesscategory
|
|
|
6ec482 |
+ command = user_customattr.make_retrieve_command(all=True)
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ assert 'BusinessCat' in result['result'][u'businesscategory']
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ # delete the user with --preserve
|
|
|
6ec482 |
+ command = user_customattr.make_delete_command(no_preserve=False,
|
|
|
6ec482 |
+ preserve=True)
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ user_customattr.check_delete(result)
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ # Check that the preserved user contains businesscategory
|
|
|
6ec482 |
+ command = user_customattr.make_retrieve_command(all=True)
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ assert 'BusinessCat' in result['result'][u'businesscategory']
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ # Move the user from preserved to stage
|
|
|
6ec482 |
+ command = user_customattr.make_stage_command()
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ stageduser_customattr.check_restore_preserved(result)
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+ # Check that the stage user contains businesscategory
|
|
|
6ec482 |
+ command = stageduser_customattr.make_retrieve_command(all=True)
|
|
|
6ec482 |
+ result = command()
|
|
|
6ec482 |
+ assert 'BusinessCat' in result['result'][u'businesscategory']
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+
|
|
|
6ec482 |
@pytest.mark.tier1
|
|
|
6ec482 |
class TestManagers(XMLRPC_test):
|
|
|
6ec482 |
def test_staged_manager(self, user, stageduser):
|
|
|
6ec482 |
diff --git a/ipatests/test_xmlrpc/tracker/stageuser_plugin.py b/ipatests/test_xmlrpc/tracker/stageuser_plugin.py
|
|
|
6ec482 |
index c2ab1d35c0b64980eae37f75db081b948c992b00..7609664ab4f3dc3d17b33c9ba4fa855f61a8b106 100644
|
|
|
6ec482 |
--- a/ipatests/test_xmlrpc/tracker/stageuser_plugin.py
|
|
|
6ec482 |
+++ b/ipatests/test_xmlrpc/tracker/stageuser_plugin.py
|
|
|
6ec482 |
@@ -176,12 +176,13 @@ class StageUserTracker(KerberosAliasMixin, Tracker):
|
|
|
6ec482 |
|
|
|
6ec482 |
self.exists = True
|
|
|
6ec482 |
|
|
|
6ec482 |
- def check_create(self, result):
|
|
|
6ec482 |
+ def check_create(self, result, extra_keys=()):
|
|
|
6ec482 |
""" Check 'stageuser-add' command result """
|
|
|
6ec482 |
+ expected = self.filter_attrs(self.create_keys | set(extra_keys))
|
|
|
6ec482 |
assert_deepequal(dict(
|
|
|
6ec482 |
value=self.uid,
|
|
|
6ec482 |
summary=u'Added stage user "%s"' % self.uid,
|
|
|
6ec482 |
- result=self.filter_attrs(self.create_keys),
|
|
|
6ec482 |
+ result=self.filter_attrs(expected),
|
|
|
6ec482 |
), result)
|
|
|
6ec482 |
|
|
|
6ec482 |
def check_delete(self, result):
|
|
|
6ec482 |
--
|
|
|
6ec482 |
2.20.1
|
|
|
6ec482 |
|