Hi,

here's patch with fix for failing user tests, specifically tests with renaming users.


Failures were caused by RFE Kerberos principal aliases. As part of the fix, I had to rewrite few of the tests themselves, since they used "--setattr" option rather than "--rename" option, which produces different results.


Lenka

From 18968819c48088c77786736cc52271d973e123cd Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Fri, 15 Jul 2016 17:57:53 +0200
Subject: [PATCH] Tests: Fix for failing user tests

Providing fix for failing user rename tests. Failures were caused by RFE Kerberos principal alias.
Some tests were rewritten, since they used "--setattr" option instead of "--rename", and hence didn't reflect proper behaviour of the principal aliases feature.
---
 ipatests/test_xmlrpc/test_user_plugin.py    | 31 ++++++-----------------------
 ipatests/test_xmlrpc/tracker/user_plugin.py | 10 ++++++++++
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index def522814f6c0a894f0bd8f352e110a95e5aa09a..7c27abc56cb859eb4fb710f1ff384793dfbe453c 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -316,24 +316,10 @@ class TestUpdate(XMLRPC_test):
         renameduser.ensure_missing()
         olduid = user.uid
 
-        # using user.update(dict(uid=value)) results in
-        # OverlapError: overlapping arguments and options: ['uid']
-        user.attrs.update(uid=[renameduser.uid])
-        command = user.make_update_command(
-            updates=dict(setattr=(u'uid=%s' % renameduser.uid))
-        )
-        result = command()
-        user.check_update(result)
-        user.uid = renameduser.uid
+        user.update(updates=dict(rename=renameduser.uid))
 
         # rename the test user back so it gets properly deleted
-        user.attrs.update(uid=[olduid])
-        command = user.make_update_command(
-            updates=dict(setattr=(u'uid=%s' % olduid))
-        )
-        result = command()
-        user.check_update(result)
-        user.uid = olduid
+        user.update(updates=dict(rename=olduid))
 
     def test_rename_to_the_same_value(self, user):
         """ Try to rename user to the same value """
@@ -640,18 +626,13 @@ class TestUserWithGroup(XMLRPC_test):
             if its manager is also renamed """
         renamed_name = u'renamed_npg2'
         old_name = user_npg2.uid
-        command = user_npg2.make_update_command(dict(rename=renamed_name))
-        result = command()
-        user_npg2.attrs.update(uid=[renamed_name])
-        user_npg2.check_update(result)
+
+        user_npg2.update(updates=dict(rename=renamed_name))
+
         user_npg.attrs.update(manager=[renamed_name])
         user_npg.retrieve(all=True)
 
-        command = user_npg2.make_command(
-            'user_mod', renamed_name, **dict(rename=old_name)
-        )
-        # we rename the user back otherwise the tracker is too confused
-        result = command()
+        user_npg2.update(updates=dict(rename=old_name))
 
     def test_check_if_manager_gets_removed(self, user_npg, user_npg2):
         """ Delete manager and check if it's gone from user's attributes """
diff --git a/ipatests/test_xmlrpc/tracker/user_plugin.py b/ipatests/test_xmlrpc/tracker/user_plugin.py
index 1a85e93327e5d517249fd67e208e83a922509002..fca0ab9c46b18ed145990bf04c2444701b8a3675 100644
--- a/ipatests/test_xmlrpc/tracker/user_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/user_plugin.py
@@ -196,11 +196,18 @@ class UserTracker(Tracker):
         for key, value in updates.items():
             if value is None or value is '' or value is u'':
                 del self.attrs[key]
+            elif key == 'rename':
+                new_principal = u'{0}@{1}'.format(value, self.api.env.realm)
+                self.attrs['uid'] = [value]
+                self.attrs['krbcanonicalname'] = [new_principal]
+                if new_principal not in self.attrs['krbprincipalname']:
+                    self.attrs['krbprincipalname'].append(new_principal)
             else:
                 if type(value) is list:
                     self.attrs[key] = value
                 else:
                     self.attrs[key] = [value]
+
         for key, value in expected_updates.items():
             if value is None or value is '' or value is u'':
                 del self.attrs[key]
@@ -212,6 +219,9 @@ class UserTracker(Tracker):
             extra_keys=set(updates.keys()) | set(expected_updates.keys())
         )
 
+        if 'rename' in updates:
+            self.uid = self.attrs['uid'][0]
+
     def check_create(self, result, extra_keys=()):
         """ Check 'user-add' command result """
         expected = self.filter_attrs(self.create_keys | set(extra_keys))
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to