Re: [Freeipa-devel] [PATCH 0006] Refactor test_hostgroup_plugin

2016-03-07 Thread Filip Škola
Sorry, forgot to cc you, Milan.

F.

On Tue, 22 Dec 2015 05:57:50 -0500 (EST)
Filip Skola  wrote:

> And also sending refactored hostgroup plugin test.
> 
> F

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


Re: [Freeipa-devel] [PATCH 0002] Refactor test_group_plugin

2015-12-13 Thread Filip Škola
On Mon, 7 Dec 2015 17:49:18 +0100
Milan Kubík  wrote:

> On 12/03/2015 08:15 PM, Filip Škola wrote:
> > On Mon, 30 Nov 2015 17:18:30 +0100
> > Milan Kubík  wrote:
> >
> >> On 11/23/2015 04:42 PM, Filip Škola wrote:
> >>> Sending updated patch.
> >>>
> >>> F.
> >>>
> >>> On Mon, 23 Nov 2015 14:59:34 +0100
> >>> Filip Škola  wrote:
> >>>
> >>>> Found couple of issues (broke some dependencies).
> >>>>
> >>>> NACK
> >>>>
> >>>> F.
> >>>>
> >>>> On Fri, 20 Nov 2015 13:56:36 +0100
> >>>> Filip Škola  wrote:
> >>>>
> >>>>> Another one.
> >>>>>
> >>>>> F.
> >>>
> >> Hi, the tests look good. Few remarks, though.
> >>
> >> 1. Please, use the shortes copyright notice in new modules.
> >>
> >>   #
> >>   # Copyright (C) 2015  FreeIPA Contributors see COPYING for
> >> license #
> >>
> >> 2. The tests `test_group_remove_group_from_protected_group` and
> >> `test_group_full_set_of_objectclass_not_available_post_detach`
> >> were not ported. Please, include them in the patch.
> >>
> >> Also, for less hassle, please rebase your patches on top of
> >> freeipa-mkubik-0025-3-Separated-Tracker-implementations-into-standalone-pa.patch
> >> Which changes the location of tracker implementations and prevents
> >> circular imports.
> >>
> >> Thanks.
> >>
> >
> >
> > Hi,
> >
> > these cases are there, in corresponding classes. They are marked
> > with the original comments. (However I can move them to separate
> > class if desirable.)
> >
> > The copyright notice is changed. Also included a few changes in the
> > test with user without private group.
> >
> > Filip
> NACK
> 
> linter:
> * Module tracker.group_plugin
> ipatests/test_xmlrpc/tracker/group_plugin.py:257: 
> [E0102(function-redefined), GroupTracker.check_remove_member] method 
> already defined line 253)
> 
> Probably a leftover after the rebase made on top of my patch. Please
> fix it. You can check youch changes by make-lint script before
> sending them.
> 
> Thanks
> 


Hi,

I learned to use make-lint!

Thanks,
F.
>From 2e231e285215818bbe1e06aeba573d43c86fab8b Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Mon, 9 Nov 2015 16:48:55 +0100
Subject: [PATCH] Refactor test_group_plugin, use GroupTracker for tests

---
 ipatests/test_xmlrpc/test_group_plugin.py | 1728 +
 ipatests/test_xmlrpc/test_stageuser_plugin.py |4 +-
 ipatests/test_xmlrpc/tracker/group_plugin.py  |  149 ++-
 3 files changed, 736 insertions(+), 1145 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_group_plugin.py b/ipatests/test_xmlrpc/test_group_plugin.py
index f2bd0f4b9c8d517500b63cf49a8a7bc7c29aab6e..1ac278c7e224b8dd8793dc56c299dcae88aa78a3 100644
--- a/ipatests/test_xmlrpc/test_group_plugin.py
+++ b/ipatests/test_xmlrpc/test_group_plugin.py
@@ -1,6 +1,7 @@
 # Authors:
 #   Rob Crittenden 
 #   Pavel Zuna 
+#   Filip Skola 
 #
 # Copyright (C) 2008  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -26,1137 +27,648 @@ import pytest
 
 from ipalib import api, errors
 from ipatests.test_xmlrpc import objectclasses
-from ipatests.test_xmlrpc.xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_set_ci,
- add_sid, add_oc, XMLRPC_test, raises_exact)
+from ipatests.test_xmlrpc.xmlrpc_test import (
+fuzzy_digits, fuzzy_uuid, fuzzy_set_ci, add_sid, add_oc,
+XMLRPC_test, raises_exact
+)
 from ipapython.dn import DN
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
 
+from ipatests.test_xmlrpc.tracker.group_plugin import GroupTracker
 from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
-from ipatests.util import assert_deepequal
+from ipatests.test_xmlrpc.test_user_plugin import user, user_npg2
+from ipatests.util import assert_deepequal, get_group_dn
 
 
-group1 = u'testgroup1'
-group2 = u'testgroup2'
-group3 = u'testgroup3'
-renamedgroup1 = u'testgroup'
-user1 = u'tuser1'
+notagroup = u'notagroup'
+renamedgroup1 = u'renamedgroup'
+invalidgroup1 = u'+tgroup1'
+external_sid1 = u'S-1-1-123456-789-1'
 
-invalidgroup1=u'+tgroup1'
 
-# When adding external SID member to a group we can't test
-# it fully due to possibly missing Samba 4 python bindings
-# and/or not configured AD trusts. Thus, we'll use incorrect
-# SID value to merely test that proper excepti

Re: [Freeipa-devel] [PATCH] 0001 Refactor test_user_plugin

2015-12-10 Thread Filip Škola
Hi,

this if fixed. Also issues with test_stageuser_plugin caused by
UserTracker changes should be fixed here.

Filip


On Mon, 7 Dec 2015 09:29:31 -0500 (EST)
Aleš Mareček  wrote:

> NACK.
> 
> $ ./make-lint 
> * Module ipatests.test_xmlrpc.test_user_plugin
> ipatests/test_xmlrpc/test_user_plugin.py:42:
> [E0611(no-name-in-module), ] No name 'ldaptracker' in module
> 'ipatests.test_xmlrpc')
> 
> $ grep ldaptracker ipatests/test_xmlrpc/test_user_plugin.py 
> from ipatests.test_xmlrpc.ldaptracker import Tracker
> $ ls ipatests/test_xmlrpc/ldaptracker*
> ls: cannot access ipatests/test_xmlrpc/ldaptracker*: No such file or
> directory
> 
> 
> - Original Message -
> > From: "Filip Škola" 
> > To: "Milan Kubík" 
> > Cc: freeipa-devel@redhat.com
> > Sent: Thursday, December 3, 2015 5:38:43 PM
> > Subject: Re: [Freeipa-devel] [PATCH] 0001 Refactor test_user_plugin
> > 
> > Hi,
> > 
> > sending corrected version.
> > 
> > F.
> > 
> > On Thu, 12 Nov 2015 14:03:19 +0100
> > Milan Kubík  wrote:
> > 
> > > On 11/10/2015 12:13 PM, Filip Škola wrote:
> > > > Hi,
> > > >
> > > > fixed.
> > > >
> > > > F.
> > > >
> > > > On Tue, 10 Nov 2015 10:52:45 +0100
> > > > Milan Kubík  wrote:
> > > >
> > > >> On 11/09/2015 04:35 PM, Filip Škola wrote:
> > > >>> Another patch was applied in the meantime.
> > > >>>
> > > >>> Attaching an updated version.
> > > >>>
> > > >>> F.
> > > >>>
> > > >>> On Mon, 9 Nov 2015 13:35:02 +0100
> > > >>> Milan Kubík  wrote:
> > > >>>
> > > >>>> On 11/06/2015 11:32 AM, Filip Škola wrote:
> > > >>>> Hi,
> > > >>>> the patch doesn't apply.
> > > >>>>
> > > >> Please fix this.
> > > >>
> > > >>   ipatests/test_xmlrpc/test_user_plugin.py:1419:
> > > >> [E0602(undefined-variable),
> > > >> TestDeniedBindWithExpiredPrincipal.teardown_class] Undefined
> > > >> variable 'user1')
> > > >>
> > > >> Also, use the version numbers for your changed patches.
> > > >>
> > > >
> > > >
> > > Thanks for the patch. Several issues:
> > > 
> > > 1. Use dict.items instead of dict.iteritems, for python3
> > > compatibility
> > > 
> > > 2. What is the purpose of TestPrepare class? The 'purge' methods
> > > do not call any ipa commands.
> > > Tracker.make_fixture should be used to make the Tracked resources
> > > clean themselves up when they're out of scope.
> > > 
> > > 3. Why reference the resources by hardcoded name if they have a
> > > fixture representation?
> > > 
> > > 4. Rewrite {create,delete}_test_group to a fixture. You may want
> > > to use different scope (or not).
> > > 
> > > 5. In `def atest_rename_to_invalid_login(self, user):` - use
> > > pytest.skipif decorator and provide a reason if you must,
> > > do not obfuscate method name in order not to run it.
> > > 
> > > 
> > 
> > 
> > --
> > 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

>From 7867154636c4b77ea7f570eb5c78e0573ff9c430 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 6 Nov 2015 10:57:37 +0100
Subject: [PATCH] Refactor test_user_plugin, use UserTracker for tests

---
 ipatests/test_xmlrpc/test_user_plugin.py| 2387 ++-
 ipatests/test_xmlrpc/tracker/user_plugin.py |  172 +-
 2 files changed, 1039 insertions(+), 1520 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 084fb83c42d362204ff4547357226c8f56d217fb..155e77446230786fbbd2c137674dbed29c4350c7 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -2,6 +2,7 @@
 #   Rob Crittenden 
 #   Pavel Zuna 
 #   Jason Gerard DeRose 
+#   Filip Skola 
 #
 # Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -23,6 +24,7 @@
 Test the `ipalib/plugins/user.py` module.
 """
 
+import pytest
 import datetime
 import ldap
 import re
@@ -30,42 +32,42 @@ import re
 from ipalib

Re: [Freeipa-devel] [PATCH 0004] Refactor test_attr

2015-12-07 Thread Filip Škola
Now the tier marker have lost somewhere on the way... which is
corrected in this patch.

/me apologizes for the noise

F.

On Mon, 7 Dec 2015 13:00:41 +0100
Filip Škola  wrote:

> Self-NACK, resubmitting with the last commit which includes
> UserTracker from the right location...
> 
> F.
> 
> On Fri, 4 Dec 2015 16:24:16 +0100
> Filip Škola  wrote:
> 
> > Hi,
> > 
> > sending a new version of test_attr.
> > 
> > F.

>From 13af34b6f8fa4d419673578cfd55c9f87fd651fc Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 27 Nov 2015 15:41:47 +0100
Subject: [PATCH] Refactor test_attr

---
 ipatests/test_xmlrpc/test_attr.py | 667 --
 1 file changed, 280 insertions(+), 387 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_attr.py b/ipatests/test_xmlrpc/test_attr.py
index 9248ce0448cfd08fcfe194d402c6819a283c2c07..83a51b56b82731d55c5fbdfa2b4f3a1097ebc340 100644
--- a/ipatests/test_xmlrpc/test_attr.py
+++ b/ipatests/test_xmlrpc/test_attr.py
@@ -1,5 +1,6 @@
 # Authors:
 #   Rob Crittenden 
+#   Filip Skola 
 #
 # Copyright (C) 2010  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -22,397 +23,289 @@ Test --setattr and --addattr and other attribute-specific issues
 """
 
 from ipalib import errors
-from ipatests.test_xmlrpc.xmlrpc_test import Declarative
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
+from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test, raises_exact
+from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
 import pytest
 
-user1=u'tuser1'
+
+@pytest.fixture(scope='class')
+def user(request):
+tracker = UserTracker(name=u'user1', givenname=u'Test', sn=u'User1')
+return tracker.make_fixture(request)
+
+
+@pytest.mark.tier1
+class TestAttrOnUser(XMLRPC_test):
+def test_add_user_with_singlevalue_addattr(self):
+""" Try to add a user with single-value attribute
+set via option and --addattr """
+user = UserTracker(name=u'user', givenname=u'Test', sn=u'User1',
+   addattr=u'sn=User2')
+command = user.make_create_command()
+with raises_exact(errors.OnlyOneValueAllowed(attr='sn')):
+command()
+
+def test_create_user(self, user):
+""" Create a test user """
+user.ensure_exists()
+
+def test_change_givenname_add_mail_user(self, user):
+""" Change givenname, add mail to user """
+user.ensure_exists()
+user.update(
+dict(setattr=(u'givenname=Finkle', u'mail=t...@example.com')),
+dict(givenname=[u'Finkle'], mail=[u't...@example.com'], setattr='')
+)
+
+def test_add_another_mail_user(self, user):
+""" Add another mail to user """
+user.ensure_exists()
+update = u'te...@example.com'
+user.attrs['mail'].append(update)
+user.update(dict(addattr='mail='+update),
+dict(addattr=''))
+
+def test_add_two_phone_numbers_at_once_user(self, user):
+""" Add two phone numbers at once to user """
+user.ensure_exists()
+update1 = u'410-555-1212'
+update2 = u'301-555-1212'
+user.update(
+dict(setattr=u'telephoneNumber='+update1,
+ addattr=u'telephoneNumber='+update2),
+dict(addattr='', setattr='',
+ telephonenumber=[update1, update2]))
+
+def test_go_from_two_phone_numbers_to_one(self, user):
+""" Go from two phone numbers to one for user """
+update = u'301-555-1212'
+user.ensure_exists()
+user.update(dict(setattr=u'telephoneNumber='+update),
+dict(setattr='', telephonenumber=[update]))
+
+def test_add_two_more_phone_numbers(self, user):
+""" Add two more phone numbers to user """
+user.ensure_exists()
+update1 = u'703-555-1212'
+update2 = u'202-888-9833'
+user.attrs['telephonenumber'].extend([update1, update2])
+user.update(dict(addattr=(u'telephoneNumber='+update1,
+  u'telephoneNumber='+update2)),
+dict(addattr=''))
+
+def test_delete_one_phone_number(self, user):
+""" Delete one phone number for user """
+user.ensure_exists()
+update = u'301

Re: [Freeipa-devel] [PATCH 0004] Refactor test_attr

2015-12-07 Thread Filip Škola
Self-NACK, resubmitting with the last commit which includes UserTracker
from the right location...

F.

On Fri, 4 Dec 2015 16:24:16 +0100
Filip Škola  wrote:

> Hi,
> 
> sending a new version of test_attr.
> 
> F.
>From 786b0004f3793bb557b8c9b2b7e034784969da8e Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 27 Nov 2015 15:41:47 +0100
Subject: [PATCH] Refactor test_attr

---
 ipatests/test_xmlrpc/test_attr.py | 671 --
 1 file changed, 281 insertions(+), 390 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_attr.py b/ipatests/test_xmlrpc/test_attr.py
index 9248ce0448cfd08fcfe194d402c6819a283c2c07..cb5c47910794852dcd7202ca73b0e9b9b5961573 100644
--- a/ipatests/test_xmlrpc/test_attr.py
+++ b/ipatests/test_xmlrpc/test_attr.py
@@ -1,5 +1,6 @@
 # Authors:
 #   Rob Crittenden 
+#   Filip Skola 
 #
 # Copyright (C) 2010  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -22,397 +23,287 @@ Test --setattr and --addattr and other attribute-specific issues
 """
 
 from ipalib import errors
-from ipatests.test_xmlrpc.xmlrpc_test import Declarative
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
+from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test, raises_exact
+from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
 import pytest
 
-user1=u'tuser1'
-
-
-@pytest.mark.tier1
-class test_attr(Declarative):
-
-cleanup_commands = [
-('user_del', [user1], {}),
-]
-
-tests = [
-
-dict(
-desc='Try to add user %r with single-value attribute set via '
- 'option and --addattr' % user1,
-command=(
-'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
-addattr=u'sn=User2')
-),
-expected=errors.OnlyOneValueAllowed(attr='sn'),
-),
-
-dict(
-desc='Create %r' % user1,
-command=(
-'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
-setattr=None)
-),
-expected=dict(
-value=user1,
-summary=u'Added user "tuser1"',
-result=get_user_result(user1, u'Test', u'User1', 'add'),
-),
-),
-
-
-dict(
-desc='Change givenname, add mail %r' % user1,
-command=(
-'user_mod', [user1], dict(setattr=(u'givenname=Finkle', u'mail=t...@example.com'))
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Add another mail %r' % user1,
-command=(
-'user_mod', [user1], dict(addattr=u'mail=te...@example.com')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Add two phone numbers at once %r' % user1,
-command=(
-'user_mod', [user1], dict(setattr=u'telephoneNumber=410-555-1212', addattr=u'telephoneNumber=301-555-1212')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@example.com'],
-telephonenumber=[u'410-555-1212', u'301-555-1212'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Go from two phone numbers to one %r' % user1,
-command=(
-'user_mod', [user1], dict(setattr=u'telephoneNumber=301-555-1212')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@e

[Freeipa-devel] [PATCH 0004] Refactor test_attr

2015-12-04 Thread Filip Škola
Hi,

sending a new version of test_attr.

F.>From e1c0cf5dacc5624c9678458e3293a146a98729a5 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 27 Nov 2015 15:41:47 +0100
Subject: [PATCH] Refactor test_attr

---
 ipatests/test_xmlrpc/test_attr.py | 671 --
 1 file changed, 281 insertions(+), 390 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_attr.py b/ipatests/test_xmlrpc/test_attr.py
index 9248ce0448cfd08fcfe194d402c6819a283c2c07..125e0830aa00bb3960deb6144b8c76937cc2f883 100644
--- a/ipatests/test_xmlrpc/test_attr.py
+++ b/ipatests/test_xmlrpc/test_attr.py
@@ -1,5 +1,6 @@
 # Authors:
 #   Rob Crittenden 
+#   Filip Skola 
 #
 # Copyright (C) 2010  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -22,397 +23,287 @@ Test --setattr and --addattr and other attribute-specific issues
 """
 
 from ipalib import errors
-from ipatests.test_xmlrpc.xmlrpc_test import Declarative
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
+from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test, raises_exact
+from ipatests.test_xmlrpc.test_user_plugin import UserTracker
 import pytest
 
-user1=u'tuser1'
-
-
-@pytest.mark.tier1
-class test_attr(Declarative):
-
-cleanup_commands = [
-('user_del', [user1], {}),
-]
-
-tests = [
-
-dict(
-desc='Try to add user %r with single-value attribute set via '
- 'option and --addattr' % user1,
-command=(
-'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
-addattr=u'sn=User2')
-),
-expected=errors.OnlyOneValueAllowed(attr='sn'),
-),
-
-dict(
-desc='Create %r' % user1,
-command=(
-'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
-setattr=None)
-),
-expected=dict(
-value=user1,
-summary=u'Added user "tuser1"',
-result=get_user_result(user1, u'Test', u'User1', 'add'),
-),
-),
-
-
-dict(
-desc='Change givenname, add mail %r' % user1,
-command=(
-'user_mod', [user1], dict(setattr=(u'givenname=Finkle', u'mail=t...@example.com'))
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Add another mail %r' % user1,
-command=(
-'user_mod', [user1], dict(addattr=u'mail=te...@example.com')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Add two phone numbers at once %r' % user1,
-command=(
-'user_mod', [user1], dict(setattr=u'telephoneNumber=410-555-1212', addattr=u'telephoneNumber=301-555-1212')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@example.com'],
-telephonenumber=[u'410-555-1212', u'301-555-1212'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Go from two phone numbers to one %r' % user1,
-command=(
-'user_mod', [user1], dict(setattr=u'telephoneNumber=301-555-1212')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@example.com'],
-telephonenumber=[u'301-555-1212'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Add two more phone numbers %r' % user1,
-command=(
-'user_mod', [user1], dict(addattr=(u'telephoneNumber=703-555-1212', u'telephoneNumber=202-888-9833'))
-),
-expected=dict(
-result=get_user_result(
-user1, u'Finkle', u'User1', 'mod',
-mail=[u't...@example.com', u'te...@example.com'],
-telephonenumber=[u'301-555-1212', u'703-555-1212',
- u'202-888-9833'],
-),
-summary=u'Modified user "tuser

Re: [Freeipa-devel] [PATCH 0003] Refactor test_replace

2015-12-04 Thread Filip Škola
On Fri, 4 Dec 2015 10:08:40 +0100
Milan Kubík  wrote:

> On 12/04/2015 10:04 AM, Filip Škola wrote:
> > Hi,
> >
> > sending rather short one this time.
> >
> > F.
> NACK, UserTracker is implemented in 
> ipatests.test_xmlrpc.tracker.user_plugin.
> 

Ah, sorry for this.


F.
>From 1bffd8f743de9c8c16744a7451311bdb14549fe1 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Tue, 24 Nov 2015 14:34:03 +0100
Subject: [PATCH] Refactor test_replace

---
 ipatests/test_xmlrpc/test_replace.py | 174 ++-
 1 file changed, 48 insertions(+), 126 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_replace.py b/ipatests/test_xmlrpc/test_replace.py
index 1420e7d87f8f2f5d371b1f2fc093bcc062670537..76f7d1c2c7c7c43387abbbc531c3c9df30cd90ae 100644
--- a/ipatests/test_xmlrpc/test_replace.py
+++ b/ipatests/test_xmlrpc/test_replace.py
@@ -1,5 +1,6 @@
 # Authors:
 #   Rob Crittenden 
+#   Filip Skola 
 #
 # Copyright (C) 2011  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -25,134 +26,55 @@ Note that member management in other tests also exercises the
 gen_modlist code.
 """
 
-from ipatests.test_xmlrpc.xmlrpc_test import Declarative
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
+
+from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
+from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
 import pytest
 
-user1=u'tuser1'
+
+@pytest.fixture(scope='class')
+def user(request):
+tracker = UserTracker(
+name=u'user1', givenname=u'Test', sn=u'User1',
+mail=[u'te...@example.com', u'te...@example.com']
+)
+return tracker.make_fixture(request)
 
 
 @pytest.mark.tier1
-class test_replace(Declarative):
-
-cleanup_commands = [
-('user_del', [user1], {}),
-]
-
-tests = [
-
-dict(
-desc='Create %r with 2 e-mail accounts' % user1,
-command=(
-'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
-mail=[u'te...@example.com', u'te...@example.com'])
-),
-expected=dict(
-value=user1,
-summary=u'Added user "tuser1"',
-result=get_user_result(
-user1, u'Test', u'User1', 'add',
-mail=[u'te...@example.com', u'te...@example.com'],
-),
-),
-),
-
-
-dict(
-desc='Drop one e-mail account, add another to %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=[u'te...@example.com', u'te...@example.com'])
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-mail=[u'te...@example.com', u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Set mail to a new single value %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=u'te...@example.com')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-mail=[u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Set mail to three new values %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=[u'te...@example.com', u'te...@example.com', u'te...@example.com'])
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-mail=[u'te...@example.com', u'te...@example.com',
-  u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Remove all mail values %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=u'')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod'

[Freeipa-devel] [PATCH 0003] Refactor test_replace

2015-12-04 Thread Filip Škola
Hi,

sending rather short one this time.

F.
>From 2b8718e0423bfca737b7a33678521e4e08007191 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Tue, 24 Nov 2015 14:34:03 +0100
Subject: [PATCH] Refactor test_replace

---
 ipatests/test_xmlrpc/test_replace.py | 174 ++-
 1 file changed, 48 insertions(+), 126 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_replace.py b/ipatests/test_xmlrpc/test_replace.py
index 1420e7d87f8f2f5d371b1f2fc093bcc062670537..2a882565f4b998355bda6e1d25303f4a1a8c8edd 100644
--- a/ipatests/test_xmlrpc/test_replace.py
+++ b/ipatests/test_xmlrpc/test_replace.py
@@ -1,5 +1,6 @@
 # Authors:
 #   Rob Crittenden 
+#   Filip Skola 
 #
 # Copyright (C) 2011  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -25,134 +26,55 @@ Note that member management in other tests also exercises the
 gen_modlist code.
 """
 
-from ipatests.test_xmlrpc.xmlrpc_test import Declarative
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
+
+from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
+from ipatests.test_xmlrpc.test_user_plugin import UserTracker
 import pytest
 
-user1=u'tuser1'
+
+@pytest.fixture(scope='class')
+def user(request):
+tracker = UserTracker(
+name=u'user1', givenname=u'Test', sn=u'User1',
+mail=[u'te...@example.com', u'te...@example.com']
+)
+return tracker.make_fixture(request)
 
 
 @pytest.mark.tier1
-class test_replace(Declarative):
-
-cleanup_commands = [
-('user_del', [user1], {}),
-]
-
-tests = [
-
-dict(
-desc='Create %r with 2 e-mail accounts' % user1,
-command=(
-'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
-mail=[u'te...@example.com', u'te...@example.com'])
-),
-expected=dict(
-value=user1,
-summary=u'Added user "tuser1"',
-result=get_user_result(
-user1, u'Test', u'User1', 'add',
-mail=[u'te...@example.com', u'te...@example.com'],
-),
-),
-),
-
-
-dict(
-desc='Drop one e-mail account, add another to %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=[u'te...@example.com', u'te...@example.com'])
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-mail=[u'te...@example.com', u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Set mail to a new single value %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=u'te...@example.com')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-mail=[u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Set mail to three new values %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=[u'te...@example.com', u'te...@example.com', u'te...@example.com'])
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-mail=[u'te...@example.com', u'te...@example.com',
-  u'te...@example.com'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Remove all mail values %r' % user1,
-command=(
-'user_mod', [user1], dict(mail=u'')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-omit=['mail'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Ensure single-value mods work too, replace initials %r' % user1,
-command=(
-'user_mod', [user1], dict(initials=u'ABC')
-),
-expected=dict(
-result=get_user_result(
-user1, u'Test', u'User1', 'mod',
-initials=[u'ABC'],
-omit=['mail'],
-),
-summary=u'Modified user "tuser1"',
-value=user1,
-),
-),
-
-
-dict(
-desc='Drop a single-value attribute %r' % user1,
-command=(
-'user_mod', [user1], dict(initials=u'')
-),
-expected=dict(
-   

Re: [Freeipa-devel] [PATCH 0002] Refactor test_group_plugin

2015-12-03 Thread Filip Škola
On Mon, 30 Nov 2015 17:18:30 +0100
Milan Kubík  wrote:

> On 11/23/2015 04:42 PM, Filip Škola wrote:
> > Sending updated patch.
> >
> > F.
> >
> > On Mon, 23 Nov 2015 14:59:34 +0100
> > Filip Škola  wrote:
> >
> >> Found couple of issues (broke some dependencies).
> >>
> >> NACK
> >>
> >> F.
> >>
> >> On Fri, 20 Nov 2015 13:56:36 +0100
> >> Filip Škola  wrote:
> >>
> >>> Another one.
> >>>
> >>> F.
> >>
> >
> >
> 
> Hi, the tests look good. Few remarks, though.
> 
> 1. Please, use the shortes copyright notice in new modules.
> 
>  #
>  # Copyright (C) 2015  FreeIPA Contributors see COPYING for
> license #
> 
> 2. The tests `test_group_remove_group_from_protected_group` and 
> `test_group_full_set_of_objectclass_not_available_post_detach`
> were not ported. Please, include them in the patch.
> 
> Also, for less hassle, please rebase your patches on top of 
> freeipa-mkubik-0025-3-Separated-Tracker-implementations-into-standalone-pa.patch
> Which changes the location of tracker implementations and prevents 
> circular imports.
> 
> Thanks.
> 



Hi, 

these cases are there, in corresponding classes. They are marked with
the original comments. (However I can move them to separate class if
desirable.)

The copyright notice is changed. Also included a few changes in the
test with user without private group.

Filip
>From ff0b1fd07f15a076d5b370ff5299784b85e40af8 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Mon, 9 Nov 2015 16:48:55 +0100
Subject: [PATCH] Refactor test_group_plugin, use GroupTracker for tests

---
 ipatests/test_xmlrpc/test_group_plugin.py| 1728 +-
 ipatests/test_xmlrpc/tracker/group_plugin.py |  153 ++-
 2 files changed, 739 insertions(+), 1142 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_group_plugin.py b/ipatests/test_xmlrpc/test_group_plugin.py
index f2bd0f4b9c8d517500b63cf49a8a7bc7c29aab6e..1ac278c7e224b8dd8793dc56c299dcae88aa78a3 100644
--- a/ipatests/test_xmlrpc/test_group_plugin.py
+++ b/ipatests/test_xmlrpc/test_group_plugin.py
@@ -1,6 +1,7 @@
 # Authors:
 #   Rob Crittenden 
 #   Pavel Zuna 
+#   Filip Skola 
 #
 # Copyright (C) 2008  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -26,1137 +27,648 @@ import pytest
 
 from ipalib import api, errors
 from ipatests.test_xmlrpc import objectclasses
-from ipatests.test_xmlrpc.xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_set_ci,
- add_sid, add_oc, XMLRPC_test, raises_exact)
+from ipatests.test_xmlrpc.xmlrpc_test import (
+fuzzy_digits, fuzzy_uuid, fuzzy_set_ci, add_sid, add_oc,
+XMLRPC_test, raises_exact
+)
 from ipapython.dn import DN
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
 
+from ipatests.test_xmlrpc.tracker.group_plugin import GroupTracker
 from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
-from ipatests.util import assert_deepequal
+from ipatests.test_xmlrpc.test_user_plugin import user, user_npg2
+from ipatests.util import assert_deepequal, get_group_dn
 
 
-group1 = u'testgroup1'
-group2 = u'testgroup2'
-group3 = u'testgroup3'
-renamedgroup1 = u'testgroup'
-user1 = u'tuser1'
+notagroup = u'notagroup'
+renamedgroup1 = u'renamedgroup'
+invalidgroup1 = u'+tgroup1'
+external_sid1 = u'S-1-1-123456-789-1'
 
-invalidgroup1=u'+tgroup1'
 
-# When adding external SID member to a group we can't test
-# it fully due to possibly missing Samba 4 python bindings
-# and/or not configured AD trusts. Thus, we'll use incorrect
-# SID value to merely test that proper exceptions are raised
-external_sid1=u'S-1-1-123456-789-1'
+@pytest.fixture(scope='class')
+def group(request):
+tracker = GroupTracker(name=u'testgroup1', description=u'Test desc1')
+return tracker.make_fixture(request)
 
-def get_group_dn(cn):
-return DN(('cn', cn), api.env.container_group, api.env.basedn)
+
+@pytest.fixture(scope='class')
+def group2(request):
+tracker = GroupTracker(name=u'testgroup2', description=u'Test desc2')
+return tracker.make_fixture(request)
+
+
+@pytest.fixture(scope='class')
+def managed_group(request, user):
+user.ensure_exists()
+tracker = GroupTracker(
+name=user.uid, description=u'User private group for %s' % user.uid
+)
+tracker.exists = True
+# Managed group gets created when user is created
+tracker.track_create()
+return tracker
+
+
+@pytest.fixture(scope='class')
+def admins(request):
+# Track the admins group
+tracker = GroupTracker(
+name=u'admins&

Re: [Freeipa-devel] [PATCH] 0001 Refactor test_user_plugin

2015-12-03 Thread Filip Škola
Hi,

sending corrected version.

F.

On Thu, 12 Nov 2015 14:03:19 +0100
Milan Kubík  wrote:

> On 11/10/2015 12:13 PM, Filip Škola wrote:
> > Hi,
> >
> > fixed.
> >
> > F.
> >
> > On Tue, 10 Nov 2015 10:52:45 +0100
> > Milan Kubík  wrote:
> >
> >> On 11/09/2015 04:35 PM, Filip Škola wrote:
> >>> Another patch was applied in the meantime.
> >>>
> >>> Attaching an updated version.
> >>>
> >>> F.
> >>>
> >>> On Mon, 9 Nov 2015 13:35:02 +0100
> >>> Milan Kubík  wrote:
> >>>
> >>>> On 11/06/2015 11:32 AM, Filip Škola wrote:
> >>>> Hi,
> >>>> the patch doesn't apply.
> >>>>
> >> Please fix this.
> >>
> >>   ipatests/test_xmlrpc/test_user_plugin.py:1419:
> >> [E0602(undefined-variable),
> >> TestDeniedBindWithExpiredPrincipal.teardown_class] Undefined
> >> variable 'user1')
> >>
> >> Also, use the version numbers for your changed patches.
> >>
> >
> >
> Thanks for the patch. Several issues:
> 
> 1. Use dict.items instead of dict.iteritems, for python3 compatibility
> 
> 2. What is the purpose of TestPrepare class? The 'purge' methods do
> not call any ipa commands.
> Tracker.make_fixture should be used to make the Tracked resources
> clean themselves up when they're out of scope.
> 
> 3. Why reference the resources by hardcoded name if they have a
> fixture representation?
> 
> 4. Rewrite {create,delete}_test_group to a fixture. You may want to
> use different scope (or not).
> 
> 5. In `def atest_rename_to_invalid_login(self, user):` - use 
> pytest.skipif decorator and provide a reason if you must,
> do not obfuscate method name in order not to run it.
> 
> 

>From e2411ccfbabbb2a9e747c547141466ed38331528 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 6 Nov 2015 10:57:37 +0100
Subject: [PATCH] Refactor test_user_plugin, use UserTracker for tests

---
 ipatests/test_xmlrpc/test_user_plugin.py| 2387 ++-
 ipatests/test_xmlrpc/tracker/user_plugin.py |  162 +-
 2 files changed, 1033 insertions(+), 1516 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 084fb83c42d362204ff4547357226c8f56d217fb..7d299d228aef4881efce5b3f575c95d21a0d41d3 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -2,6 +2,7 @@
 #   Rob Crittenden 
 #   Pavel Zuna 
 #   Jason Gerard DeRose 
+#   Filip Skola 
 #
 # Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -23,6 +24,7 @@
 Test the `ipalib/plugins/user.py` module.
 """
 
+import pytest
 import datetime
 import ldap
 import re
@@ -30,42 +32,42 @@ import re
 from ipalib import api, errors
 from ipatests.test_xmlrpc import objectclasses
 from ipatests.util import (
-assert_equal, assert_not_equal, raises)
+assert_deepequal, assert_equal, assert_not_equal, raises)
 from xmlrpc_test import (
-XMLRPC_test, Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_password,
-fuzzy_string, fuzzy_dergeneralizedtime, add_sid, add_oc)
+XMLRPC_test, fuzzy_digits, fuzzy_uuid, fuzzy_password,
+fuzzy_string, fuzzy_dergeneralizedtime, add_sid, add_oc, raises_exact)
 from ipapython.dn import DN
-import pytest
+from ipapython.version import API_VERSION
+
+from ipatests.test_xmlrpc.ldaptracker import Tracker
+from ipatests.test_xmlrpc.tracker.group_plugin import GroupTracker
+from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
 
-user1 = u'tuser1'
-user2 = u'tuser2'
 admin1 = u'admin'
-admin2 = u'admin2'
-renameduser1 = u'tuser'
-group1 = u'group1'
-admins_group = u'admins'
+admin_group = u'admins'
 
 invaliduser1 = u'+tuser1'
 invaliduser2 = u'tuser1234567890123456789012345678901234567890'
 
 sshpubkey = (u'ssh-rsa B3NzaC1yc2EDAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6X'
-  'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
-  'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
-  'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
-  'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
-  '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
-  '0L public key test')
+ 'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
+ 'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
+

Re: [Freeipa-devel] [PATCH 0002] Refactor test_group_plugin

2015-11-23 Thread Filip Škola
Sending updated patch.

F.

On Mon, 23 Nov 2015 14:59:34 +0100
Filip Škola  wrote:

> Found couple of issues (broke some dependencies).
> 
> NACK
> 
> F.
> 
> On Fri, 20 Nov 2015 13:56:36 +0100
> Filip Škola  wrote:
> 
> > Another one.
> > 
> > F.
> 
> 

>From d6e30ee42ea427e9a2d5a85a787eddffd557eeba Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Mon, 9 Nov 2015 16:48:55 +0100
Subject: [PATCH] Refactor test_group_plugin, use GroupTracker for tests

---
 ipatests/test_xmlrpc/test_group_plugin.py| 1881 +-
 ipatests/test_xmlrpc/tracker/__init__.py |   22 +
 ipatests/test_xmlrpc/tracker/group_plugin.py |  303 +
 3 files changed, 927 insertions(+), 1279 deletions(-)
 create mode 100644 ipatests/test_xmlrpc/tracker/__init__.py
 create mode 100644 ipatests/test_xmlrpc/tracker/group_plugin.py

diff --git a/ipatests/test_xmlrpc/test_group_plugin.py b/ipatests/test_xmlrpc/test_group_plugin.py
index ed38c696e643a394510b6cbf7988f8c17520daf4..4350f128bad6306ac37492a8f5fdbb74b64478ab 100644
--- a/ipatests/test_xmlrpc/test_group_plugin.py
+++ b/ipatests/test_xmlrpc/test_group_plugin.py
@@ -1,6 +1,7 @@
 # Authors:
 #   Rob Crittenden 
 #   Pavel Zuna 
+#   Filip Skola 
 #
 # Copyright (C) 2008  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -26,1325 +27,647 @@ import pytest
 
 from ipalib import api, errors
 from ipatests.test_xmlrpc import objectclasses
-from xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_set_ci,
- add_sid, add_oc, XMLRPC_test, raises_exact)
+from ipatests.test_xmlrpc.xmlrpc_test import (
+fuzzy_digits, fuzzy_uuid, fuzzy_set_ci, add_sid, add_oc,
+XMLRPC_test, raises_exact
+)
 from ipapython.dn import DN
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
 
-from ipatests.test_xmlrpc.ldaptracker import Tracker
-from ipatests.test_xmlrpc.test_user_plugin import UserTracker
+from ipatests.test_xmlrpc.tracker.group_plugin import GroupTracker
+from ipatests.test_xmlrpc.test_user_plugin import UserTracker, user, user_npg
 from ipatests.util import assert_deepequal
 
 
-group1 = u'testgroup1'
-group2 = u'testgroup2'
-group3 = u'testgroup3'
-renamedgroup1 = u'testgroup'
-user1 = u'tuser1'
+notagroup = u'notagroup'
+renamedgroup1 = u'renamedgroup'
+invalidgroup1 = u'+tgroup1'
+external_sid1 = u'S-1-1-123456-789-1'
 
-invalidgroup1=u'+tgroup1'
-
-# When adding external SID member to a group we can't test
-# it fully due to possibly missing Samba 4 python bindings
-# and/or not configured AD trusts. Thus, we'll use incorrect
-# SID value to merely test that proper exceptions are raised
-external_sid1=u'S-1-1-123456-789-1'
 
 def get_group_dn(cn):
 return DN(('cn', cn), api.env.container_group, api.env.basedn)
 
 
-@pytest.mark.tier1
-class test_group(Declarative):
-cleanup_commands = [
-('group_del', [group1], {}),
-('group_del', [group2], {}),
-('group_del', [group3], {}),
-('group_del', [renamedgroup1], {}),
-('user_del', [user1], {}),
-]
-
-tests = [
-
-
-# create group1:
-dict(
-desc='Try to retrieve non-existent %r' % group1,
-command=('group_show', [group1], {}),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Try to update non-existent %r' % group1,
-command=('group_mod', [group1], dict(description=u'Foo')),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Try to delete non-existent %r' % group1,
-command=('group_del', [group1], {}),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Try to rename non-existent %r' % group1,
-command=('group_mod', [group1], dict(setattr=u'cn=%s' % renamedgroup1)),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Create non-POSIX %r' % group1,
-command=(
-'group_add', [group1], dict(description=u'Test desc 1',nonposix=True)
-),
-expected=dict(
-value=group1,
-summary=u'Added group "testgroup1"',
-result=dict(
-cn=[group1],
-description=[u'Test desc 1'],
-objectclass=objectclasses.group,
-   

Re: [Freeipa-devel] [PATCH 0002] Refactor test_group_plugin

2015-11-23 Thread Filip Škola
Found couple of issues (broke some dependencies).

NACK

F.

On Fri, 20 Nov 2015 13:56:36 +0100
Filip Škola  wrote:

> Another one.
> 
> F.


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

[Freeipa-devel] [PATCH 0002] Refactor test_group_plugin

2015-11-20 Thread Filip Škola
Another one.

F.
>From 0f0edcb1c7e32e24cf421e197657b8ac3a6a16a8 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Mon, 9 Nov 2015 16:48:55 +0100
Subject: [PATCH] Refactor test_group_plugin, use GroupTracker for tests

---
 ipatests/test_xmlrpc/test_group_plugin.py | 1896 +++--
 1 file changed, 742 insertions(+), 1154 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_group_plugin.py b/ipatests/test_xmlrpc/test_group_plugin.py
index ed38c696e643a394510b6cbf7988f8c17520daf4..a37cabc9dc1e9a32c971e4dc973cc57dcedddb32 100644
--- a/ipatests/test_xmlrpc/test_group_plugin.py
+++ b/ipatests/test_xmlrpc/test_group_plugin.py
@@ -1,6 +1,7 @@
 # Authors:
 #   Rob Crittenden 
 #   Pavel Zuna 
+#   Filip Skola 
 #
 # Copyright (C) 2008  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -26,1147 +27,34 @@ import pytest
 
 from ipalib import api, errors
 from ipatests.test_xmlrpc import objectclasses
-from xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_set_ci,
+from xmlrpc_test import (fuzzy_digits, fuzzy_uuid, fuzzy_set_ci,
  add_sid, add_oc, XMLRPC_test, raises_exact)
 from ipapython.dn import DN
-from ipatests.test_xmlrpc.test_user_plugin import get_user_result
 
 from ipatests.test_xmlrpc.ldaptracker import Tracker
-from ipatests.test_xmlrpc.test_user_plugin import UserTracker
+from ipatests.test_xmlrpc.test_user_plugin import UserTracker, user, user_npg
 from ipatests.util import assert_deepequal
 
 
-group1 = u'testgroup1'
+notagroup = u'notagroup'
 group2 = u'testgroup2'
 group3 = u'testgroup3'
-renamedgroup1 = u'testgroup'
+renamedgroup1 = u'renamedgroup'
 user1 = u'tuser1'
 
-invalidgroup1=u'+tgroup1'
+invalidgroup1 = u'+tgroup1'
+
+external_sid1 = u'S-1-1-123456-789-1'
 
-# When adding external SID member to a group we can't test
-# it fully due to possibly missing Samba 4 python bindings
-# and/or not configured AD trusts. Thus, we'll use incorrect
-# SID value to merely test that proper exceptions are raised
-external_sid1=u'S-1-1-123456-789-1'
 
 def get_group_dn(cn):
 return DN(('cn', cn), api.env.container_group, api.env.basedn)
 
 
-@pytest.mark.tier1
-class test_group(Declarative):
-cleanup_commands = [
-('group_del', [group1], {}),
-('group_del', [group2], {}),
-('group_del', [group3], {}),
-('group_del', [renamedgroup1], {}),
-('user_del', [user1], {}),
-]
-
-tests = [
-
-
-# create group1:
-dict(
-desc='Try to retrieve non-existent %r' % group1,
-command=('group_show', [group1], {}),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Try to update non-existent %r' % group1,
-command=('group_mod', [group1], dict(description=u'Foo')),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Try to delete non-existent %r' % group1,
-command=('group_del', [group1], {}),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Try to rename non-existent %r' % group1,
-command=('group_mod', [group1], dict(setattr=u'cn=%s' % renamedgroup1)),
-expected=errors.NotFound(reason=u'%s: group not found' % group1),
-),
-
-
-dict(
-desc='Create non-POSIX %r' % group1,
-command=(
-'group_add', [group1], dict(description=u'Test desc 1',nonposix=True)
-),
-expected=dict(
-value=group1,
-summary=u'Added group "testgroup1"',
-result=dict(
-cn=[group1],
-description=[u'Test desc 1'],
-objectclass=objectclasses.group,
-ipauniqueid=[fuzzy_uuid],
-dn=get_group_dn('testgroup1'),
-),
-),
-),
-
-
-dict(
-desc='Try to create duplicate %r' % group1,
-command=(
-'group_add', [group1], dict(description=u'Test desc 1')
-),
-expected=errors.DuplicateEntry(
-message=u'group with name "%s" already exists' % group1),
-),
-
-
-dict(
-desc='Retrieve non-POSIX %r' % group1,
-command=('group_show', [group1], {}),
-expected=dict(
-value=group1,
-summary=None,
-result=dict(
-cn=[group1],
-description=[u'Test desc 1'],
-dn=get_group_dn('testgroup1'),
-),
-),
-),
-
-
-dict(
-desc='Updated non-POSIX %r' % group1,
-command=(
-'group_mod', [group1], dict(description=u'New desc 1')
-),
-   

Re: [Freeipa-devel] [PATCH] 0001 Refactor test_user_plugin

2015-11-10 Thread Filip Škola
Hi,

fixed.

F.

On Tue, 10 Nov 2015 10:52:45 +0100
Milan Kubík  wrote:

> On 11/09/2015 04:35 PM, Filip Škola wrote:
> > Another patch was applied in the meantime.
> >
> > Attaching an updated version.
> >
> > F.
> >
> > On Mon, 9 Nov 2015 13:35:02 +0100
> > Milan Kubík  wrote:
> >
> >> On 11/06/2015 11:32 AM, Filip Škola wrote:
> >>>
> >> Hi,
> >> the patch doesn't apply.
> >>
> Please fix this.
> 
>  ipatests/test_xmlrpc/test_user_plugin.py:1419: 
> [E0602(undefined-variable), 
> TestDeniedBindWithExpiredPrincipal.teardown_class] Undefined variable 
> 'user1')
> 
> Also, use the version numbers for your changed patches.
> 

>From cdaa729b2bf3694f157e7f3fe62dd782e1a03334 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 6 Nov 2015 10:57:37 +0100
Subject: [PATCH] Refactor test_user_plugin, use UserTracker for tests

---
 ipatests/test_xmlrpc/test_user_plugin.py | 2809 +-
 1 file changed, 1195 insertions(+), 1614 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 81185e449acaa127aa9429fff9587d39a2be81e6..2d63e1636abd6bb55d541df354d039404c6475e8 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -2,6 +2,7 @@
 #   Rob Crittenden 
 #   Pavel Zuna 
 #   Jason Gerard DeRose 
+#   Filip Skola 
 #
 # Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -23,6 +24,7 @@
 Test the `ipalib/plugins/user.py` module.
 """
 
+import pytest
 import functools
 import datetime
 import ldap
@@ -33,41 +35,38 @@ from ipatests.test_xmlrpc import objectclasses
 from ipatests.util import (
 assert_equal, assert_not_equal, raises, assert_deepequal)
 from xmlrpc_test import (
-XMLRPC_test, Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_password,
+XMLRPC_test, fuzzy_digits, fuzzy_uuid, fuzzy_password,
 fuzzy_string, fuzzy_dergeneralizedtime, add_sid, add_oc, raises_exact)
 from ipapython.dn import DN
 from ipatests.test_xmlrpc.ldaptracker import Tracker
 import pytest
 
-user1 = u'tuser1'
-user2 = u'tuser2'
 admin1 = u'admin'
-admin2 = u'admin2'
-renameduser1 = u'tuser'
 group1 = u'group1'
-admins_group = u'admins'
+admin_group = u'admins'
 
 invaliduser1 = u'+tuser1'
 invaliduser2 = u'tuser1234567890123456789012345678901234567890'
 
 sshpubkey = (u'ssh-rsa B3NzaC1yc2EDAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6X'
-  'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
-  'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
-  'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
-  'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
-  '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
-  '0L public key test')
+ 'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
+ 'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
+ 'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
+ 'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
+ '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
+ '0L public key test')
 sshpubkeyfp = (u'13:67:6B:BF:4E:A2:05:8E:AE:25:8B:A1:31:DE:6F:1B '
-'public key test (ssh-rsa)')
+   'public key test (ssh-rsa)')
 
-validlanguage1 = u'en-US;q=0.987 , en, abcdfgh-abcdefgh;q=1, a;q=1.000'
-validlanguage2 = u'*'
+validlanguages = {
+u'en-US;q=0.987 , en, abcdfgh-abcdefgh;q=1, a;q=1.000',
+u'*'
+}
 
-invalidlanguage1 = u'abcdfghji-abcdfghji'
-invalidlanguage2 = u'en-us;q=0,123'
-invalidlanguage3 = u'en-us;q=0.1234'
-invalidlanguage4 = u'en-us;q=1.1'
-invalidlanguage5 = u'en-us;q=1.'
+invalidlanguages = {
+u'abcdfghji-abcdfghji', u'en-us;q=0,123',
+u'en-us;q=0.1234', u'en-us;q=1.1', u'en-us;q=1.'
+}
 
 principal_expiration_string = "2020-12-07T19:54:13Z"
 principal_expiration_date = datetime.datetime(2020, 12, 7, 19, 54, 13)
@@ -79,1583 +78,6 @@ expired_expiration_string = "1991-12-07T19:54:13Z"
 isodate_re = re.compile('^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$')
 
 
-def get_user_result(uid, givenname, sn, operation='show', omit=[],
-**overrides

Re: [Freeipa-devel] [PATCH] 0001 Refactor test_user_plugin

2015-11-09 Thread Filip Škola
Another patch was applied in the meantime.

Attaching an updated version.

F.

On Mon, 9 Nov 2015 13:35:02 +0100
Milan Kubík  wrote:

> On 11/06/2015 11:32 AM, Filip Škola wrote:
> >
> >
> Hi,
> the patch doesn't apply.
> 

>From ff593642291cece0360ee85f58f28f1c270d41a0 Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 6 Nov 2015 10:57:37 +0100
Subject: [PATCH] Refactor test_user_plugin, use UserTracker for tests

---
 ipatests/test_xmlrpc/test_user_plugin.py | 2810 +-
 1 file changed, 1196 insertions(+), 1614 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 81185e449acaa127aa9429fff9587d39a2be81e6..63a61a908c5623431c95c76b970919145e82a2e0 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -2,6 +2,7 @@
 #   Rob Crittenden 
 #   Pavel Zuna 
 #   Jason Gerard DeRose 
+#   Filip Skola 
 #
 # Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -23,6 +24,7 @@
 Test the `ipalib/plugins/user.py` module.
 """
 
+import pytest
 import functools
 import datetime
 import ldap
@@ -33,41 +35,38 @@ from ipatests.test_xmlrpc import objectclasses
 from ipatests.util import (
 assert_equal, assert_not_equal, raises, assert_deepequal)
 from xmlrpc_test import (
-XMLRPC_test, Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_password,
+XMLRPC_test, fuzzy_digits, fuzzy_uuid, fuzzy_password,
 fuzzy_string, fuzzy_dergeneralizedtime, add_sid, add_oc, raises_exact)
 from ipapython.dn import DN
 from ipatests.test_xmlrpc.ldaptracker import Tracker
 import pytest
 
-user1 = u'tuser1'
-user2 = u'tuser2'
 admin1 = u'admin'
-admin2 = u'admin2'
-renameduser1 = u'tuser'
 group1 = u'group1'
-admins_group = u'admins'
+admin_group = u'admins'
 
 invaliduser1 = u'+tuser1'
 invaliduser2 = u'tuser1234567890123456789012345678901234567890'
 
 sshpubkey = (u'ssh-rsa B3NzaC1yc2EDAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6X'
-  'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
-  'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
-  'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
-  'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
-  '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
-  '0L public key test')
+ 'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
+ 'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
+ 'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
+ 'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
+ '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
+ '0L public key test')
 sshpubkeyfp = (u'13:67:6B:BF:4E:A2:05:8E:AE:25:8B:A1:31:DE:6F:1B '
-'public key test (ssh-rsa)')
+   'public key test (ssh-rsa)')
 
-validlanguage1 = u'en-US;q=0.987 , en, abcdfgh-abcdefgh;q=1, a;q=1.000'
-validlanguage2 = u'*'
+validlanguages = {
+u'en-US;q=0.987 , en, abcdfgh-abcdefgh;q=1, a;q=1.000',
+u'*'
+}
 
-invalidlanguage1 = u'abcdfghji-abcdfghji'
-invalidlanguage2 = u'en-us;q=0,123'
-invalidlanguage3 = u'en-us;q=0.1234'
-invalidlanguage4 = u'en-us;q=1.1'
-invalidlanguage5 = u'en-us;q=1.'
+invalidlanguages = {
+u'abcdfghji-abcdfghji', u'en-us;q=0,123',
+u'en-us;q=0.1234', u'en-us;q=1.1', u'en-us;q=1.'
+}
 
 principal_expiration_string = "2020-12-07T19:54:13Z"
 principal_expiration_date = datetime.datetime(2020, 12, 7, 19, 54, 13)
@@ -79,1583 +78,6 @@ expired_expiration_string = "1991-12-07T19:54:13Z"
 isodate_re = re.compile('^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$')
 
 
-def get_user_result(uid, givenname, sn, operation='show', omit=[],
-**overrides):
-"""Get a user result for a user-{add,mod,find,show} command
-
-This gives the result as from a user_add(uid, givenname=givenname, sn=sn);
-modifications to that can be specified in ``omit`` and ``overrides``.
-
-The ``operation`` can be one of:
-- add
-- show
-- show-all ((show with the --all flag)
-- find
-- mod
-
-Attributes named in ``omit`` are removed from the result; any additional
-or non-default values can be specified in ``overrides``.
-""&q

[Freeipa-devel] [PATCH] 0001 Refactor test_user_plugin

2015-11-06 Thread Filip Škola
>From 881f5f980e820f178850307c0f64e3eb50cbc01e Mon Sep 17 00:00:00 2001
From: Filip Skola 
Date: Fri, 6 Nov 2015 10:57:37 +0100
Subject: [PATCH] Refactor test_user_plugin, use UserTracker for tests

---
 ipatests/test_xmlrpc/test_user_plugin.py | 2794 +-
 1 file changed, 1182 insertions(+), 1612 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 3d7b5e6ba14e3ccb144575f52e4e503e6638037d..ede6a339a519dfd40fd7507ee644f1cab0d4503c 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -2,6 +2,7 @@
 #   Rob Crittenden 
 #   Pavel Zuna 
 #   Jason Gerard DeRose 
+#   Filip Skola 
 #
 # Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
@@ -23,6 +24,7 @@
 Test the `ipalib/plugins/user.py` module.
 """
 
+import pytest
 import functools
 import datetime
 import ldap
@@ -33,40 +35,37 @@ from ipatests.test_xmlrpc import objectclasses
 from ipatests.util import (
 assert_equal, assert_not_equal, raises, assert_deepequal)
 from xmlrpc_test import (
-XMLRPC_test, Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_password,
+XMLRPC_test, fuzzy_digits, fuzzy_uuid, fuzzy_password,
 fuzzy_string, fuzzy_dergeneralizedtime, add_sid, add_oc, raises_exact)
 from ipapython.dn import DN
 from ipatests.test_xmlrpc.ldaptracker import Tracker
 
-user1 = u'tuser1'
-user2 = u'tuser2'
 admin1 = u'admin'
-admin2 = u'admin2'
-renameduser1 = u'tuser'
 group1 = u'group1'
-admins_group = u'admins'
+admin_group = u'admins'
 
 invaliduser1 = u'+tuser1'
 invaliduser2 = u'tuser1234567890123456789012345678901234567890'
 
 sshpubkey = (u'ssh-rsa B3NzaC1yc2EDAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6X'
-  'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
-  'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
-  'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
-  'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
-  '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
-  '0L public key test')
+ 'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
+ 'wA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2'
+ 'No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNm'
+ 'cSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM01'
+ '9Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF'
+ '0L public key test')
 sshpubkeyfp = (u'13:67:6B:BF:4E:A2:05:8E:AE:25:8B:A1:31:DE:6F:1B '
-'public key test (ssh-rsa)')
+   'public key test (ssh-rsa)')
 
-validlanguage1 = u'en-US;q=0.987 , en, abcdfgh-abcdefgh;q=1, a;q=1.000'
-validlanguage2 = u'*'
+validlanguages = {
+u'en-US;q=0.987 , en, abcdfgh-abcdefgh;q=1, a;q=1.000',
+u'*'
+}
 
-invalidlanguage1 = u'abcdfghji-abcdfghji'
-invalidlanguage2 = u'en-us;q=0,123'
-invalidlanguage3 = u'en-us;q=0.1234'
-invalidlanguage4 = u'en-us;q=1.1'
-invalidlanguage5 = u'en-us;q=1.'
+invalidlanguages = {
+u'abcdfghji-abcdfghji', u'en-us;q=0,123',
+u'en-us;q=0.1234', u'en-us;q=1.1', u'en-us;q=1.'
+}
 
 principal_expiration_string = "2020-12-07T19:54:13Z"
 principal_expiration_date = datetime.datetime(2020, 12, 7, 19, 54, 13)
@@ -78,1581 +77,6 @@ expired_expiration_string = "1991-12-07T19:54:13Z"
 isodate_re = re.compile('^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$')
 
 
-def get_user_result(uid, givenname, sn, operation='show', omit=[],
-**overrides):
-"""Get a user result for a user-{add,mod,find,show} command
-
-This gives the result as from a user_add(uid, givenname=givenname, sn=sn);
-modifications to that can be specified in ``omit`` and ``overrides``.
-
-The ``operation`` can be one of:
-- add
-- show
-- show-all ((show with the --all flag)
-- find
-- mod
-
-Attributes named in ``omit`` are removed from the result; any additional
-or non-default values can be specified in ``overrides``.
-"""
-# sn can be None; this should only be used from `get_admin_result`
-cn = overrides.get('cn', ['%s %s' % (givenname, sn or '')])
-cn[0] = cn[0].strip()
-result = add_sid(dict(
-homedirectory=[u'/home/%s' % uid],
-loginshell=[u'/bin/sh'],
-uid=[uid],
-uidnumber=[fuzzy_digits],
-gidnumber=[fuzzy_digits],
-mail=[u'%s@%s' % (uid, api.env.domain)],
-has_keytab=False,
-has_password=False,
-))
-if sn:
-result['sn'] = [sn]
-if givenname:
-result['givenname'] = [givenname]
-if operation in ('add', 'show', 'show-all', 'find'):
-result.update(
-dn=get_user_dn(uid),
-)
-if operation in ('add', 'show-all'):
-result.upda