mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
xmlrpc test: add test for preserved > stage user
When moving a preserved user to the stage area, check that the custom attributes are not lost ( = the attr for which there is no specific user_stage option). Test scenario: - add a stage user with --setattr "businesscategory=value" - activate the user, check that businesscategory is still present - delete (preserve) the user, check that attr is still present - stage the user, check that attr is still present Related: https://pagure.io/freeipa/issue/7597 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
27baf35013
commit
8ebbb271a5
@ -129,6 +129,17 @@ def stageduser_notposix(request):
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def stageduser_customattr(request):
|
||||
tracker = StageUserTracker(u'customattr', u'customattr', u'customattr',
|
||||
setattr=u'businesscategory=BusinessCat')
|
||||
tracker.track_create()
|
||||
tracker.attrs.update(
|
||||
businesscategory=[u'BusinessCat']
|
||||
)
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def user(request):
|
||||
tracker = UserTracker(u'auser1', u'active', u'user')
|
||||
@ -574,6 +585,59 @@ class TestPreserved(XMLRPC_test):
|
||||
stageduser.delete()
|
||||
|
||||
|
||||
@pytest.mark.tier1
|
||||
class TestCustomAttr(XMLRPC_test):
|
||||
"""Test for pagure ticket 7597
|
||||
|
||||
When a staged user is activated, preserved and finally staged again,
|
||||
the custom attributes are lost.
|
||||
"""
|
||||
def test_stageduser_customattr(self, stageduser_customattr):
|
||||
# Create a staged user with attributes not accessible
|
||||
# through the options
|
||||
# --setattr is needed here
|
||||
command = stageduser_customattr.make_create_command()
|
||||
result = command()
|
||||
stageduser_customattr.check_create(result, [u'businesscategory'])
|
||||
|
||||
# Activate the staged user
|
||||
user_customattr = UserTracker(
|
||||
stageduser_customattr.uid, stageduser_customattr.givenname,
|
||||
stageduser_customattr.sn)
|
||||
user_customattr.create_from_staged(stageduser_customattr)
|
||||
user_customattr.attrs[u'businesscategory'] = [u'BusinessCat']
|
||||
|
||||
command = stageduser_customattr.make_activate_command()
|
||||
result = command()
|
||||
user_customattr.check_activate(result)
|
||||
|
||||
# Check that the user contains businesscategory
|
||||
command = user_customattr.make_retrieve_command(all=True)
|
||||
result = command()
|
||||
assert 'BusinessCat' in result['result'][u'businesscategory']
|
||||
|
||||
# delete the user with --preserve
|
||||
command = user_customattr.make_delete_command(no_preserve=False,
|
||||
preserve=True)
|
||||
result = command()
|
||||
user_customattr.check_delete(result)
|
||||
|
||||
# Check that the preserved user contains businesscategory
|
||||
command = user_customattr.make_retrieve_command(all=True)
|
||||
result = command()
|
||||
assert 'BusinessCat' in result['result'][u'businesscategory']
|
||||
|
||||
# Move the user from preserved to stage
|
||||
command = user_customattr.make_stage_command()
|
||||
result = command()
|
||||
stageduser_customattr.check_restore_preserved(result)
|
||||
|
||||
# Check that the stage user contains businesscategory
|
||||
command = stageduser_customattr.make_retrieve_command(all=True)
|
||||
result = command()
|
||||
assert 'BusinessCat' in result['result'][u'businesscategory']
|
||||
|
||||
|
||||
@pytest.mark.tier1
|
||||
class TestManagers(XMLRPC_test):
|
||||
def test_staged_manager(self, user, stageduser):
|
||||
|
@ -177,12 +177,13 @@ class StageUserTracker(KerberosAliasMixin, Tracker):
|
||||
|
||||
self.exists = True
|
||||
|
||||
def check_create(self, result):
|
||||
def check_create(self, result, extra_keys=()):
|
||||
""" Check 'stageuser-add' command result """
|
||||
expected = self.filter_attrs(self.create_keys | set(extra_keys))
|
||||
assert_deepequal(dict(
|
||||
value=self.uid,
|
||||
summary=u'Added stage user "%s"' % self.uid,
|
||||
result=self.filter_attrs(self.create_keys),
|
||||
result=self.filter_attrs(expected),
|
||||
), result)
|
||||
|
||||
def check_delete(self, result):
|
||||
|
Loading…
Reference in New Issue
Block a user