diff options
Diffstat (limited to 'ipatests')
-rw-r--r-- | ipatests/test_xmlrpc/test_attr.py | 225 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_automember_plugin.py | 65 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_group_plugin.py | 53 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_krbtpolicy.py | 30 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_nesting.py | 111 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_netgroup_plugin.py | 58 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_range_plugin.py | 25 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_replace.py | 124 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_selinuxusermap_plugin.py | 33 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_user_plugin.py | 855 |
10 files changed, 271 insertions, 1308 deletions
diff --git a/ipatests/test_xmlrpc/test_attr.py b/ipatests/test_xmlrpc/test_attr.py index 118eabdeb..d4671b984 100644 --- a/ipatests/test_xmlrpc/test_attr.py +++ b/ipatests/test_xmlrpc/test_attr.py @@ -21,10 +21,9 @@ Test --setattr and --addattr and other attribute-specific issues """ -from ipalib import api, errors -from ipatests.test_xmlrpc import objectclasses -from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, add_sid, add_oc -from ipapython.dn import DN +from ipalib import errors +from xmlrpc_test import Declarative +from ipatests.test_xmlrpc.test_user_plugin import get_user_result user1=u'tuser1' @@ -55,32 +54,7 @@ class test_attr(Declarative): expected=dict( value=user1, summary=u'Added user "tuser1"', - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), - has_keytab=False, - has_password=False, - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), @@ -91,19 +65,9 @@ class test_attr(Declarative): 'user_mod', [user1], dict(setattr=(u'givenname=Finkle', u'mail=test@example.com')) ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com'], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -117,19 +81,9 @@ class test_attr(Declarative): 'user_mod', [user1], dict(addattr=u'mail=test2@example.com') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -143,20 +97,10 @@ class test_attr(Declarative): 'user_mod', [user1], dict(setattr=u'telephoneNumber=410-555-1212', addattr=u'telephoneNumber=301-555-1212') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'410-555-1212', u'301-555-1212'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -170,20 +114,10 @@ class test_attr(Declarative): 'user_mod', [user1], dict(setattr=u'telephoneNumber=301-555-1212') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'301-555-1212'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -197,20 +131,11 @@ class test_attr(Declarative): 'user_mod', [user1], dict(addattr=(u'telephoneNumber=703-555-1212', u'telephoneNumber=202-888-9833')) ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], - telephonenumber=[u'301-555-1212', u'202-888-9833', u'703-555-1212'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + telephonenumber=[u'301-555-1212', u'703-555-1212', + u'202-888-9833'], ), summary=u'Modified user "tuser1"', value=user1, @@ -224,20 +149,10 @@ class test_attr(Declarative): 'user_mod', [user1], dict(delattr=u'telephoneNumber=301-555-1212') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], - telephonenumber=[u'202-888-9833', u'703-555-1212'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + telephonenumber=[u'703-555-1212', u'202-888-9833'], ), summary=u'Modified user "tuser1"', value=user1, @@ -262,20 +177,10 @@ class test_attr(Declarative): delattr=u'telephoneNumber=202-888-9833') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], - telephonenumber=[u'301-555-1212', u'703-555-1212'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + telephonenumber=[u'703-555-1212', u'301-555-1212'], ), summary=u'Modified user "tuser1"', value=user1, @@ -291,20 +196,11 @@ class test_attr(Declarative): delattr=u'telephoneNumber=301-555-1212') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], - telephonenumber=[u'703-555-1212', u'301-555-1212', u'202-888-9833'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + telephonenumber=[u'703-555-1212', u'301-555-1212', + u'202-888-9833'], ), summary=u'Modified user "tuser1"', value=user1, @@ -320,20 +216,10 @@ class test_attr(Declarative): delattr=u'telephoneNumber=301-555-1212') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'202-888-9833'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -365,20 +251,10 @@ class test_attr(Declarative): 'user_mod', [user1], dict(givenname=u'Fred') ), expected=dict( - result=dict( - givenname=[u'Fred'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Fred', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'202-888-9833'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -392,20 +268,10 @@ class test_attr(Declarative): 'user_mod', [user1], dict(setattr=u'givenname=Finkle') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'202-888-9833'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -418,20 +284,11 @@ class test_attr(Declarative): 'user_mod', [user1], dict(setattr=u'nsaccountlock=TrUe') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'202-888-9833'], nsaccountlock=True, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -446,20 +303,10 @@ class test_attr(Declarative): delattr=u'nsaccountlock=TRUE') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Finkle', u'User1', 'mod', mail=[u'test@example.com', u'test2@example.com'], - memberof_group=[u'ipausers'], telephonenumber=[u'202-888-9833'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, diff --git a/ipatests/test_xmlrpc/test_automember_plugin.py b/ipatests/test_xmlrpc/test_automember_plugin.py index 2c38b6463..7b390a500 100644 --- a/ipatests/test_xmlrpc/test_automember_plugin.py +++ b/ipatests/test_xmlrpc/test_automember_plugin.py @@ -24,7 +24,8 @@ Test the `ipalib/plugins/automember.py` module. from ipalib import api, errors from ipapython.dn import DN from ipatests.test_xmlrpc import objectclasses -from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, add_sid, add_oc +from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid +from ipatests.test_xmlrpc.test_user_plugin import get_user_result user1=u'tuser1' @@ -794,32 +795,9 @@ class test_automember(Declarative): expected=dict( value=manager1, summary=u'Added user "mscott"', - result=add_sid(dict( - gecos=[u'Michael Scott'], - givenname=[u'Michael'], - homedirectory=[u'/home/mscott'], - krbprincipalname=[u'mscott@' + api.env.realm], - has_keytab=False, - has_password=False, - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'Scott'], - uid=[manager1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (manager1, api.env.domain)], - displayname=[u'Michael Scott'], - cn=[u'Michael Scott'], - initials=[u'MS'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn', 'global_policy'), ('cn', api.env.realm), ('cn', 'kerberos'), - api.env.basedn)], - mepmanagedentry=[DN(('cn', manager1), ('cn', 'groups'), ('cn', 'accounts'), - api.env.basedn)], - memberof_group=[u'defaultgroup1', u'ipausers'], - dn=DN(('uid', 'mscott'), ('cn', 'users'), ('cn', 'accounts'), - api.env.basedn), - )), + result=get_user_result( + manager1, u'Michael', u'Scott', 'add', + memberof_group=[defaultgroup1, u'ipausers']), ), ), @@ -832,33 +810,12 @@ class test_automember(Declarative): expected=dict( value=user1, summary=u'Added user "tuser1"', - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - has_keytab=False, - has_password=False, - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - manager=[DN(('uid', 'mscott'), ('cn', 'users'), ('cn', 'accounts'), api.env.basedn)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn', 'global_policy'), ('cn', api.env.realm), ('cn', 'kerberos'), - api.env.basedn)], - mepmanagedentry=[DN(('cn', user1), ('cn', 'groups'), ('cn', 'accounts'), - api.env.basedn)], - memberof_group=[u'group1', u'ipausers'], - dn=DN(('uid', 'tuser1'), ('cn', 'users'), ('cn', 'accounts'), - api.env.basedn), - )), + result=get_user_result( + user1, u'Test', u'User1', 'add', + memberof_group=[group1, u'ipausers'], + manager=[DN(('uid', 'mscott'), ('cn', 'users'), + ('cn', 'accounts'), api.env.basedn)] + ), ), ), diff --git a/ipatests/test_xmlrpc/test_group_plugin.py b/ipatests/test_xmlrpc/test_group_plugin.py index be31af453..568e5851e 100644 --- a/ipatests/test_xmlrpc/test_group_plugin.py +++ b/ipatests/test_xmlrpc/test_group_plugin.py @@ -26,6 +26,7 @@ from ipatests.test_xmlrpc import objectclasses from xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_set_ci, add_sid, add_oc) from ipapython.dn import DN +from ipatests.test_xmlrpc.test_user_plugin import get_user_result group1 = u'testgroup1' group2 = u'testgroup2' @@ -796,31 +797,7 @@ class test_group(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/%s' % user1], - krbprincipalname=[u'%s@%s' % (user1, api.env.realm)], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - dn=DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn), - has_keytab=False, - has_password=False, - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), @@ -912,32 +889,14 @@ class test_group(Declarative): expected=dict( value=user1, summary=u'Added user "tuser1"', - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], + result=get_user_result( + user1, u'Test', u'User1', 'add', description=[], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], gidnumber=[u'1000'], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - )), + omit=['mepmanagedentry'], + ), ), ), diff --git a/ipatests/test_xmlrpc/test_krbtpolicy.py b/ipatests/test_xmlrpc/test_krbtpolicy.py index 2fac11f18..6d7d1b6ef 100644 --- a/ipatests/test_xmlrpc/test_krbtpolicy.py +++ b/ipatests/test_xmlrpc/test_krbtpolicy.py @@ -21,9 +21,9 @@ Test kerberos ticket policy """ from ipalib import api, errors -from ipatests.test_xmlrpc import objectclasses -from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, add_sid, add_oc +from xmlrpc_test import Declarative from ipapython.dn import DN +from ipatests.test_xmlrpc.test_user_plugin import get_user_result user1 = u'tuser1' @@ -94,31 +94,7 @@ class test_krbtpolicy(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user1),('cn','users'),('cn','accounts'), api.env.basedn) - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), diff --git a/ipatests/test_xmlrpc/test_nesting.py b/ipatests/test_xmlrpc/test_nesting.py index 850010b87..f441d2014 100644 --- a/ipatests/test_xmlrpc/test_nesting.py +++ b/ipatests/test_xmlrpc/test_nesting.py @@ -22,8 +22,9 @@ Test group nesting and indirect members from ipalib import api from ipatests.test_xmlrpc import objectclasses -from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, add_sid, add_oc +from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid from ipapython.dn import DN +from ipatests.test_xmlrpc.test_user_plugin import get_user_result group1 = u'testgroup1' group2 = u'testgroup2' @@ -160,32 +161,7 @@ class test_nesting(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn) - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), @@ -198,32 +174,7 @@ class test_nesting(Declarative): expected=dict( value=user2, summary=u'Added user "%s"' % user2, - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user2, api.env.domain)], - displayname=[u'Test User2'], - cn=[u'Test User2'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user2),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user2),('cn','users'),('cn','accounts'), - api.env.basedn) - )), + result=get_user_result(user2, u'Test', u'User2', 'add'), ), ), @@ -236,32 +187,7 @@ class test_nesting(Declarative): expected=dict( value=user3, summary=u'Added user "%s"' % user3, - result=add_sid(dict( - gecos=[u'Test User3'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser3'], - krbprincipalname=[u'tuser3@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User3'], - uid=[user3], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user3, api.env.domain)], - displayname=[u'Test User3'], - cn=[u'Test User3'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user3),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user3),('cn','users'),('cn','accounts'), - api.env.basedn) - )), + result=get_user_result(user3, u'Test', u'User3', 'add'), ), ), @@ -274,32 +200,7 @@ class test_nesting(Declarative): expected=dict( value=user4, summary=u'Added user "%s"' % user4, - result=add_sid(dict( - gecos=[u'Test User4'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser4'], - krbprincipalname=[u'tuser4@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User4'], - uid=[user4], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user4, api.env.domain)], - displayname=[u'Test User4'], - cn=[u'Test User4'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user4),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user4),('cn','users'),('cn','accounts'), - api.env.basedn) - )), + result=get_user_result(user4, u'Test', u'User4', 'add'), ), ), diff --git a/ipatests/test_xmlrpc/test_netgroup_plugin.py b/ipatests/test_xmlrpc/test_netgroup_plugin.py index 09241a7d6..9c21e8d11 100644 --- a/ipatests/test_xmlrpc/test_netgroup_plugin.py +++ b/ipatests/test_xmlrpc/test_netgroup_plugin.py @@ -23,13 +23,15 @@ Test the `ipalib/plugins/netgroup.py` module. import nose import krbV + from ipalib import api from ipalib import errors from ipaserver.plugins.ldap2 import ldap2 from xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, - fuzzy_netgroupdn, add_sid, add_oc) + fuzzy_netgroupdn) from ipatests.test_xmlrpc import objectclasses from ipapython.dn import DN +from ipatests.test_xmlrpc.test_user_plugin import get_user_result # Global so we can save the value between tests netgroup_dn = None @@ -272,32 +274,7 @@ class test_netgroup(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/%s' % user1], - krbprincipalname=[u'%s@%s' % (user1, api.env.realm)], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn), - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), @@ -309,32 +286,7 @@ class test_netgroup(Declarative): expected=dict( value=user2, summary=u'Added user "%s"' % user2, - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/%s' % user2], - krbprincipalname=[u'%s@%s' % (user2, api.env.realm)], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user2, api.env.domain)], - displayname=[u'Test User2'], - cn=[u'Test User2'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user2),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user2),('cn','users'),('cn','accounts'), - api.env.basedn), - )), + result=get_user_result(user2, u'Test', u'User2', 'add'), ), ), diff --git a/ipatests/test_xmlrpc/test_range_plugin.py b/ipatests/test_xmlrpc/test_range_plugin.py index df80e2fb7..4bafdaf01 100644 --- a/ipatests/test_xmlrpc/test_range_plugin.py +++ b/ipatests/test_xmlrpc/test_range_plugin.py @@ -26,6 +26,7 @@ from xmlrpc_test import Declarative, fuzzy_uuid from ipatests.test_xmlrpc import objectclasses from ipatests.util import MockLDAP from ipapython.dn import DN +from ipatests.test_xmlrpc.test_user_plugin import get_user_result id_shift = 0 rid_shift = 0 @@ -232,30 +233,10 @@ class test_range(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=objectclasses.user, - sn=[u'User1'], - uid=[user1], + result=get_user_result( + user1, u'Test', u'User1', 'add', uidnumber=[unicode(user1_uid)], gidnumber=[unicode(user1_uid)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - mail=[u'%s@%s' % (user1, api.env.domain)], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid',user1),('cn','users'),('cn','accounts'), api.env.basedn) ), ), ), diff --git a/ipatests/test_xmlrpc/test_replace.py b/ipatests/test_xmlrpc/test_replace.py index 1b946b76c..0d02a0d8b 100644 --- a/ipatests/test_xmlrpc/test_replace.py +++ b/ipatests/test_xmlrpc/test_replace.py @@ -25,10 +25,8 @@ Note that member management in other tests also exercises the gen_modlist code. """ -from ipalib import api -from ipatests.test_xmlrpc import objectclasses -from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, add_sid, add_oc -from ipapython.dn import DN +from xmlrpc_test import Declarative +from ipatests.test_xmlrpc.test_user_plugin import get_user_result user1=u'tuser1' @@ -50,32 +48,10 @@ class test_replace(Declarative): expected=dict( value=user1, summary=u'Added user "tuser1"', - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], + result=get_user_result( + user1, u'Test', u'User1', 'add', mail=[u'test1@example.com', u'test2@example.com'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm),('cn','kerberos'), - api.env.basedn)], - mepmanagedentry=[DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), - )), + ), ), ), @@ -86,19 +62,9 @@ class test_replace(Declarative): 'user_mod', [user1], dict(mail=[u'test1@example.com', u'test3@example.com']) ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Test', u'User1', 'mod', mail=[u'test1@example.com', u'test3@example.com'], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -112,19 +78,9 @@ class test_replace(Declarative): 'user_mod', [user1], dict(mail=u'test4@example.com') ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Test', u'User1', 'mod', mail=[u'test4@example.com'], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "tuser1"', value=user1, @@ -138,19 +94,10 @@ class test_replace(Declarative): 'user_mod', [user1], dict(mail=[u'test5@example.com', u'test6@example.com', u'test7@example.com']) ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'test6@example.com', u'test7@example.com', u'test5@example.com'], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + result=get_user_result( + user1, u'Test', u'User1', 'mod', + mail=[u'test5@example.com', u'test6@example.com', + u'test7@example.com'], ), summary=u'Modified user "tuser1"', value=user1, @@ -164,18 +111,9 @@ class test_replace(Declarative): 'user_mod', [user1], dict(mail=u'') ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + result=get_user_result( + user1, u'Test', u'User1', 'mod', + omit=['mail'], ), summary=u'Modified user "tuser1"', value=user1, @@ -189,19 +127,10 @@ class test_replace(Declarative): 'user_mod', [user1], dict(initials=u'ABC') ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + user1, u'Test', u'User1', 'mod', initials=[u'ABC'], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + omit=['mail'], ), summary=u'Modified user "tuser1"', value=user1, @@ -215,18 +144,9 @@ class test_replace(Declarative): 'user_mod', [user1], dict(initials=u'') ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, + result=get_user_result( + user1, u'Test', u'User1', 'mod', + omit=['mail'], ), summary=u'Modified user "tuser1"', value=user1, diff --git a/ipatests/test_xmlrpc/test_selinuxusermap_plugin.py b/ipatests/test_xmlrpc/test_selinuxusermap_plugin.py index d1fedf1f0..9089a1c5e 100644 --- a/ipatests/test_xmlrpc/test_selinuxusermap_plugin.py +++ b/ipatests/test_xmlrpc/test_selinuxusermap_plugin.py @@ -22,9 +22,10 @@ Test the `ipalib/plugins/selinuxusermap.py` module. from ipalib import api, errors from ipatests.test_xmlrpc import objectclasses -from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, add_sid, add_oc +from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid from ipapython.dn import DN from ipatests.util import Fuzzy +from ipatests.test_xmlrpc.test_user_plugin import get_user_result rule1 = u'selinuxrule1' selinuxuser1 = u'guest_u:s0' @@ -200,35 +201,7 @@ class test_selinuxusermap(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/%s' % user1], - krbprincipalname=[u'%s@%s' % (user1, api.env.realm)], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn', 'global_policy'), - ('cn', api.env.realm), - ('cn', 'kerberos'), - api.env.basedn) - ], - mepmanagedentry=[DN(('cn', user1), ('cn', 'groups'), - ('cn', 'accounts'), api.env.basedn)], - memberof_group=[u'ipausers'], - dn=DN(('uid', user1), ('cn', 'users'), ('cn', 'accounts'), - api.env.basedn), - has_keytab=False, - has_password=False, - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py index 98e1965a4..9df5d5d5b 100644 --- a/ipatests/test_xmlrpc/test_user_plugin.py +++ b/ipatests/test_xmlrpc/test_user_plugin.py @@ -45,6 +45,89 @@ invaliduser2=u'tuser1234567890123456789012345678901234567890' sshpubkey = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6XHBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGIwA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNmcSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM019Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF0L 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)' + +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.update( + cn=cn, + displayname=cn, + gecos=cn, + initials=[givenname[0] + (sn or '')[:1]], + ipauniqueid=[fuzzy_uuid], + mepmanagedentry=[get_group_dn(uid)], + objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), + krbprincipalname=[u'%s@%s' % (uid, api.env.realm)], + krbpwdpolicyreference=[DN(('cn', 'global_policy'), + ('cn', api.env.realm), + ('cn', 'kerberos'), + api.env.basedn)], + ) + if operation in ('show', 'show-all', 'find', 'mod'): + result.update( + nsaccountlock=False, + ) + if operation in ('add', 'show', 'show-all', 'mod'): + result.update( + memberof_group=[u'ipausers'], + ) + for key in omit: + del result[key] + result.update(overrides) + return result + + +def get_admin_result(operation='show', **overrides): + """Give the result for the default admin user + + Any additional or non-default values can be given in ``overrides``. + """ + result = get_user_result(u'admin', None, u'Administrator', operation, + omit=['mail'], + has_keytab=True, + has_password=True, + loginshell=[u'/bin/bash'], + **overrides) + return result + + + def get_user_dn(uid): return DN(('uid', uid), api.env.container_user, api.env.basedn) @@ -63,6 +146,7 @@ def not_upg_check(response): response['result']['gidnumber']) return True + class test_user(Declarative): cleanup_commands = [ @@ -109,30 +193,7 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), extra_check = upg_check, ), @@ -154,21 +215,7 @@ class test_user(Declarative): 'user_show', [user1], {} ), expected=dict( - result=dict( - dn=get_user_dn(user1), - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, - ), + result=get_user_result(user1, u'Test', u'User1', 'show'), value=user1, summary=None, ), @@ -182,32 +229,7 @@ class test_user(Declarative): ), expected=dict( result=[ - add_sid({ - 'dn': get_user_dn(user1), - 'cn': [u'Test User1'], - 'gecos': [u'Test User1'], - 'givenname': [u'Test'], - 'homedirectory': [u'/home/tuser1'], - 'krbprincipalname': [u'tuser1@' + api.env.realm], - 'loginshell': [u'/bin/sh'], - 'memberof_group': [u'ipausers'], - 'objectclass': add_oc(objectclasses.user, - u'ipantuserattrs'), - 'sn': [u'User1'], - 'uid': [user1], - 'uidnumber': [fuzzy_digits], - 'gidnumber': [fuzzy_digits], - 'ipauniqueid': [fuzzy_uuid], - 'mepmanagedentry': [get_group_dn(user1)], - 'krbpwdpolicyreference': [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - 'nsaccountlock': False, - 'has_keytab': False, - 'has_password': False, - 'displayname': [u'Test User1'], - 'initials': [u'TU'], - 'mail': [u'%s@%s' % (user1, api.env.domain)], - }), + get_user_result(user1, u'Test', u'User1', 'show-all'), ], summary=u'1 user matched', count=1, truncated=False, @@ -240,20 +262,7 @@ class test_user(Declarative): ), expected=dict( result=[ - dict( - dn=get_user_dn(user1), - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - nsaccountlock=False, - has_keytab=False, - has_password=False, - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - ), + get_user_result(user1, u'Test', u'User1', 'find'), ], summary=u'1 user matched', count=1, @@ -269,32 +278,8 @@ class test_user(Declarative): ), expected=dict( result=[ - dict( - dn=get_user_dn(admin1), - homedirectory=[u'/home/admin'], - loginshell=[u'/bin/bash'], - sn=[u'Administrator'], - uid=[admin1], - nsaccountlock=False, - has_keytab=True, - has_password=True, - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - ), - dict( - dn=get_user_dn(user1), - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - nsaccountlock=False, - has_keytab=False, - has_password=False, - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - ), + get_admin_result('find'), + get_user_result(user1, u'Test', u'User1', 'find'), ], summary=u'2 users matched', count=2, @@ -309,20 +294,7 @@ class test_user(Declarative): 'user_find', [], dict(sizelimit=1,), ), expected=dict( - result=[ - dict( - dn=get_user_dn(admin1), - homedirectory=[u'/home/admin'], - loginshell=[u'/bin/bash'], - sn=[u'Administrator'], - uid=[admin1], - nsaccountlock=False, - has_keytab=True, - has_password=True, - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - ), - ], + result=[get_admin_result('find')], summary=u'1 user matched', count=1, truncated=True, @@ -346,7 +318,8 @@ class test_user(Declarative): desc='Assert user is disabled', command=('user_find', [user1], {}), expected=dict( - result=[lambda d: d['nsaccountlock'] == True], + result=[get_user_result(user1, u'Test', u'User1', 'find', + nsaccountlock=True)], summary=u'1 user matched', count=1, truncated=False, @@ -369,7 +342,7 @@ class test_user(Declarative): desc='Assert user "%s" is enabled' % user1, command=('user_find', [user1], {}), expected=dict( - result=[lambda d: d['nsaccountlock'] == False], + result=[get_user_result(user1, u'Test', u'User1', 'find')], summary=u'1 user matched', count=1, truncated=False, @@ -380,7 +353,8 @@ class test_user(Declarative): desc='Disable "%s" using setattr' % user1, command=('user_mod', [user1], dict(setattr=u'nsaccountlock=True')), expected=dict( - result=lambda d: d['nsaccountlock'] == True, + result=get_user_result(user1, u'Test', u'User1', 'mod', + nsaccountlock=True), value=user1, summary=u'Modified user "%s"' % user1, ), @@ -390,7 +364,7 @@ class test_user(Declarative): desc='Enable "%s" using setattr' % user1, command=('user_mod', [user1], dict(setattr=u'nsaccountlock=False')), expected=dict( - result=lambda d: d['nsaccountlock'] == False, + result=get_user_result(user1, u'Test', u'User1', 'mod'), value=user1, summary=u'Modified user "%s"' % user1, ), @@ -400,7 +374,8 @@ class test_user(Declarative): desc='Disable "%s" using user_mod' % user1, command=('user_mod', [user1], dict(nsaccountlock=True)), expected=dict( - result=lambda d: d['nsaccountlock'] == True, + result=get_user_result(user1, u'Test', u'User1', 'mod', + nsaccountlock=True), value=user1, summary=u'Modified user "%s"' % user1, ), @@ -410,7 +385,7 @@ class test_user(Declarative): desc='Enable "%s" using user_mod' % user1, command=('user_mod', [user1], dict(nsaccountlock=False)), expected=dict( - result=lambda d: d['nsaccountlock'] == False, + result=get_user_result(user1, u'Test', u'User1', 'mod'), value=user1, summary=u'Modified user "%s"' % user1, ), @@ -429,20 +404,7 @@ class test_user(Declarative): 'user_mod', [user1], dict(givenname=u'Finkle') ), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, - ), + result=get_user_result(user1, u'Finkle', u'User1', 'mod'), summary=u'Modified user "%s"' % user1, value=user1, ), @@ -463,21 +425,7 @@ class test_user(Declarative): desc='Retrieve "%s" to verify update' % user1, command=('user_show', [user1], {}), expected=dict( - result=dict( - dn=get_user_dn(user1), - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, - ), + result=get_user_result(user1, u'Finkle', u'User1', 'show'), summary=None, value=user1, ), @@ -489,20 +437,10 @@ class test_user(Declarative): desc='Rename "%s"' % user1, command=('user_mod', [user1], dict(setattr=u'uid=%s' % renameduser1)), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[renameduser1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + renameduser1, u'Finkle', u'User1', 'mod', mail=[u'%s@%s' % (user1, api.env.domain)], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, - ), + homedirectory=[u'/home/%s' % user1]), summary=u'Modified user "%s"' % user1, value=user1, ), @@ -520,20 +458,7 @@ class test_user(Declarative): desc='Rename back "%s"' % renameduser1, command=('user_mod', [renameduser1], dict(setattr=u'uid=%s' % user1)), expected=dict( - result=dict( - givenname=[u'Finkle'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user1, api.env.domain)], - memberof_group=[u'ipausers'], - nsaccountlock=False, - has_keytab=False, - has_password=False, - ), + result=get_user_result(user1, u'Finkle', u'User1', 'mod'), summary=u'Modified user "%s"' % renameduser1, value=renameduser1, ), @@ -576,32 +501,12 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], + result=get_user_result( + user1, u'Test', u'User1', 'add', objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - mail=[u'%s@%s' % (user1, api.env.domain)], ipasshpubkey=[sshpubkey], sshpubkeyfp=[sshpubkeyfp], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + ), ), extra_check = upg_check, ), @@ -634,30 +539,7 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), extra_check = upg_check, ), @@ -671,30 +553,7 @@ class test_user(Declarative): expected=dict( value=user2, summary=u'Added user "%s"' % user2, - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User2'], - cn=[u'Test User2'], - mail=[u'%s@%s' % (user2, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user2)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user2), - )), + result=get_user_result(user2, u'Test', u'User2', 'add'), ), extra_check = upg_check, ), @@ -712,21 +571,8 @@ class test_user(Declarative): desc='Make "%s" the manager of "%s"' % (user1, user2), command=('user_mod', [user2], dict(manager=user1)), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - loginshell=[u'/bin/sh'], - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - memberof_group=[u'ipausers'], - mail=[u'%s@%s' % (user2, api.env.domain)], - nsaccountlock=False, - has_keytab=False, - has_password=False, - manager=[user1], - ), + result=get_user_result(user2, u'Test', u'User2', 'mod', + manager=[user1]), summary=u'Modified user "%s"' % user2, value=user2, ), @@ -738,23 +584,8 @@ class test_user(Declarative): 'user_find', [user2], {'manager': user1} ), expected=dict( - result=[ - dict( - dn=get_user_dn(user2), - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - loginshell=[u'/bin/sh'], - sn=[u'User2'], - uid=[user2], - nsaccountlock=False, - has_keytab=False, - has_password=False, - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user2, api.env.domain)], - manager=[user1], - ), - ], + result=[get_user_result(user2, u'Test', u'User2', 'find', + manager=[user1])], summary=u'1 user matched', count=1, truncated=False, @@ -887,35 +718,12 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - mail=[u'%s@%s' % (user1, api.env.domain)], - street=[u'123 Maple Rd'], - l=[u'Anytown'], - st=[u'MD'], - postalcode=[u'01234-5678'], + result=get_user_result( + user1, u'Test', u'User1', 'add', + street=[u'123 Maple Rd'], l=[u'Anytown'], st=[u'MD'], telephonenumber=[u'410-555-1212'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + postalcode=[u'01234-5678'], + ), ), ), @@ -938,34 +746,14 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=True, - has_password=True, + result=get_user_result( + user1, u'Test', u'User1', 'add', randompassword=fuzzy_password, + has_keytab=True, has_password=True, krbextradata=[fuzzy_string], krbpasswordexpiration=[fuzzy_dergeneralizedtime], - krblastpwdchange=[fuzzy_dergeneralizedtime], - dn=get_user_dn(user1), - )), + krblastpwdchange=[fuzzy_dergeneralizedtime] + ), ), ), @@ -987,30 +775,7 @@ class test_user(Declarative): expected=dict( value=user2, summary=u'Added user "%s"' % user2, - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User2'], - cn=[u'Test User2'], - mail=[u'%s@%s' % (user2, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user2)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user2), - )), + result=get_user_result(user2, u'Test', u'User2', 'add'), ), ), @@ -1020,20 +785,10 @@ class test_user(Declarative): 'user_mod', [user2], dict(random=True) ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - loginshell=[u'/bin/sh'], - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - memberof_group=[u'ipausers'], - mail=[u'%s@%s' % (user2, api.env.domain)], - nsaccountlock=False, - has_keytab=True, - has_password=True, + result=get_user_result( + user2, u'Test', u'User2', 'mod', randompassword=fuzzy_password, + has_keytab=True, has_password=True, ), summary=u'Modified user "%s"' % user2, value=user2, @@ -1059,30 +814,7 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + result=get_user_result(user1, u'Test', u'User1', 'add'), ), ), @@ -1132,30 +864,8 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/other-home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + result=get_user_result(user1, u'Test', u'User1', 'add', + homedirectory=[u'/other-home/tuser1']), ), ), @@ -1194,30 +904,8 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/usr/bin/ipython'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - initials=[u'TU'], - mail=[u'%s@%s' % (user1, api.env.domain)], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + result=get_user_result(user1, u'Test', u'User1', 'add', + loginshell=[u'/usr/bin/ipython']), ), ), @@ -1255,31 +943,14 @@ class test_user(Declarative): expected=dict( value=user2, summary=u'Added user "%s"' % user2, - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - description=[], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], + result=get_user_result( + user2, u'Test', u'User2', 'add', objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], gidnumber=[u'1000'], - displayname=[u'Test User2'], - cn=[u'Test User2'], - mail=[u'%s@%s' % (user2, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user2), - )), + description=[], + omit=['mepmanagedentry'], + ), ), ), @@ -1309,31 +980,14 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - description=[], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], + result=get_user_result( + user1, u'Test', u'User1', 'add', objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], + description=[], memberof_group=[group1], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + omit=['mepmanagedentry'], + ), ), extra_check = not_upg_check, ), @@ -1346,31 +1000,15 @@ class test_user(Declarative): expected=dict( value=user2, summary=u'Added user "%s"' % user2, - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - description=[], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], + result=get_user_result( + user2, u'Test', u'User2', 'add', objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], + description=[], gidnumber=[u'1000'], - displayname=[u'Test User2'], - cn=[u'Test User2'], - mail=[u'%s@%s' % (user2, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], memberof_group=[group1], - has_keytab=False, - has_password=False, - dn=get_user_dn(user2), - )), + omit=['mepmanagedentry'], + ), ), ), @@ -1380,21 +1018,10 @@ class test_user(Declarative): 'user_mod', [user2], dict(manager=user1) ), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - loginshell=[u'/bin/sh'], - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - memberof_group=[group1], - mail=[u'%s@%s' % (user2, api.env.domain)], - nsaccountlock=False, - has_keytab=False, - has_password=False, - manager=[user1], - ), + result=get_user_result(user2, u'Test', u'User2', 'mod', + gidnumber=[u'1000'], + memberof_group=[group1], + manager=[user1]), summary=u'Modified user "%s"' % user2, value=user2, ), @@ -1404,19 +1031,11 @@ class test_user(Declarative): desc='Rename "%s"' % user1, command=('user_mod', [user1], dict(rename=renameduser1)), expected=dict( - result=dict( - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - loginshell=[u'/bin/sh'], - sn=[u'User1'], - uid=[renameduser1], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], + result=get_user_result( + renameduser1, u'Test', u'User1', 'mod', + homedirectory=[u'/home/%s' % user1], mail=[u'%s@%s' % (user1, api.env.domain)], memberof_group=[group1], - nsaccountlock=False, - has_keytab=False, - has_password=False, ), summary=u'Modified user "%s"' % user1, value=user1, @@ -1429,32 +1048,15 @@ class test_user(Declarative): 'user_show', [user2], {'all': True} ), expected=dict( - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user_base, - u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], + result=get_user_result( + user2, u'Test', u'User2', 'show-all', gidnumber=[u'1000'], - displayname=[u'Test User2'], - cn=[u'Test User2'], - mail=[u'%s@%s' % (user2, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], memberof_group=[group1], - nsaccountlock=False, - has_keytab=False, - has_password=False, - dn=get_user_dn(user2), manager=[renameduser1], - )), + objectclass=add_oc(objectclasses.user_base, + u'ipantuserattrs'), + omit=['mepmanagedentry'], + ), value=user2, summary=None, ), @@ -1476,31 +1078,14 @@ class test_user(Declarative): 'user_show', [user2], {'all': True} ), expected=dict( - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user_base, - u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], + result=get_user_result( + user2, u'Test', u'User2', 'show-all', gidnumber=[u'1000'], - displayname=[u'Test User2'], - cn=[u'Test User2'], - mail=[u'%s@%s' % (user2, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], memberof_group=[group1], - nsaccountlock=False, - has_keytab=False, - has_password=False, - dn=get_user_dn(user2), - )), + objectclass=add_oc(objectclasses.user_base, + u'ipantuserattrs'), + omit=['mepmanagedentry'], + ), value=user2, summary=None, ), @@ -1537,30 +1122,7 @@ class test_user(Declarative): expected=dict( value=admin2, summary=u'Added user "%s"' % admin2, - result=add_sid(dict( - gecos=[u'Second Admin'], - givenname=[u'Second'], - homedirectory=[u'/home/admin2'], - krbprincipalname=[u'admin2@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'Admin'], - uid=[admin2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - displayname=[u'Second Admin'], - cn=[u'Second Admin'], - initials=[u'SA'], - mail=[u'%s@%s' % (admin2, api.env.domain)], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(admin2)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(admin2), - )), + result=get_user_result(admin2, u'Second', u'Admin', 'add'), ), ), @@ -1726,32 +1288,7 @@ class test_user(Declarative): expected=dict( value=user2, summary=u'Added user "tuser2"', - result=add_sid(dict( - gecos=[u'Test User2'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser2'], - krbprincipalname=[u'tuser2@' + api.env.realm], - has_keytab=False, - has_password=False, - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User2'], - uid=[user2], - uidnumber=[fuzzy_digits], - gidnumber=[fuzzy_digits], - mail=[u'%s@%s' % (user2, api.env.domain)], - displayname=[u'Test User2'], - cn=[u'Test User2'], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn', 'global_policy'), ('cn', api.env.realm), ('cn', 'kerberos'), - api.env.basedn)], - mepmanagedentry=[DN(('cn', user2), ('cn', 'groups'), ('cn', 'accounts'), - api.env.basedn)], - memberof_group=[u'ipausers'], - dn=DN(('uid', 'tuser2'), ('cn', 'users'), ('cn', 'accounts'), - api.env.basedn), - )), + result=get_user_result(user2, u'Test', u'User2', 'add'), ), ), @@ -1764,30 +1301,9 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=objectclasses.user, - sn=[u'User1'], - uid=[user1], - uidnumber=[u'999'], - gidnumber=[u'999'], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - ), + result=get_user_result(user1, u'Test', u'User1', 'add', + uidnumber=[u'999'], + gidnumber=[u'999']), ), extra_check = upg_check, ), @@ -1812,30 +1328,11 @@ class test_user(Declarative): expected=dict( value=user1, summary=u'Added user "%s"' % user1, - result=add_sid(dict( - gecos=[u'Test User1'], - givenname=[u'Test'], - homedirectory=[u'/home/tuser1'], - krbprincipalname=[u'tuser1@' + api.env.realm], - loginshell=[u'/bin/sh'], - objectclass=add_oc(objectclasses.user, u'ipantuserattrs'), - sn=[u'User1'], - uid=[user1], + result=get_user_result( + user1, u'Test', u'User1', 'add', uidnumber=[lambda v: int(v) != 999], gidnumber=[lambda v: int(v) != 999], - displayname=[u'Test User1'], - cn=[u'Test User1'], - mail=[u'%s@%s' % (user1, api.env.domain)], - initials=[u'TU'], - ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=[get_group_dn(user1)], - memberof_group=[u'ipausers'], - has_keytab=False, - has_password=False, - dn=get_user_dn(user1), - )), + ), ), extra_check = upg_check, ), |