On 19.10.2015 14:16, Martin Basti wrote:


On 19.10.2015 12:30, Martin Basti wrote:
Attribute nsaccountlock has not been processed correctly

Patch attached.



Self-NACK, more fixes required



Updated patch attached, but it still needs to improve because tests in my patch 331 are still failing.
From 7b1fa0d7b9ad8782d2dbb8e98becb6c016183e07 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Mon, 19 Oct 2015 12:21:07 +0200
Subject: [PATCH] Tests: Fix user tracker

---
 ipatests/test_xmlrpc/test_user_plugin.py | 42 ++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 18305ad02906a63baafcdf49bd2c93fa39dc4584..a7f2584e986e262ecddd669167e6a684d545d6c9 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -1649,7 +1649,7 @@ class test_denied_bind_with_expired_principal(XMLRPC_test):
 
 
 class UserTracker(Tracker):
-    """ Class for host plugin like tests """
+    """ Class for user plugin like tests """
 
     retrieve_keys = {
         u'uid', u'givenname', u'sn', u'homedirectory',
@@ -1671,7 +1671,7 @@ class UserTracker(Tracker):
     retrieve_preserved_keys = retrieve_keys - {u'memberof_group'}
     retrieve_preserved_all_keys = retrieve_all_keys - {u'memberof_group'}
 
-    create_keys = retrieve_all_keys | {
+    create_keys = (retrieve_all_keys - {u'nsaccountlock'}) | {
         u'randompassword', u'mepmanagedentry',
         u'krbextradata', u'krbpasswordexpiration', u'krblastpwdchange',
         u'krbprincipalkey', u'randompassword', u'userpassword'
@@ -1680,7 +1680,8 @@ class UserTracker(Tracker):
     activate_keys = retrieve_all_keys - {u'has_keytab', u'has_password',
                                          u'nsaccountlock', u'sshpubkeyfp'}
 
-    find_keys = retrieve_keys - {u'mepmanagedentry', u'memberof_group'}
+    find_keys = retrieve_keys - {u'mepmanagedentry', u'memberof_group',
+                                 u'manager'}
     find_all_keys = retrieve_all_keys - {u'mepmanagedentry', u'memberof_group'}
 
     def __init__(self, name, givenname, sn, **kwargs):
@@ -1692,6 +1693,17 @@ class UserTracker(Tracker):
 
         self.kwargs = kwargs
 
+    def _fix_nsaccountlock_attr(self, result):
+        # small override because user-* commands returns different type
+        # of nsaccountlock value than DS, but overall the value fits
+        # expected result
+        if u'nsaccountlock' in result:
+            if result[u'nsaccountlock'] == [u'true']:
+                result[u'nsaccountlock'] = True
+            elif result[u'nsaccountlock'] == [u'false']:
+                result[u'nsaccountlock'] = False
+
+
     def make_create_command(self, force=None):
         """ Make function that crates a user using user-add """
         return self.make_command(
@@ -1768,6 +1780,8 @@ class UserTracker(Tracker):
             has_password=False,
             mepmanagedentry=[get_group_dn(self.uid)],
             memberof_group=[u'ipausers'],
+            nsaccountlock=[u'false'],
+            preserved=[u'false']
             )
 
         for key in self.kwargs:
@@ -1811,14 +1825,7 @@ class UserTracker(Tracker):
         else:
             expected = self.filter_attrs(self.retrieve_keys)
 
-        # small override because stageuser-find returns different type
-        # of nsaccountlock value than DS, but overall the value fits
-        # expected result
-        if u'nsaccountlock' in expected:
-            if expected[u'nsaccountlock'] == [u'true']:
-                expected[u'nsaccountlock'] = True
-            elif expected[u'nsaccountlock'] == [u'false']:
-                expected[u'nsaccountlock'] = False
+        self._fix_nsaccountlock_attr(expected)
 
         assert_deepequal(dict(
             value=self.uid,
@@ -1828,14 +1835,13 @@ class UserTracker(Tracker):
 
     def check_find(self, result, all=False, raw=False):
         """ Check 'user-find' command result """
-        self.attrs[u'nsaccountlock'] = True
-        self.attrs[u'preserved'] = True
-
         if all:
             expected = self.filter_attrs(self.find_all_keys)
         else:
             expected = self.filter_attrs(self.find_keys)
 
+        self._fix_nsaccountlock_attr(expected)
+
         assert_deepequal(dict(
             count=1,
             truncated=False,
@@ -1854,10 +1860,14 @@ class UserTracker(Tracker):
 
     def check_update(self, result, extra_keys=()):
         """ Check 'user-mod' command result """
+        expected = self.filter_attrs(self.update_keys | set(extra_keys))
+
+        self._fix_nsaccountlock_attr(expected)
+
         assert_deepequal(dict(
             value=self.uid,
             summary=u'Modified user "%s"' % self.uid,
-            result=self.filter_attrs(self.update_keys | set(extra_keys))
+            result=expected,
         ), result)
 
     def create_from_staged(self, stageduser):
@@ -1915,7 +1925,7 @@ class UserTracker(Tracker):
             ), result)
 
     def track_delete(self, preserve=False):
-        """Update expected state for host deletion"""
+        """Update expected state for user deletion"""
         if preserve:
             self.exists = True
             if u'memberof_group' in self.attrs:
-- 
2.4.3

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