On 16.03.2016 09:13, Martin Basti wrote:


On 15.03.2016 10:46, David Kupka wrote:
On 08/03/16 12:02, Martin Basti wrote:
https://fedorahosted.org/freeipa/ticket/5481

Patch attached.


Works for me, ACK.

Pushed to master: 4871cb5b549042f383ee883e527e773c0abe9d87
Pushed to ipa-4-3: 03743ba1d9191bf0d786116808dba4d7a3522b1f

Fix for tests.
Patch attached.
From 3110aa74401dc0872bbabe915387a13f03868e00 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 17 Mar 2016 14:24:00 +0100
Subject: [PATCH] Fix stageuser-activate - managers test

https://fedorahosted.org/freeipa/ticket/5481
---
 ipatests/test_xmlrpc/test_stageuser_plugin.py |  6 ++-
 ipatests/test_xmlrpc/test_user_plugin.py      |  2 +-
 ipatests/test_xmlrpc/tracker/user_plugin.py   | 58 ++++++++++++++-------------
 3 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_stageuser_plugin.py b/ipatests/test_xmlrpc/test_stageuser_plugin.py
index 689682c9da5fc14a7d7bc12df94b477a4c603944..0ad017cbd61ec1db009fef917ea1be4ec8f357d8 100644
--- a/ipatests/test_xmlrpc/test_stageuser_plugin.py
+++ b/ipatests/test_xmlrpc/test_stageuser_plugin.py
@@ -442,7 +442,8 @@ class TestPreserved(XMLRPC_test):
         command = user.make_find_command(
             uid=user.uid, preserved=True, all=False)
         result = command()
-        user.check_find(result, all=False)
+        user.check_find(result, all=False,
+                        expected_override=dict(preserved=True))
         user.delete()
 
     def test_search_preserved_valid_all(self, user):
@@ -451,7 +452,8 @@ class TestPreserved(XMLRPC_test):
         command = user.make_find_command(
             uid=user.uid, preserved=True, all=True)
         result = command()
-        user.check_find(result, all=True)
+        user.check_find(result, all=True,
+                        expected_override=dict(preserved=True))
         user.delete()
 
     def test_retrieve_preserved(self, user):
diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 355573138fdf35d7f54471875dc955036ec5c64d..a70b90a994a243ea98a4d09ceec9a6b0aca49545 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -691,7 +691,7 @@ class TestManagers(XMLRPC_test):
         """ Find user by his manager's UID """
         command = user.make_find_command(manager=user2.uid)
         result = command()
-        user.check_find(result)
+        user.check_find(result, expected_override=dict(manager=[user2.uid]))
 
     def test_delete_both_user_and_manager(self, user, user2):
         """ Delete both user and its manager at once """
diff --git a/ipatests/test_xmlrpc/tracker/user_plugin.py b/ipatests/test_xmlrpc/tracker/user_plugin.py
index c72e17424da7630b6ed239ac42e7baec59be278c..216112db50ff909846e7bb900e76e961177cd10b 100644
--- a/ipatests/test_xmlrpc/tracker/user_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/user_plugin.py
@@ -7,7 +7,7 @@ from ipapython.dn import DN
 
 import six
 
-from ipatests.util import assert_deepequal, get_group_dn, get_user_dn
+from ipatests.util import assert_deepequal, get_group_dn
 from ipatests.test_xmlrpc import objectclasses
 from ipatests.test_xmlrpc.xmlrpc_test import (
     fuzzy_digits, fuzzy_uuid, raises_exact)
@@ -21,24 +21,26 @@ class UserTracker(Tracker):
     """ Class for host plugin like tests """
 
     retrieve_keys = {
-        u'uid', u'givenname', u'sn', u'homedirectory',
-        u'loginshell', u'uidnumber', u'gidnumber', u'mail', u'ou',
-        u'telephonenumber', u'title', u'memberof',
+        u'dn', u'uid', u'givenname', u'sn', u'homedirectory', u'loginshell',
+        u'uidnumber', u'gidnumber', u'mail', u'ou',
+        u'telephonenumber', u'title', u'memberof', u'nsaccountlock',
         u'memberofindirect', u'ipauserauthtype', u'userclass',
         u'ipatokenradiusconfiglink', u'ipatokenradiususername',
-        u'krbprincipalexpiration', u'usercertificate', u'dn', u'has_keytab',
-        u'has_password', u'street', u'postalcode', u'facsimiletelephonenumber',
-        u'carlicense', u'ipasshpubkey', u'sshpubkeyfp', u'nsaccountlock',
-        u'memberof_group', u'l', u'mobile', u'krbextradata',
-        u'krblastpwdchange', u'krbpasswordexpiration', u'pager', u'st',
-        u'manager', u'preserved'}
+        u'krbprincipalexpiration', u'usercertificate;binary',
+        u'has_keytab', u'has_password', u'memberof_group', u'sshpubkeyfp',
+    }
 
     retrieve_all_keys = retrieve_keys | {
-        u'cn', u'ipauniqueid', u'objectclass', u'mepmanagedentry',
+        u'usercertificate', u'street', u'postalcode',
+        u'facsimiletelephonenumber', u'carlicense', u'ipasshpubkey',
+        u'l', u'mobile', u'krbextradata', u'krblastpwdchange',
+        u'krbpasswordexpiration', u'pager', u'st', u'manager', u'cn',
+        u'ipauniqueid', u'objectclass', u'mepmanagedentry',
         u'displayname', u'gecos', u'initials', u'krbprincipalname',
         u'preserved'}
 
-    retrieve_preserved_keys = retrieve_keys - {u'memberof_group'}
+    retrieve_preserved_keys = (retrieve_keys - {u'memberof_group'}) | {
+        u'preserved'}
     retrieve_preserved_all_keys = retrieve_all_keys - {u'memberof_group'}
 
     create_keys = retrieve_all_keys | {
@@ -47,8 +49,7 @@ class UserTracker(Tracker):
     create_keys = create_keys - {u'nsaccountlock'}
 
     update_keys = retrieve_keys - {u'dn'}
-    activate_keys = retrieve_all_keys - {u'has_keytab', u'has_password',
-                                         u'nsaccountlock', u'sshpubkeyfp'}
+    activate_keys = retrieve_keys
 
     find_keys = retrieve_keys - {u'mepmanagedentry', u'memberof_group'}
     find_all_keys = retrieve_all_keys
@@ -250,7 +251,8 @@ class UserTracker(Tracker):
             result=expected,
         ), result)
 
-    def check_find(self, result, all=False, pkey_only=False, raw=False):
+    def check_find(self, result, all=False, pkey_only=False, raw=False,
+                   expected_override=None):
         """ Check 'user-find' command result """
         if all:
             if u'preserved' not in self.attrs:
@@ -270,6 +272,10 @@ class UserTracker(Tracker):
             elif expected[u'nsaccountlock'] == [u'false']:
                 expected[u'nsaccountlock'] = False
 
+        if expected_override:
+            assert isinstance(expected_override, dict)
+            expected.update(expected_override)
+
         assert_deepequal(dict(
             count=1,
             truncated=False,
@@ -327,9 +333,7 @@ class UserTracker(Tracker):
         self.attrs[u'mepmanagedentry'] = None
         self.attrs[u'dn'] = self.dn
         self.attrs[u'ipauniqueid'] = [fuzzy_uuid]
-        self.attrs[u'memberof'] = [u'cn=ipausers,%s,%s' % (
-            api.env.container_group, api.env.basedn
-            )]
+        self.attrs[u'memberof_group'] = [u'ipausers']
         self.attrs[u'mepmanagedentry'] = [u'cn=%s,%s,%s' % (
             self.uid, api.env.container_group, api.env.basedn
             )]
@@ -343,6 +347,7 @@ class UserTracker(Tracker):
                 self.attrs[u'ipasshpubkey'] = [str(
                     self.kwargs[u'ipasshpubkey']
                     )]
+        self.attrs[u'nsaccountlock'] = [u'false']
 
     def check_activate(self, result):
         """ Check 'stageuser-activate' command result """
@@ -351,16 +356,13 @@ class UserTracker(Tracker):
             summary=u'Stage user %s activated' % self.uid,
             result=self.filter_attrs(self.activate_keys))
 
-        if 'manager' in expected['result']:
-            expected['result']['manager'] = [
-                unicode(get_user_dn(expected['result']['manager'][0]))]
-
-        # work around to eliminate inconsistency in returned objectclass
-        # (case sensitive assertion)
-        expected['result']['objectclass'] = [item.lower() for item in
-                                             expected['result']['objectclass']]
-        result['result']['objectclass'] = [item.lower() for item in
-                                           result['result']['objectclass']]
+        # small override because stageuser-find returns different
+        # type of nsaccountlock value than DS, but overall the value
+        # fits expected result
+        if expected['result'][u'nsaccountlock'] == [u'true']:
+            expected['result'][u'nsaccountlock'] = True
+        elif expected['result'][u'nsaccountlock'] == [u'false']:
+            expected['result'][u'nsaccountlock'] = False
 
         assert_deepequal(expected, result)
 
-- 
2.5.0

-- 
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