diff options
Diffstat (limited to 'tests/test_xmlrpc')
25 files changed, 592 insertions, 803 deletions
diff --git a/tests/test_xmlrpc/test_attr.py b/tests/test_xmlrpc/test_attr.py index f5003c40..799c7793 100644 --- a/tests/test_xmlrpc/test_attr.py +++ b/tests/test_xmlrpc/test_attr.py @@ -21,29 +21,17 @@ Test --setattr and --addattr and other attribute-specific issues """ -from ipalib import api, errors, x509 +from ipalib import api, errors from tests.test_xmlrpc import objectclasses -from xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_date, - fuzzy_hex, fuzzy_hash, fuzzy_issuer) -from ipalib.dn import * -import base64 - -user1 = u'tuser1' -fqdn1 = u'testhost1.%s' % api.env.domain - -# We can use the same cert we generated for the service tests -fd = open('tests/test_xmlrpc/service.crt', 'r') -servercert = fd.readlines() -servercert = u''.join(servercert) -servercert = x509.strip_header(servercert) -servercert = servercert.replace('\n', '') -fd.close() +from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid +from ipapython.dn import DN + +user1=u'tuser1' class test_attr(Declarative): cleanup_commands = [ ('user_del', [user1], {}), - ('host_del', [fqdn1], {}), ] tests = [ @@ -72,16 +60,13 @@ class test_attr(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), has_keytab=False, has_password=False, ), @@ -563,71 +548,4 @@ class test_attr(Declarative): desc='Server is unwilling to perform', info=''), ), - dict( - desc='Try to create %r with description and --addattr description' % fqdn1, - command=('host_add', [fqdn1], - dict( - description=u'Test host 1', - addattr=u'description=Test host 2', - force=True, - ), - ), - expected=errors.OnlyOneValueAllowed(attr='description'), - ), - - dict( - desc='Create %r with a certificate' % fqdn1, - command=('host_add', [fqdn1], - dict( - usercertificate=servercert, - force=True, - ), - ), - expected=dict( - value=fqdn1, - summary=u'Added host "%s"' % fqdn1, - result=dict( - dn=lambda x: DN(x) == DN(('fqdn',fqdn1),('cn','computers'), - ('cn','accounts'),api.env.basedn), - fqdn=[fqdn1], - krbprincipalname=[u'host/%s@%s' % (fqdn1, api.env.realm)], - objectclass=objectclasses.host, - ipauniqueid=[fuzzy_uuid], - managedby_host=[fqdn1], - usercertificate=[base64.b64decode(servercert)], - valid_not_before=fuzzy_date, - valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), - serial_number=fuzzy_digits, - serial_number_hex=fuzzy_hex, - md5_fingerprint=fuzzy_hash, - sha1_fingerprint=fuzzy_hash, - issuer=fuzzy_issuer, - has_keytab=False, - has_password=False, - ), - ), - ), - - dict( - desc='Remove %r certificate using --delattr' % fqdn1, - command=('host_mod', [fqdn1], - dict( - delattr=u'usercertificate=%s' % servercert, - ), - ), - expected=dict( - value=fqdn1, - summary=u'Modified host "%s"' % fqdn1, - result=dict( - fqdn=[fqdn1], - krbprincipalname=[u'host/%s@%s' % (fqdn1, api.env.realm)], - managedby_host=[fqdn1], - has_keytab=False, - has_password=False, - ), - ), - ), - ] diff --git a/tests/test_xmlrpc/test_automember_plugin.py b/tests/test_xmlrpc/test_automember_plugin.py index ceae8c3f..36a51093 100644 --- a/tests/test_xmlrpc/test_automember_plugin.py +++ b/tests/test_xmlrpc/test_automember_plugin.py @@ -22,6 +22,7 @@ Test the `ipalib/plugins/automember.py` module. """ from ipalib import api, errors +from ipapython.dn import DN from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid @@ -132,7 +133,7 @@ class test_automember(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn), + dn=DN(('cn', group1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -151,8 +152,8 @@ class test_automember(Declarative): description=[u'Test desc'], objectclass=objectclasses.hostgroup, ipauniqueid=[fuzzy_uuid], - mepmanagedentry=['cn=%s,cn=ng,cn=alt,%s' % (hostgroup1, api.env.basedn)], - dn=u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn), + mepmanagedentry=[DN(('cn', hostgroup1), ('cn', 'ng'), ('cn', 'alt'), api.env.basedn)], + dn=DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -171,8 +172,8 @@ class test_automember(Declarative): description=[u'Test desc'], objectclass=objectclasses.hostgroup, ipauniqueid=[fuzzy_uuid], - mepmanagedentry=['cn=%s,cn=ng,cn=alt,%s' % (hostgroup2, api.env.basedn)], - dn=u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup2, api.env.basedn), + mepmanagedentry=[DN(('cn', hostgroup2), ('cn', 'ng'), ('cn', 'alt'), api.env.basedn)], + dn=DN(('cn', hostgroup2), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -191,8 +192,8 @@ class test_automember(Declarative): description=[u'Test desc'], objectclass=objectclasses.hostgroup, ipauniqueid=[fuzzy_uuid], - mepmanagedentry=['cn=%s,cn=ng,cn=alt,%s' % (hostgroup3, api.env.basedn)], - dn=u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup3, api.env.basedn), + mepmanagedentry=[DN(('cn', hostgroup3), ('cn', 'ng'), ('cn', 'alt'), api.env.basedn)], + dn=DN(('cn', hostgroup3), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -211,8 +212,8 @@ class test_automember(Declarative): description=[u'Test desc'], objectclass=objectclasses.hostgroup, ipauniqueid=[fuzzy_uuid], - mepmanagedentry=['cn=%s,cn=ng,cn=alt,%s' % (hostgroup4, api.env.basedn)], - dn=u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup4, api.env.basedn), + mepmanagedentry=[DN(('cn', hostgroup4), ('cn', 'ng'), ('cn', 'alt'), api.env.basedn)], + dn=DN(('cn', hostgroup4), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -232,7 +233,7 @@ class test_automember(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=u'cn=%s,cn=groups,cn=accounts,%s' % (defaultgroup1, api.env.basedn), + dn=DN(('cn', defaultgroup1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -251,8 +252,8 @@ class test_automember(Declarative): description=[u'Default test desc'], objectclass=objectclasses.hostgroup, ipauniqueid=[fuzzy_uuid], - mepmanagedentry=['cn=%s,cn=ng,cn=alt,%s' % (defaulthostgroup1, api.env.basedn)], - dn=u'cn=%s,cn=hostgroups,cn=accounts,%s' % (defaulthostgroup1, api.env.basedn), + mepmanagedentry=[DN(('cn', defaulthostgroup1), ('cn', 'ng'), ('cn', 'alt'), api.env.basedn)], + dn=DN(('cn', defaulthostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), ), ), ), @@ -269,9 +270,9 @@ class test_automember(Declarative): result=dict( cn=[group1], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn)], + automembertargetgroup=[DN(('cn', group1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], objectclass=objectclasses.automember, - dn=u'cn=%s,cn=group,cn=automember,cn=etc,%s' % (group1, api.env.basedn), + dn=DN(('cn', group1), ('cn', 'group'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ), ), @@ -299,7 +300,7 @@ class test_automember(Declarative): cn=[group1], description=[u'Test desc'], automemberinclusiveregex=[u'manager=%s' % group_include_regex], - automembertargetgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn)], + automembertargetgroup=[DN(('cn', group1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], ), ), ), @@ -318,9 +319,9 @@ class test_automember(Declarative): result=dict( cn=[hostgroup1], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], objectclass=objectclasses.automember, - dn=u'cn=%s,cn=hostgroup,cn=automember,cn=etc,%s' % (hostgroup1, api.env.basedn), + dn=DN(('cn', hostgroup1), ('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ), ), @@ -348,7 +349,7 @@ class test_automember(Declarative): cn=[hostgroup1], description=[u'Test desc'], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_include_regex], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], ), ), ), @@ -401,7 +402,7 @@ class test_automember(Declarative): result=dict( cn=[hostgroup1], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_include_regex, u'fqdn=%s' % hostgroup_include_regex3, u'fqdn=%s' % hostgroup_include_regex2, @@ -428,9 +429,9 @@ class test_automember(Declarative): result=dict( cn=[hostgroup2], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup2, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup2), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], objectclass=objectclasses.automember, - dn=u'cn=%s,cn=hostgroup,cn=automember,cn=etc,%s' % (hostgroup2, api.env.basedn), + dn=DN(('cn', hostgroup2), ('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ), ), @@ -458,7 +459,7 @@ class test_automember(Declarative): cn=[hostgroup2], description=[u'Test desc'], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_exclude_regex], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup2, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup2), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], ), ), ), @@ -477,9 +478,9 @@ class test_automember(Declarative): result=dict( cn=[hostgroup3], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup3, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup3), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], objectclass=objectclasses.automember, - dn=u'cn=%s,cn=hostgroup,cn=automember,cn=etc,%s' % (hostgroup3, api.env.basedn), + dn=DN(('cn', hostgroup3), ('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ), ), @@ -507,7 +508,7 @@ class test_automember(Declarative): cn=[hostgroup3], description=[u'Test desc'], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_exclude_regex2], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup3, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup3), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], ), ), ), @@ -526,9 +527,9 @@ class test_automember(Declarative): result=dict( cn=[hostgroup4], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup4, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup4), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], objectclass=objectclasses.automember, - dn=u'cn=%s,cn=hostgroup,cn=automember,cn=etc,%s' % (hostgroup4, api.env.basedn), + dn=DN(('cn', hostgroup4), ('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ), ), @@ -556,7 +557,7 @@ class test_automember(Declarative): cn=[hostgroup4], description=[u'Test desc'], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_exclude_regex3], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup4, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup4), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], ), ), ), @@ -574,8 +575,8 @@ class test_automember(Declarative): cn=[group1], description=[u'Test desc'], automemberinclusiveregex=[u'manager=%s' % group_include_regex], - automembertargetgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn)], - dn=u'cn=%s,cn=group,cn=automember,cn=etc,%s' % (group1, api.env.basedn), + automembertargetgroup=[DN(('cn', group1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], + dn=DN(('cn', group1), ('cn', 'group'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), summary=None, ), @@ -596,8 +597,8 @@ class test_automember(Declarative): cn=[group1], description=[u'Test desc'], automemberinclusiveregex=[u'manager=%s' % group_include_regex], - automembertargetgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn)], - dn=u'cn=%s,cn=group,cn=automember,cn=etc,%s' % (group1, api.env.basedn), + automembertargetgroup=[DN(('cn', group1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], + dn=DN(('cn', group1), ('cn', 'group'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ], summary=u'1 rules matched', @@ -618,7 +619,7 @@ class test_automember(Declarative): cn=[group1], description=[u'New desc 1'], automemberinclusiveregex=[u'manager=%s' % group_include_regex], - automembertargetgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn)], + automembertargetgroup=[DN(('cn', group1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], ), summary=u'Modified automember rule "%s"' % group1, value=group1, @@ -637,7 +638,7 @@ class test_automember(Declarative): result=dict( cn=[hostgroup1], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_include_regex, u'fqdn=%s' % hostgroup_include_regex3, u'fqdn=%s' % hostgroup_include_regex2, @@ -646,7 +647,7 @@ class test_automember(Declarative): u'fqdn=%s' % hostgroup_exclude_regex3, u'fqdn=%s' % hostgroup_exclude_regex, ], - dn=u'cn=%s,cn=hostgroup,cn=automember,cn=etc,%s' % (hostgroup1, api.env.basedn), + dn=DN(('cn', hostgroup1), ('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), summary=None, ), @@ -666,7 +667,7 @@ class test_automember(Declarative): dict( cn=[hostgroup1], description=[u'Test desc'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_include_regex, u'fqdn=%s' % hostgroup_include_regex3, u'fqdn=%s' % hostgroup_include_regex2, @@ -675,7 +676,7 @@ class test_automember(Declarative): u'fqdn=%s' % hostgroup_exclude_regex3, u'fqdn=%s' % hostgroup_exclude_regex, ], - dn=u'cn=%s,cn=hostgroup,cn=automember,cn=etc,%s' % (hostgroup1, api.env.basedn), + dn=DN(('cn', hostgroup1), ('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), ), ], summary=u'1 rules matched', @@ -695,7 +696,7 @@ class test_automember(Declarative): result=dict( cn=[hostgroup1], description=[u'New desc 1'], - automembertargetgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn)], + automembertargetgroup=[DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], automemberinclusiveregex=[u'fqdn=%s' % hostgroup_include_regex, u'fqdn=%s' % hostgroup_include_regex3, u'fqdn=%s' % hostgroup_include_regex2, @@ -722,7 +723,7 @@ class test_automember(Declarative): expected=dict( result=dict( cn=[u'Group'], - automemberdefaultgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (defaultgroup1, api.env.basedn)], + automemberdefaultgroup=[DN(('cn', defaultgroup1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], ), value=u'group', summary=u'Set default (fallback) group for automember "group"', @@ -737,9 +738,9 @@ class test_automember(Declarative): ), expected=dict( result=dict( - dn=u'cn=group,cn=automember,cn=etc,%s' % (api.env.basedn), + dn=DN(('cn', 'group'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), cn=[u'Group'], - automemberdefaultgroup=[u'cn=%s,cn=groups,cn=accounts,%s' % (defaultgroup1, api.env.basedn)], + automemberdefaultgroup=[DN(('cn', defaultgroup1), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)], ), value=u'group', summary=None, @@ -758,7 +759,7 @@ class test_automember(Declarative): expected=dict( result=dict( cn=[u'Hostgroup'], - automemberdefaultgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (defaulthostgroup1, api.env.basedn)], + automemberdefaultgroup=[DN(('cn', defaulthostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], ), value=u'hostgroup', summary=u'Set default (fallback) group for automember "hostgroup"', @@ -775,9 +776,9 @@ class test_automember(Declarative): ), expected=dict( result=dict( - dn=u'cn=hostgroup,cn=automember,cn=etc,%s' % (api.env.basedn), + dn=DN(('cn', 'hostgroup'), ('cn', 'automember'), ('cn', 'etc'), api.env.basedn), cn=[u'Hostgroup'], - automemberdefaultgroup=[u'cn=%s,cn=hostgroups,cn=accounts,%s' % (defaulthostgroup1, api.env.basedn)], + automemberdefaultgroup=[DN(('cn', defaulthostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn)], ), value=u'hostgroup', summary=None, @@ -810,10 +811,13 @@ class test_automember(Declarative): cn=[u'Michael Scott'], initials=[u'MS'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=[u'cn=global_policy,cn=%s,cn=kerberos,%s' % (api.env.realm, api.env.basedn)], - mepmanagedentry=[u'cn=%s,cn=groups,cn=accounts,%s' % (manager1, api.env.basedn)], + 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=u'uid=mscott,cn=users,cn=accounts,' + api.env.basedn, + dn=DN(('uid', 'mscott'), ('cn', 'users'), ('cn', 'accounts'), + api.env.basedn), ), ), ), @@ -840,15 +844,18 @@ class test_automember(Declarative): uid=[user1], uidnumber=[fuzzy_digits], gidnumber=[fuzzy_digits], - manager=[u'uid=mscott,cn=users,cn=accounts,%s' % api.env.basedn], + 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=[u'cn=global_policy,cn=%s,cn=kerberos,%s' % (api.env.realm, api.env.basedn)], - mepmanagedentry=[u'cn=%s,cn=groups,cn=accounts,%s' % (user1, api.env.basedn)], + 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=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn, + dn=DN(('uid', 'tuser1'), ('cn', 'users'), ('cn', 'accounts'), + api.env.basedn), ), ), ), @@ -867,7 +874,7 @@ class test_automember(Declarative): value=fqdn1, summary=u'Added host "%s"' % fqdn1, result=dict( - dn=u'fqdn=%s,cn=computers,cn=accounts,%s' % (fqdn1, api.env.basedn), + dn=DN(('fqdn', fqdn1), ('cn', 'computers'), ('cn', 'accounts'), api.env.basedn), fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -895,7 +902,7 @@ class test_automember(Declarative): value=fqdn2, summary=u'Added host "%s"' % fqdn2, result=dict( - dn=u'fqdn=%s,cn=computers,cn=accounts,%s' % (fqdn2, api.env.basedn), + dn=DN(('fqdn', fqdn2), ('cn', 'computers'), ('cn', 'accounts'), api.env.basedn), fqdn=[fqdn2], description=[u'Test host 2'], l=[u'Undisclosed location 1'], @@ -923,7 +930,7 @@ class test_automember(Declarative): value=fqdn3, summary=u'Added host "%s"' % fqdn3, result=dict( - dn=u'fqdn=%s,cn=computers,cn=accounts,%s' % (fqdn3, api.env.basedn), + dn=DN(('fqdn', fqdn3), ('cn', 'computers'), ('cn', 'accounts'), api.env.basedn), fqdn=[fqdn3], description=[u'Test host 3'], l=[u'Undisclosed location 1'], @@ -951,7 +958,7 @@ class test_automember(Declarative): value=fqdn4, summary=u'Added host "%s"' % fqdn4, result=dict( - dn=u'fqdn=%s,cn=computers,cn=accounts,%s' % (fqdn4, api.env.basedn), + dn=DN(('fqdn', fqdn4), ('cn', 'computers'), ('cn', 'accounts'), api.env.basedn), fqdn=[fqdn4], description=[u'Test host 4'], l=[u'Undisclosed location 1'], @@ -979,7 +986,7 @@ class test_automember(Declarative): value=fqdn5, summary=u'Added host "%s"' % fqdn5, result=dict( - dn=u'fqdn=%s,cn=computers,cn=accounts,%s' % (fqdn5, api.env.basedn), + dn=DN(('fqdn', fqdn5), ('cn', 'computers'), ('cn', 'accounts'), api.env.basedn), fqdn=[fqdn5], description=[u'Test host 5'], l=[u'Undisclosed location 1'], @@ -1001,7 +1008,7 @@ class test_automember(Declarative): value=hostgroup1, summary=None, result={ - 'dn': u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup1, api.env.basedn), + 'dn': DN(('cn', hostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), 'member_host': [u'%s' % fqdn1], 'cn': [hostgroup1], 'description': [u'Test desc'], @@ -1017,7 +1024,7 @@ class test_automember(Declarative): value=defaulthostgroup1, summary=None, result={ - 'dn': u'cn=%s,cn=hostgroups,cn=accounts,%s' % (defaulthostgroup1, api.env.basedn), + 'dn': DN(('cn', defaulthostgroup1), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), 'member_host': [u'%s' % fqdn2], 'cn': [defaulthostgroup1], 'description': [u'Default test desc'], @@ -1033,7 +1040,7 @@ class test_automember(Declarative): value=hostgroup2, summary=None, result={ - 'dn': u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup2, api.env.basedn), + 'dn': DN(('cn', hostgroup2), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), 'member_host': [u'%s' % fqdn3], 'cn': [hostgroup2], 'description': [u'Test desc'], @@ -1049,7 +1056,7 @@ class test_automember(Declarative): value=hostgroup3, summary=None, result={ - 'dn': u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup3, api.env.basedn), + 'dn': DN(('cn', hostgroup3), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), 'member_host': [u'%s' % fqdn4], 'cn': [hostgroup3], 'description': [u'Test desc'], @@ -1065,7 +1072,7 @@ class test_automember(Declarative): value=hostgroup4, summary=None, result={ - 'dn': u'cn=%s,cn=hostgroups,cn=accounts,%s' % (hostgroup4, api.env.basedn), + 'dn': DN(('cn', hostgroup4), ('cn', 'hostgroups'), ('cn', 'accounts'), api.env.basedn), 'member_host': [u'%s' % fqdn5], 'cn': [hostgroup4], 'description': [u'Test desc'], diff --git a/tests/test_xmlrpc/test_automount_plugin.py b/tests/test_xmlrpc/test_automount_plugin.py index d6c28997..19968a0d 100644 --- a/tests/test_xmlrpc/test_automount_plugin.py +++ b/tests/test_xmlrpc/test_automount_plugin.py @@ -28,7 +28,7 @@ import shutil from ipalib import api from ipalib import errors -from ipalib.dn import DN +from ipapython.dn import DN from nose.tools import raises, assert_raises # pylint: disable=E0611 from xmlrpc_test import XMLRPC_test, assert_attr_equal @@ -238,40 +238,36 @@ class test_automount(AutomountTest): result=dict( keys={'auto.direct': ()}, orphanmaps=(dict( - dn=lambda dn: DN(dn) == DN( - ('automountmapname', self.mapname), - ('cn', self.locname), - ('cn', 'automount'), api.env.basedn), + dn=DN(('automountmapname', self.mapname), + ('cn', self.locname), + ('cn', 'automount'), api.env.basedn), description=(u'description of map',), automountmapname=(u'testmap',)),), orphankeys=[( dict( - dn=lambda dn: DN(dn) == DN( - ('description', self.keyname2), - ('automountmapname', 'testmap'), - ('cn', self.locname), - ('cn', 'automount'), api.env.basedn), + dn=DN(('description', self.keyname2), + ('automountmapname', 'testmap'), + ('cn', self.locname), + ('cn', 'automount'), api.env.basedn), automountkey=(self.keyname2,), description=(self.keyname2,), automountinformation=(u'ro',), ), dict( - dn=lambda dn: DN(dn) == DN( - ('description', self.keyname_rename), - ('automountmapname', 'testmap'), - ('cn', self.locname), - ('cn', 'automount'), api.env.basedn), + dn=DN(('description', self.keyname_rename), + ('automountmapname', 'testmap'), + ('cn', self.locname), + ('cn', 'automount'), api.env.basedn), automountkey=(self.keyname_rename,), description=(self.keyname_rename,), automountinformation=(u'rw',), ))], maps=( dict( - dn=lambda dn: DN(dn) == DN( - ('description', '/- auto.direct'), - ('automountmapname', 'auto.master'), - ('cn', self.locname), - ('cn', 'automount'), api.env.basedn), + dn=DN(('description', '/- auto.direct'), + ('automountmapname', 'auto.master'), + ('cn', self.locname), + ('cn', 'automount'), api.env.basedn), automountkey=(u'/-',), description=(u'/- auto.direct',), automountinformation=(u'auto.direct',) diff --git a/tests/test_xmlrpc/test_batch_plugin.py b/tests/test_xmlrpc/test_batch_plugin.py index 19728add..55e55705 100644 --- a/tests/test_xmlrpc/test_batch_plugin.py +++ b/tests/test_xmlrpc/test_batch_plugin.py @@ -25,7 +25,7 @@ from ipalib import api, errors from tests.test_xmlrpc import objectclasses from tests.util import assert_equal, Fuzzy, assert_deepequal from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import DN +from ipapython.dn import DN group1 = u'testgroup1' @@ -96,11 +96,10 @@ class test_batch(Declarative): objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], gidnumber=[fuzzy_digits], - dn=lambda x: DN(x) == \ - DN(('cn', 'testgroup1'), - ('cn', 'groups'), - ('cn', 'accounts'), - api.env.basedn), + dn=DN(('cn', 'testgroup1'), + ('cn', 'groups'), + ('cn', 'accounts'), + api.env.basedn), ), error=None), dict( @@ -159,11 +158,10 @@ class test_batch(Declarative): objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], gidnumber=[fuzzy_digits], - dn=lambda x: DN(x) == \ - DN(('cn', 'testgroup1'), - ('cn', 'groups'), - ('cn', 'accounts'), - api.env.basedn), + dn=DN(('cn', 'testgroup1'), + ('cn', 'groups'), + ('cn', 'accounts'), + api.env.basedn), ), error=None), ), diff --git a/tests/test_xmlrpc/test_cert.py b/tests/test_xmlrpc/test_cert.py index 90809ab3..4f95ffe1 100644 --- a/tests/test_xmlrpc/test_cert.py +++ b/tests/test_xmlrpc/test_cert.py @@ -33,7 +33,7 @@ import tempfile from ipapython import ipautil import nose import base64 -from ipalib.dn import * +from ipapython.dn import DN # So we can save the cert from issuance and compare it later cert = None diff --git a/tests/test_xmlrpc/test_delegation_plugin.py b/tests/test_xmlrpc/test_delegation_plugin.py index 95aa8287..a31fed3e 100644 --- a/tests/test_xmlrpc/test_delegation_plugin.py +++ b/tests/test_xmlrpc/test_delegation_plugin.py @@ -24,6 +24,7 @@ Test the `ipalib/plugins/delegation.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid +from ipapython.dn import DN delegation1 = u'testdelegation' member1 = u'admins' @@ -148,8 +149,9 @@ class test_delegation(Declarative): value=delegation1, summary=None, result={ - 'aci': u'(targetattr = "street || c || l || st || postalcode")(targetfilter = "(memberOf=cn=admins,cn=groups,cn=accounts,%s)")(version 3.0;acl "delegation:testdelegation";allow (write) groupdn = "ldap:///cn=editors,cn=groups,cn=accounts,%s";)' \ - % (api.env.basedn, api.env.basedn) + 'aci': u'(targetattr = "street || c || l || st || postalcode")(targetfilter = "(memberOf=%s)")(version 3.0;acl "delegation:testdelegation";allow (write) groupdn = "ldap:///%s";)' % \ + (DN(('cn', 'admins'), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn), + DN(('cn', 'editors'), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)) }, ), ), @@ -200,8 +202,9 @@ class test_delegation(Declarative): summary=u'1 delegation matched', result=[ { - 'aci': u'(targetattr = "street || c || l || st || postalcode")(targetfilter = "(memberOf=cn=admins,cn=groups,cn=accounts,%s)")(version 3.0;acl "delegation:testdelegation";allow (write) groupdn = "ldap:///cn=editors,cn=groups,cn=accounts,%s";)' \ - % (api.env.basedn, api.env.basedn), + 'aci': u'(targetattr = "street || c || l || st || postalcode")(targetfilter = "(memberOf=%s)")(version 3.0;acl "delegation:testdelegation";allow (write) groupdn = "ldap:///%s";)' % \ + (DN(('cn', 'admins'), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn), + DN(('cn', 'editors'), ('cn', 'groups'), ('cn', 'accounts'), api.env.basedn)), }, ], ), diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py index 9c9b2239..2b6d53c0 100644 --- a/tests/test_xmlrpc/test_dns_plugin.py +++ b/tests/test_xmlrpc/test_dns_plugin.py @@ -22,7 +22,7 @@ Test the `ipalib/plugins/dns.py` module. import nose from ipalib import api, errors -from ipalib.dn import * +from ipapython.dn import DN from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid @@ -139,7 +139,7 @@ class test_dns(Declarative): 'value': dnszone1, 'summary': None, 'result': { - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [dnszone1], 'idnszoneactive': [u'TRUE'], 'idnssoamname': [dnszone1_mname], @@ -200,7 +200,7 @@ class test_dns(Declarative): 'value': dnszone2, 'summary': None, 'result': { - 'dn': unicode(dnszone2_dn), + 'dn': dnszone2_dn, 'idnsname': [dnszone2], 'idnszoneactive': [u'TRUE'], 'idnssoamname': [dnszone2_mname], @@ -240,7 +240,7 @@ class test_dns(Declarative): 'value': dnszone1, 'summary': None, 'result': { - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [dnszone1], 'idnszoneactive': [u'TRUE'], 'nsrecord': [dnszone1_mname], @@ -295,7 +295,7 @@ class test_dns(Declarative): 'value': revdnszone1, 'summary': None, 'result': { - 'dn': unicode(revdnszone1_dn), + 'dn': revdnszone1_dn, 'idnsname': [revdnszone1], 'idnszoneactive': [u'TRUE'], 'idnssoamname': [dnszone1_mname], @@ -325,7 +325,7 @@ class test_dns(Declarative): 'count': 2, 'truncated': False, 'result': [{ - 'dn': unicode(revdnszone1_dn), + 'dn': revdnszone1_dn, 'idnsname': [revdnszone1], 'idnszoneactive': [u'TRUE'], 'nsrecord': [dnszone1_mname], @@ -340,7 +340,7 @@ class test_dns(Declarative): 'idnsallowquery': [u'any;'], }, { - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [dnszone1], 'idnszoneactive': [u'TRUE'], 'nsrecord': [dnszone1_mname], @@ -366,7 +366,7 @@ class test_dns(Declarative): 'count': 1, 'truncated': False, 'result': [{ - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [dnszone1], 'idnszoneactive': [u'TRUE'], 'nsrecord': [dnszone1_mname], @@ -413,7 +413,7 @@ class test_dns(Declarative): 'value': dnszone1, 'summary': None, 'result': { - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [dnszone1], 'idnszoneactive': [u'FALSE'], 'nsrecord': [dnszone1_mname], @@ -449,7 +449,7 @@ class test_dns(Declarative): 'value': dnszone1, 'summary': None, 'result': { - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [dnszone1], 'idnszoneactive': [u'TRUE'], 'nsrecord': [dnszone1_mname], @@ -507,7 +507,7 @@ class test_dns(Declarative): 'value': dnsres1, 'summary': None, 'result': { - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'objectclass': objectclasses.dnsrecord, 'arecord': [u'127.0.0.1'], @@ -525,17 +525,17 @@ class test_dns(Declarative): 'truncated': False, 'result': [ { - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'nsrecord': (dnszone1_mname,), 'idnsname': [u'@'], }, { - 'dn': unicode(dnszone1_mname_dn), + 'dn': dnszone1_mname_dn, 'idnsname': [u'ns1'], 'arecord': [u'1.2.3.4'], }, { - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'arecord': [u'127.0.0.1'], }, @@ -551,7 +551,7 @@ class test_dns(Declarative): 'value': dnsres1, 'summary': None, 'result': { - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'arecord': [u'127.0.0.1', u'10.10.0.1'], 'objectclass': objectclasses.dnsrecord, @@ -633,7 +633,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnszone, - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [u'@'], 'mxrecord': [u"0 %s" % dnszone1_mname], 'nsrecord': [dnszone1_mname], @@ -681,7 +681,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(DN(('idnsname', u'_foo._tcp'), dnszone1_dn)), + 'dn': DN(('idnsname', u'_foo._tcp'), dnszone1_dn), 'idnsname': [u'_foo._tcp'], 'srvrecord': [u"0 100 1234 %s" % dnszone1_mname], }, @@ -738,7 +738,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnszone, - 'dn': unicode(dnszone1_dn), + 'dn': dnszone1_dn, 'idnsname': [u'@'], 'mxrecord': [u"0 %s" % dnszone1_mname], 'nsrecord': [dnszone1_mname], @@ -770,7 +770,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsrescname_dn), + 'dn': dnsrescname_dn, 'idnsname': [dnsrescname], 'cnamerecord': [u'foo-1.example.com.'], }, @@ -821,7 +821,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'arecord': [u'10.10.0.1'], 'kxrecord': [u'1 foo-1'], @@ -837,7 +837,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'arecord': [u'10.10.0.1'], 'kxrecord': [u'1 foo-1'], @@ -856,7 +856,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'arecord': [u'10.10.0.1'], 'kxrecord': [u'1 foo-1'], @@ -887,7 +887,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'arecord': [u'10.10.0.1'], 'kxrecord': [u'1 foo-1'], @@ -962,7 +962,7 @@ class test_dns(Declarative): 'value': revdnszone1, 'summary': None, 'result': { - 'dn': unicode(revdnszone1_dn), + 'dn': revdnszone1_dn, 'idnsname': [revdnszone1], 'idnszoneactive': [u'TRUE'], 'idnssoamname': [dnszone1_mname], @@ -1000,7 +1000,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsrev1_dn), + 'dn': dnsrev1_dn, 'idnsname': [dnsrev1], 'ptrrecord': [u'foo-1.example.com.'], }, @@ -1015,7 +1015,7 @@ class test_dns(Declarative): 'summary': None, 'result': { 'objectclass': objectclasses.dnsrecord, - 'dn': unicode(dnsrev1_dn), + 'dn': dnsrev1_dn, 'idnsname': [dnsrev1], 'ptrrecord': [u'foo-1.example.com.'], 'cnamerecord': [u'foo-1.example.com.'], @@ -1120,7 +1120,7 @@ class test_dns(Declarative): 'value': dnsres1, 'summary': None, 'result': { - 'dn': unicode(dnsres1_dn), + 'dn': dnsres1_dn, 'idnsname': [dnsres1], 'objectclass': objectclasses.dnsrecord, 'arecord': [u'80.142.15.81'], @@ -1136,7 +1136,7 @@ class test_dns(Declarative): 'value': dnsrev2, 'summary': None, 'result': { - 'dn': unicode(dnsrev2_dn), + 'dn': dnsrev2_dn, 'idnsname': [dnsrev2], 'ptrrecord': [dnsres1 + '.' + dnszone1 + '.'], }, @@ -1183,7 +1183,7 @@ class test_dns(Declarative): value=dnszone1_permission, summary=None, result={ - 'dn': lambda x: DN(x) == dnszone1_permission_dn, + 'dn': dnszone1_permission_dn, 'cn': [dnszone1_permission], 'ipapermissiontype': [u'SYSTEM'], }, @@ -1232,4 +1232,3 @@ class test_dns(Declarative): ), ] - diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py index 08cf7418..de4635d3 100644 --- a/tests/test_xmlrpc/test_group_plugin.py +++ b/tests/test_xmlrpc/test_group_plugin.py @@ -24,7 +24,7 @@ Test the `ipalib/plugins/group.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN group1 = u'testgroup1' group2 = u'testgroup2' @@ -48,6 +48,7 @@ class test_group(Declarative): ('group_del', [group1], {}), ('group_del', [group2], {}), ('group_del', [group3], {}), + ('group_del', [renamedgroup1], {}), ('user_del', [user1], {}), ] @@ -96,7 +97,7 @@ class test_group(Declarative): description=[u'Test desc 1'], objectclass=objectclasses.group, ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == get_group_dn('testgroup1'), + dn=get_group_dn('testgroup1'), ), ), ), @@ -121,7 +122,7 @@ class test_group(Declarative): result=dict( cn=[group1], description=[u'Test desc 1'], - dn=lambda x: DN(x) == get_group_dn('testgroup1'), + dn=get_group_dn('testgroup1'), ), ), ), @@ -151,7 +152,7 @@ class test_group(Declarative): result=dict( cn=[group1], description=[u'New desc 1'], - dn=lambda x: DN(x) == get_group_dn('testgroup1'), + dn=get_group_dn('testgroup1'), ), summary=None, ), @@ -184,7 +185,7 @@ class test_group(Declarative): result=dict( cn=[group1], description=(u'New desc 1',), - dn=lambda x: DN(x) == get_group_dn('testgroup1'), + dn=get_group_dn('testgroup1'), gidnumber=[fuzzy_digits], ), summary=None, @@ -200,7 +201,7 @@ class test_group(Declarative): truncated=False, result=[ dict( - dn=lambda x: DN(x) == get_group_dn(group1), + dn=get_group_dn(group1), cn=[group1], description=[u'New desc 1'], gidnumber=[fuzzy_digits], @@ -249,7 +250,7 @@ class test_group(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == get_group_dn('testgroup2'), + dn=get_group_dn('testgroup2'), ), ), ), @@ -275,7 +276,7 @@ class test_group(Declarative): cn=[group2], description=[u'Test desc 2'], gidnumber=[fuzzy_digits], - dn=lambda x: DN(x) == get_group_dn('testgroup2'), + dn=get_group_dn('testgroup2'), ), ), ), @@ -307,7 +308,7 @@ class test_group(Declarative): cn=[group2], description=[u'New desc 2'], gidnumber=[fuzzy_digits], - dn=lambda x: DN(x) == get_group_dn('testgroup2'), + dn=get_group_dn('testgroup2'), ), summary=None, ), @@ -322,7 +323,7 @@ class test_group(Declarative): truncated=False, result=[ dict( - dn=lambda x: DN(x) == get_group_dn('testgroup2'), + dn=get_group_dn('testgroup2'), cn=[group2], description=[u'New desc 2'], gidnumber=[fuzzy_digits], @@ -342,37 +343,37 @@ class test_group(Declarative): truncated=False, result=[ { - 'dn': lambda x: DN(x) == get_group_dn('admins'), + 'dn': get_group_dn('admins'), 'member_user': [u'admin'], 'gidnumber': [fuzzy_digits], 'cn': [u'admins'], 'description': [u'Account administrators group'], }, { - 'dn': lambda x: DN(x) == get_group_dn('editors'), + 'dn': get_group_dn('editors'), 'gidnumber': [fuzzy_digits], 'cn': [u'editors'], 'description': [u'Limited admins who can edit other users'], }, { - 'dn': lambda x: DN(x) == get_group_dn('ipausers'), + 'dn': get_group_dn('ipausers'), 'cn': [u'ipausers'], 'description': [u'Default group for all users'], }, dict( - dn=lambda x: DN(x) == get_group_dn(group1), + dn=get_group_dn(group1), cn=[group1], description=[u'New desc 1'], gidnumber=[fuzzy_digits], ), dict( - dn=lambda x: DN(x) == get_group_dn(group2), + dn=get_group_dn(group2), cn=[group2], description=[u'New desc 2'], gidnumber=[fuzzy_digits], ), { - 'dn': lambda x: DN(x) == get_group_dn('trust admins'), + 'dn': get_group_dn('trust admins'), 'member_user': [u'admin'], 'cn': [u'trust admins'], 'description': [u'Trusts administrators group'], @@ -396,7 +397,7 @@ class test_group(Declarative): description=[u'Test desc 3'], objectclass=objectclasses.externalgroup, ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == get_group_dn(group3), + dn=get_group_dn(group3), ), ), ), @@ -456,7 +457,7 @@ class test_group(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == get_group_dn(group1), + 'dn': get_group_dn(group1), 'member_group': (group2,), 'gidnumber': [fuzzy_digits], 'cn': [group1], @@ -480,7 +481,7 @@ class test_group(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == get_group_dn(group1), + 'dn': get_group_dn(group1), 'member_group': (group2,), 'gidnumber': [fuzzy_digits], 'cn': [group1], @@ -503,7 +504,7 @@ class test_group(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == get_group_dn(group1), + 'dn': get_group_dn(group1), 'cn': [group1], 'gidnumber': [fuzzy_digits], 'description': [u'New desc 1'], @@ -526,7 +527,7 @@ class test_group(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == get_group_dn(group1), + 'dn': get_group_dn(group1), 'cn': [group1], 'gidnumber': [fuzzy_digits], 'description': [u'New desc 1'], @@ -691,15 +692,12 @@ class test_group(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [get_group_dn(user1)], + krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), + ('cn','kerberos'),api.env.basedn)], + mepmanagedentry=[get_group_dn(user1)], memberof_group=[u'ipausers'], - dn=lambda x: DN(x) == \ - DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid',user1),('cn','users'),('cn','accounts'), + api.env.basedn), has_keytab=False, has_password=False, ), @@ -717,7 +715,7 @@ class test_group(Declarative): cn=[user1], description=[u'User private group for %s' % user1], gidnumber=[fuzzy_digits], - dn=lambda x: DN(x) == get_group_dn(user1), + dn=get_group_dn(user1), ), ), ), @@ -731,7 +729,7 @@ class test_group(Declarative): truncated=False, result=[ dict( - dn=lambda x: DN(x) == get_group_dn(user1), + dn=get_group_dn(user1), cn=[user1], description=[u'User private group for %s' % user1], gidnumber=[fuzzy_digits], @@ -810,12 +808,10 @@ class test_group(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], + 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, @@ -848,7 +844,7 @@ class test_group(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == get_group_dn('admins'), + 'dn': get_group_dn('admins'), 'member_user': [u'admin', user1], 'gidnumber': [fuzzy_digits], 'cn': [u'admins'], diff --git a/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py b/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py index 1552f46c..591c8a96 100644 --- a/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py +++ b/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py @@ -24,7 +24,7 @@ Test the `ipalib.plugins.hbacsvcgroup` module. from ipalib import api, errors from tests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_uuid from tests.test_xmlrpc import objectclasses -from ipalib.dn import * +from ipapython.dn import DN hbacsvcgroup1 = u'testhbacsvcgroup1' dn1 = DN(('cn',hbacsvcgroup1),('cn','hbacservicegroups'),('cn','hbac'), @@ -79,7 +79,7 @@ class test_hbacsvcgroup(Declarative): value=hbacsvcgroup1, summary=u'Added HBAC service group "testhbacsvcgroup1"', result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, cn=[hbacsvcgroup1], objectclass=objectclasses.hbacsvcgroup, description=[u'Test hbacsvcgroup 1'], @@ -111,7 +111,7 @@ class test_hbacsvcgroup(Declarative): value=hbacsvc1, summary=u'Added HBAC service "%s"' % hbacsvc1, result=dict( - dn=lambda x: DN(x) == hbacsvc_dn1, + dn=hbacsvc_dn1, cn=[hbacsvc1], description=[u'Test service 1'], objectclass=objectclasses.hbacsvc, @@ -134,7 +134,7 @@ class test_hbacsvcgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'cn': [hbacsvcgroup1], 'description': [u'Test hbacsvcgroup 1'], 'member_hbacsvc': [hbacsvc1], @@ -150,7 +150,7 @@ class test_hbacsvcgroup(Declarative): value=hbacsvcgroup1, summary=None, result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'member_hbacsvc': [hbacsvc1], 'cn': [hbacsvcgroup1], 'description': [u'Test hbacsvcgroup 1'], @@ -168,7 +168,7 @@ class test_hbacsvcgroup(Declarative): summary=u'1 HBAC service group matched', result=[ { - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'member_hbacsvc': [hbacsvc1], 'cn': [hbacsvcgroup1], 'description': [u'Test hbacsvcgroup 1'], @@ -202,7 +202,7 @@ class test_hbacsvcgroup(Declarative): value=hbacsvcgroup1, summary=None, result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'member_hbacsvc': [hbacsvc1], 'cn': [hbacsvcgroup1], 'description': [u'Updated hbacsvcgroup 1'], @@ -224,7 +224,7 @@ class test_hbacsvcgroup(Declarative): ), completed=1, result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'cn': [hbacsvcgroup1], 'description': [u'Updated hbacsvcgroup 1'], }, diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py index c9ec6a2b..27d3adb0 100644 --- a/tests/test_xmlrpc/test_host_plugin.py +++ b/tests/test_xmlrpc/test_host_plugin.py @@ -26,7 +26,7 @@ import os import tempfile from ipapython import ipautil from ipalib import api, errors, x509 -from ipalib.dn import * +from ipapython.dn import DN from nose.tools import raises, assert_raises from nose.plugins.skip import Skip, SkipTest from tests.test_xmlrpc.xmlrpc_test import (Declarative, XMLRPC_test, @@ -111,7 +111,7 @@ class test_host(Declarative): value=fqdn1, summary=u'Added host "%s"' % fqdn1, result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -147,7 +147,7 @@ class test_host(Declarative): value=fqdn1, summary=None, result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -167,7 +167,7 @@ class test_host(Declarative): value=fqdn1, summary=None, result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, cn=[fqdn1], fqdn=[fqdn1], description=[u'Test host 1'], @@ -198,7 +198,7 @@ class test_host(Declarative): summary=u'1 host matched', result=[ dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -221,7 +221,7 @@ class test_host(Declarative): summary=u'1 host matched', result=[ dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, cn=[fqdn1], fqdn=[fqdn1], description=[u'Test host 1'], @@ -260,8 +260,7 @@ class test_host(Declarative): usercertificate=[base64.b64decode(servercert)], valid_not_before=fuzzy_date, valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), + subject=DN(('CN',api.env.host),x509.subject_base()), serial_number=fuzzy_digits, serial_number_hex=fuzzy_hex, md5_fingerprint=fuzzy_hash, @@ -281,7 +280,7 @@ class test_host(Declarative): value=fqdn1, summary=None, result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, fqdn=[fqdn1], description=[u'Updated host 1'], l=[u'Undisclosed location 1'], @@ -292,8 +291,7 @@ class test_host(Declarative): usercertificate=[base64.b64decode(servercert)], valid_not_before=fuzzy_date, valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), + subject=DN(('CN',api.env.host),x509.subject_base()), serial_number=fuzzy_digits, serial_number_hex=fuzzy_hex, md5_fingerprint=fuzzy_hash, @@ -316,7 +314,7 @@ class test_host(Declarative): value=fqdn3, summary=u'Added host "%s"' % fqdn3, result=dict( - dn=lambda x: DN(x) == dn3, + dn=dn3, fqdn=[fqdn3], description=[u'Test host 2'], l=[u'Undisclosed location 2'], @@ -344,7 +342,7 @@ class test_host(Declarative): value=fqdn4, summary=u'Added host "%s"' % fqdn4, result=dict( - dn=lambda x: DN(x) == dn4, + dn=dn4, fqdn=[fqdn4], description=[u'Test host 4'], l=[u'Undisclosed location 4'], @@ -374,7 +372,7 @@ class test_host(Declarative): ), ), result=dict( - dn=lambda x: DN(x) == dn3, + dn=dn3, fqdn=[fqdn3], description=[u'Test host 2'], l=[u'Undisclosed location 2'], @@ -391,7 +389,7 @@ class test_host(Declarative): value=fqdn3, summary=None, result=dict( - dn=lambda x: DN(x) == dn3, + dn=dn3, fqdn=[fqdn3], description=[u'Test host 2'], l=[u'Undisclosed location 2'], @@ -412,7 +410,7 @@ class test_host(Declarative): summary=u'1 host matched', result=[ dict( - dn=lambda x: DN(x) == dn3, + dn=dn3, fqdn=[fqdn3], description=[u'Test host 2'], l=[u'Undisclosed location 2'], @@ -451,7 +449,7 @@ class test_host(Declarative): ), ), result=dict( - dn=lambda x: DN(x) == dn3, + dn=dn3, fqdn=[fqdn3], description=[u'Test host 2'], l=[u'Undisclosed location 2'], @@ -491,8 +489,7 @@ class test_host(Declarative): usercertificate=[base64.b64decode(servercert)], valid_not_before=fuzzy_date, valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), + subject=DN(('CN',api.env.host),x509.subject_base()), serial_number=fuzzy_digits, serial_number_hex=fuzzy_hex, md5_fingerprint=fuzzy_hash, @@ -521,8 +518,7 @@ class test_host(Declarative): usercertificate=[base64.b64decode(servercert)], valid_not_before=fuzzy_date, valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), + subject=DN(('CN',api.env.host),x509.subject_base()), serial_number=fuzzy_digits, serial_number_hex=fuzzy_hex, md5_fingerprint=fuzzy_hash, @@ -591,7 +587,7 @@ class test_host(Declarative): value=fqdn1, summary=u'Added host "%s"' % fqdn1, result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -612,7 +608,7 @@ class test_host(Declarative): value=service1, summary=u'Added service "%s"' % service1, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], objectclass=objectclasses.service, managedby_host=[fqdn1], @@ -666,7 +662,7 @@ class test_host(Declarative): value=fqdn2, summary=u'Added host "%s"' % fqdn2, result=dict( - dn=lambda x: DN(x) == dn2, + dn=dn2, fqdn=[fqdn2], description=[u'Test host 2'], l=[u'Undisclosed location 2'], diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py index 5642b109..36c497ba 100644 --- a/tests/test_xmlrpc/test_hostgroup_plugin.py +++ b/tests/test_xmlrpc/test_hostgroup_plugin.py @@ -23,10 +23,9 @@ Test the `ipalib.plugins.hostgroup` module. """ from ipalib import api, errors -from ipalib.dn import * from tests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_uuid from tests.test_xmlrpc import objectclasses -from ipalib.dn import * +from ipapython.dn import DN hostgroup1 = u'testhostgroup1' dn1 = DN(('cn',hostgroup1),('cn','hostgroups'),('cn','accounts'), @@ -95,14 +94,13 @@ class test_hostgroup(Declarative): value=hostgroup1, summary=u'Added hostgroup "testhostgroup1"', result=dict( - dn=lambda x: DN(x) == dn1, + dn=dn1, cn=[hostgroup1], objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 1'], ipauniqueid=[fuzzy_uuid], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), - api.env.basedn)], + mepmanagedentry=[DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), + api.env.basedn)], ), ), ), @@ -131,7 +129,7 @@ class test_hostgroup(Declarative): value=fqdn1, summary=u'Added host "%s"' % fqdn1, result=dict( - dn=lambda x: DN(x) == host_dn1, + dn=host_dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -160,7 +158,7 @@ class test_hostgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], 'member_host': [fqdn1], @@ -176,7 +174,7 @@ class test_hostgroup(Declarative): value=hostgroup1, summary=None, result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'member_host': [u'testhost1.%s' % api.env.domain], 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], @@ -194,7 +192,7 @@ class test_hostgroup(Declarative): summary=u'1 hostgroup matched', result=[ { - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'member_host': [u'testhost1.%s' % api.env.domain], 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], @@ -228,7 +226,7 @@ class test_hostgroup(Declarative): value=hostgroup1, summary=None, result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'member_host': [u'testhost1.%s' % api.env.domain], 'cn': [hostgroup1], 'description': [u'Updated hostgroup 1'], @@ -251,7 +249,7 @@ class test_hostgroup(Declarative): ), completed=1, result={ - 'dn': lambda x: DN(x) == dn1, + 'dn': dn1, 'cn': [hostgroup1], 'description': [u'Updated hostgroup 1'], }, @@ -279,14 +277,13 @@ class test_hostgroup(Declarative): value=hostgroup_single, summary=u'Added hostgroup "a"', result=dict( - dn=lambda x: DN(x) == dn_single, + dn=dn_single, cn=[hostgroup_single], objectclass=objectclasses.hostgroup, description=[u'Test hostgroup with single letter in name'], ipauniqueid=[fuzzy_uuid], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',hostgroup_single),('cn','ng'),('cn','alt'), - api.env.basedn)], + mepmanagedentry=[DN(('cn',hostgroup_single),('cn','ng'),('cn','alt'), + api.env.basedn)], ), ), ), diff --git a/tests/test_xmlrpc/test_krbtpolicy.py b/tests/test_xmlrpc/test_krbtpolicy.py index 26ba87c4..fc2bf54c 100644 --- a/tests/test_xmlrpc/test_krbtpolicy.py +++ b/tests/test_xmlrpc/test_krbtpolicy.py @@ -23,7 +23,7 @@ Test kerberos ticket policy from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN user1 = u'tuser1' @@ -61,9 +61,8 @@ class test_krbtpolicy(Declarative): value=u'', summary=None, result=dict( - dn=lambda x: DN(x) == \ - DN(('cn',api.env.domain),('cn','kerberos'), - api.env.basedn), + dn=DN(('cn',api.env.domain),('cn','kerberos'), + api.env.basedn), krbmaxticketlife=[u'86400'], krbmaxrenewableage=[u'604800'], ), @@ -110,18 +109,14 @@ class test_krbtpolicy(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn) + dn=DN(('uid',user1),('cn','users'),('cn','accounts'), api.env.basedn) ), ), ), diff --git a/tests/test_xmlrpc/test_nesting.py b/tests/test_xmlrpc/test_nesting.py index a855960a..c28b7096 100644 --- a/tests/test_xmlrpc/test_nesting.py +++ b/tests/test_xmlrpc/test_nesting.py @@ -23,7 +23,7 @@ Test group nexting an indirect members from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN group1 = u'testgroup1' group2 = u'testgroup2' @@ -80,9 +80,8 @@ class test_nesting(Declarative): objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], gidnumber=[fuzzy_digits], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup1'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup1'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -104,9 +103,8 @@ class test_nesting(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup2'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup2'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -126,9 +124,8 @@ class test_nesting(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup3'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup3'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -148,9 +145,8 @@ class test_nesting(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup4'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup4'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -179,18 +175,15 @@ class test_nesting(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn) + dn=DN(('uid',user1),('cn','users'),('cn','accounts'), + api.env.basedn) ), ), ), @@ -219,18 +212,15 @@ class test_nesting(Declarative): cn=[u'Test User2'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user2),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user2),('cn','users'),('cn','accounts'), - api.env.basedn) + dn=DN(('uid',user2),('cn','users'),('cn','accounts'), + api.env.basedn) ), ), ), @@ -259,18 +249,15 @@ class test_nesting(Declarative): cn=[u'Test User3'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user3),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user3),('cn','users'),('cn','accounts'), - api.env.basedn) + dn=DN(('uid',user3),('cn','users'),('cn','accounts'), + api.env.basedn) ), ), ), @@ -299,18 +286,15 @@ class test_nesting(Declarative): cn=[u'Test User4'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user4),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user4),('cn','users'),('cn','accounts'), - api.env.basedn) + dn=DN(('uid',user4),('cn','users'),('cn','accounts'), + api.env.basedn) ), ), ), @@ -375,9 +359,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_group': (group2,), 'gidnumber': [fuzzy_digits], 'cn': [group1], @@ -401,9 +384,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_group': [group2, group3,], 'gidnumber': [fuzzy_digits], 'cn': [group1], @@ -427,9 +409,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group2),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group2),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': (u'tuser1',), 'memberof_group': (u'testgroup1',), 'gidnumber': [fuzzy_digits], @@ -454,9 +435,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group2),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group2),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': [user1, user2], 'memberof_group': [group1], 'gidnumber': [fuzzy_digits], @@ -481,9 +461,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group3),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group3),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': [user3], 'memberof_group': [group1], 'gidnumber': [fuzzy_digits], @@ -508,9 +487,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group3),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group3),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': [user3], 'memberof_group': [group1], 'member_group': [group4], @@ -536,9 +514,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group4),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group4),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': [user1], 'memberof_group': [group3], 'memberofindirect_group': [group1], @@ -564,9 +541,8 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group4),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group4),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': [user1, user4], 'memberof_group': [group3], 'memberofindirect_group': [group1], @@ -591,9 +567,8 @@ class test_nesting(Declarative): memberindirect_group = [group4], member_group = [group2, group3], memberindirect_user = [user1, user2, user3, user4], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup1'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup1'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -611,9 +586,8 @@ class test_nesting(Declarative): gidnumber= [fuzzy_digits], memberof_group = [group1], member_user = [user1, user2], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup2'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup2'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -633,9 +607,8 @@ class test_nesting(Declarative): member_user = [user3], member_group = [group4], memberindirect_user = [user1, user4], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup3'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup3'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -654,9 +627,8 @@ class test_nesting(Declarative): memberof_group = [group3], member_user = [user1, user4], memberofindirect_group = [group1], - dn=lambda x: DN(x) == \ - DN(('cn','testgroup4'),('cn','groups'), - ('cn','accounts'),api.env.basedn), + dn=DN(('cn','testgroup4'),('cn','groups'), + ('cn','accounts'),api.env.basedn), ), ), ), @@ -676,7 +648,7 @@ class test_nesting(Declarative): value=fqdn1, summary=u'Added host "%s"' % fqdn1, result=dict( - dn=lambda x: DN(x) == host_dn1, + dn=host_dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -700,14 +672,13 @@ class test_nesting(Declarative): value=hostgroup1, summary=u'Added hostgroup "testhostgroup1"', result=dict( - dn=lambda x: DN(x) == hgdn1, + dn=hgdn1, cn=[hostgroup1], objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 1'], ipauniqueid=[fuzzy_uuid], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), - api.env.basedn)], + mepmanagedentry=[DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), + api.env.basedn)], ), ), ), @@ -722,14 +693,13 @@ class test_nesting(Declarative): value=hostgroup2, summary=u'Added hostgroup "testhostgroup2"', result=dict( - dn=lambda x: DN(x) == hgdn2, + dn=hgdn2, cn=[hostgroup2], objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 2'], ipauniqueid=[fuzzy_uuid], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',hostgroup2),('cn','ng'),('cn','alt'), - api.env.basedn)], + mepmanagedentry=[DN(('cn',hostgroup2),('cn','ng'),('cn','alt'), + api.env.basedn)], ), ), ), @@ -749,7 +719,7 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == hgdn2, + 'dn': hgdn2, 'cn': [hostgroup2], 'description': [u'Test hostgroup 2'], 'member_host': [fqdn1], @@ -772,7 +742,7 @@ class test_nesting(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == hgdn1, + 'dn': hgdn1, 'cn': [hostgroup1], 'description': [u'Test hostgroup 1'], 'member_hostgroup': [hostgroup2], @@ -788,7 +758,7 @@ class test_nesting(Declarative): value=hostgroup1, summary=None, result={ - 'dn': lambda x: DN(x) == hgdn1, + 'dn': hgdn1, 'memberindirect_host': [u'testhost1.%s' % api.env.domain], 'member_hostgroup': [hostgroup2], 'cn': [hostgroup1], @@ -805,7 +775,7 @@ class test_nesting(Declarative): value=fqdn1, summary=None, result=dict( - dn=lambda x: DN(x) == host_dn1, + dn=host_dn1, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], diff --git a/tests/test_xmlrpc/test_netgroup_plugin.py b/tests/test_xmlrpc/test_netgroup_plugin.py index 951bc77a..b54291a6 100644 --- a/tests/test_xmlrpc/test_netgroup_plugin.py +++ b/tests/test_xmlrpc/test_netgroup_plugin.py @@ -28,7 +28,7 @@ from ipalib import errors from ipaserver.plugins.ldap2 import ldap2 from tests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_netgroupdn from tests.test_xmlrpc import objectclasses -from ipalib.dn import * +from ipapython.dn import DN # Global so we can save the value between tests netgroup_dn = None @@ -142,7 +142,6 @@ class test_netgroup(Declarative): value=netgroup1, summary=u'Added netgroup "%s"' % netgroup1, result=dict( -# dn=u'ipauniqueid=%s,cn=ng,cn=alt,%s' % (fuzzy_uuid, api.env.basedn), dn=fuzzy_netgroupdn, cn=[netgroup1], objectclass=objectclasses.netgroup, @@ -163,7 +162,6 @@ class test_netgroup(Declarative): value=netgroup2, summary=u'Added netgroup "%s"' % netgroup2, result=dict( -# dn=u'ipauniqueid=%s,cn=ng,cn=alt,%s' % (fuzzy_uuid, api.env.basedn), dn=fuzzy_netgroupdn, cn=[netgroup2], objectclass=objectclasses.netgroup, @@ -229,7 +227,7 @@ class test_netgroup(Declarative): value=host1, summary=u'Added host "%s"' % host1, result=dict( - dn=lambda x: DN(x) == host_dn1, + dn=host_dn1, fqdn=[host1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -253,13 +251,12 @@ class test_netgroup(Declarative): value=hostgroup1, summary=u'Added hostgroup "%s"' % hostgroup1, result=dict( - dn=lambda x: DN(x) == hostgroup_dn1, + dn=hostgroup_dn1, cn=[hostgroup1], objectclass=objectclasses.hostgroup, description=[u'Test hostgroup 1'], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), - api.env.basedn)], + mepmanagedentry=[DN(('cn',hostgroup1),('cn','ng'),('cn','alt'), + api.env.basedn)], ipauniqueid=[fuzzy_uuid], ), ), @@ -289,18 +286,15 @@ class test_netgroup(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid',user1),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -328,18 +322,15 @@ class test_netgroup(Declarative): cn=[u'Test User2'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user2),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user2),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid',user2),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -359,9 +350,8 @@ class test_netgroup(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + dn=DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -381,9 +371,8 @@ class test_netgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': (user2,), 'gidnumber': [fuzzy_digits], 'cn': [group1], diff --git a/tests/test_xmlrpc/test_permission_plugin.py b/tests/test_xmlrpc/test_permission_plugin.py index 8aaa4a99..a1062f08 100644 --- a/tests/test_xmlrpc/test_permission_plugin.py +++ b/tests/test_xmlrpc/test_permission_plugin.py @@ -25,7 +25,7 @@ Test the `ipalib/plugins/permission.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN permission1 = u'testperm' permission1_dn = DN(('cn',permission1), @@ -110,7 +110,7 @@ class test_permission(Declarative): value=permission1, summary=u'Added permission "%s"' % permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], objectclass=objectclasses.permission, type=u'user', @@ -141,7 +141,7 @@ class test_permission(Declarative): value=privilege1, summary=u'Added privilege "%s"' % privilege1, result=dict( - dn=lambda x: DN(x) == privilege1_dn, + dn=privilege1_dn, cn=[privilege1], description=[u'privilege desc. 1'], objectclass=objectclasses.privilege, @@ -163,7 +163,7 @@ class test_permission(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1], @@ -179,7 +179,7 @@ class test_permission(Declarative): value=permission1, summary=None, result={ - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -196,11 +196,12 @@ class test_permission(Declarative): value=permission1, summary=None, result={ - 'dn': unicode(permission1_dn), + 'dn': permission1_dn, 'cn': [permission1], - 'member': [unicode(privilege1_dn)], - 'aci': u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "permission:testperm";allow (write) groupdn = "ldap:///cn=testperm,cn=permissions,cn=pbac,%s";)' \ - % (api.env.basedn, api.env.basedn), + 'member': [privilege1_dn], + 'aci': u'(target = "ldap:///%s")(version 3.0;acl "permission:testperm";allow (write) groupdn = "ldap:///%s";)' % \ + (DN(('uid', '*'), ('cn', 'users'), ('cn', 'accounts'), api.env.basedn), + DN(('cn', 'testperm'), ('cn', 'permissions'), ('cn', 'pbac'), api.env.basedn)) }, ), ), @@ -215,7 +216,7 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -235,7 +236,7 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -267,7 +268,7 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -287,11 +288,12 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': unicode(permission1_dn), + 'dn': permission1_dn, 'cn': [permission1], - 'member': [unicode(privilege1_dn)], - 'aci': u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "permission:testperm";allow (write) groupdn = "ldap:///cn=testperm,cn=permissions,cn=pbac,%s";)' \ - % (api.env.basedn, api.env.basedn), + 'member': [privilege1_dn], + 'aci': u'(target = "ldap:///%s")(version 3.0;acl "permission:testperm";allow (write) groupdn = "ldap:///%s";)' % \ + (DN(('uid', '*'), ('cn', 'users'), ('cn', 'accounts'), api.env.basedn), + DN(('cn', 'testperm'), ('cn', 'permissions'), ('cn', 'pbac'), api.env.basedn)), }, ], ), @@ -312,7 +314,7 @@ class test_permission(Declarative): value=permission2, summary=u'Added permission "%s"' % permission2, result=dict( - dn=lambda x: DN(x) == permission2_dn, + dn=permission2_dn, cn=[permission2], objectclass=objectclasses.permission, type=u'user', @@ -332,14 +334,14 @@ class test_permission(Declarative): summary=u'2 permissions matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', 'permissions': [u'write'], }, { - 'dn': lambda x: DN(x) == permission2_dn, + 'dn': permission2_dn, 'cn': [permission2], 'type': u'user', 'permissions': [u'write'], @@ -358,11 +360,11 @@ class test_permission(Declarative): summary=u'2 permissions matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], }, { - 'dn': lambda x: DN(x) == permission2_dn, + 'dn': permission2_dn, 'cn': [permission2], }, ], @@ -380,8 +382,8 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': lambda x: DN(x) == DN(('cn','Modify Group Password Policy'), - api.env.container_permission,api.env.basedn), + 'dn': DN(('cn','Modify Group Password Policy'), + api.env.container_permission, api.env.basedn), 'cn': [u'Modify Group Password Policy'], }, ], @@ -398,7 +400,7 @@ class test_permission(Declarative): summary=u'1 privilege matched', result=[ { - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1], @@ -417,7 +419,7 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -437,14 +439,14 @@ class test_permission(Declarative): summary=u'2 permissions matched', result=[ { - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', 'permissions': [u'write'], }, { - 'dn': lambda x: DN(x) == permission2_dn, + 'dn': permission2_dn, 'cn': [permission2], 'type': u'user', 'permissions': [u'write'], @@ -468,14 +470,14 @@ class test_permission(Declarative): summary=u'1 permission matched', result=[ { - 'dn': lambda x: DN(x) == DN(('cn', 'Modify HBAC rule'), - api.env.container_permission,api.env.basedn), + 'dn': DN(('cn', 'Modify HBAC rule'), + api.env.container_permission, api.env.basedn), 'cn': [u'Modify HBAC rule'], 'member_privilege': [u'HBAC Administrator'], 'permissions' : [u'write'], 'attrs': [u'servicecategory', u'sourcehostcategory', u'cn', u'description', u'ipaenabledflag', u'accesstime', u'usercategory', u'hostcategory', u'accessruletype', u'sourcehost'], - 'subtree' : u'ldap:///ipauniqueid=*,cn=hbac,%s' % api.env.basedn, - 'memberindirect': [u'cn=hbac administrator,cn=privileges,cn=pbac,%s' % api.env.basedn, u'cn=it security specialist,cn=roles,cn=accounts,%s' % api.env.basedn], + 'subtree' : u'ldap:///%s' % DN(('ipauniqueid', '*'), ('cn', 'hbac'), api.env.basedn), + 'memberindirect': [DN(('cn', 'it security specialist'), ('cn', 'roles'), ('cn', 'accounts'), api.env.basedn)], }, ], ), @@ -496,7 +498,7 @@ class test_permission(Declarative): value=permission1, summary=u'Modified permission "%s"' % permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], member_privilege=[privilege1], type=u'user', @@ -515,7 +517,7 @@ class test_permission(Declarative): value=permission1, summary=None, result={ - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -556,7 +558,7 @@ class test_permission(Declarative): value=permission1, summary=None, result={ - 'dn': lambda x: DN(x) == permission1_dn, + 'dn': permission1_dn, 'cn': [permission1], 'member_privilege': [privilege1], 'type': u'user', @@ -578,7 +580,7 @@ class test_permission(Declarative): value=permission1, summary=u'Modified permission "%s"' % permission1, result={ - 'dn': lambda x: DN(x) == permission1_renamed_dn, + 'dn': permission1_renamed_dn, 'cn': [permission1_renamed], 'member_privilege': [privilege1], 'type': u'user', @@ -600,7 +602,7 @@ class test_permission(Declarative): value=permission1_renamed, summary=u'Modified permission "%s"' % permission1_renamed, result={ - 'dn': lambda x: DN(x) == permission1_renamed_ucase_dn, + 'dn': permission1_renamed_ucase_dn, 'cn': [permission1_renamed_ucase], 'member_privilege': [privilege1], 'type': u'user', @@ -614,16 +616,18 @@ class test_permission(Declarative): dict( desc='Change %r to a subtree type' % permission1_renamed_ucase, command=( - 'permission_mod', [permission1_renamed_ucase], dict(subtree=u'ldap:///cn=*,cn=test,cn=accounts,%s' % api.env.basedn, type=None) + 'permission_mod', [permission1_renamed_ucase], + dict(subtree=u'ldap:///%s' % DN(('cn', '*'), ('cn', 'test'), ('cn', 'accounts'), api.env.basedn), + type=None) ), expected=dict( value=permission1_renamed_ucase, summary=u'Modified permission "%s"' % permission1_renamed_ucase, result=dict( - dn=lambda x: DN(x) == permission1_renamed_ucase_dn, + dn=permission1_renamed_ucase_dn, cn=[permission1_renamed_ucase], member_privilege=[privilege1], - subtree=u'ldap:///cn=*,cn=test,cn=accounts,%s' % api.env.basedn, + subtree=u'ldap:///%s' % DN(('cn', '*'), ('cn', 'test'), ('cn', 'accounts'), api.env.basedn), permissions=[u'write'], memberof=u'ipausers', ), @@ -633,17 +637,18 @@ class test_permission(Declarative): dict( desc='Search for %r using --subtree' % permission1, - command=('permission_find', [], {'subtree': 'ldap:///cn=*,cn=test,cn=accounts,%s' % api.env.basedn}), + command=('permission_find', [], + {'subtree': u'ldap:///%s' % DN(('cn', '*'), ('cn', 'test'), ('cn', 'accounts'), api.env.basedn)}), expected=dict( count=1, truncated=False, summary=u'1 permission matched', result=[ { - 'dn':lambda x: DN(x) == permission1_renamed_ucase_dn, + 'dn':permission1_renamed_ucase_dn, 'cn':[permission1_renamed_ucase], 'member_privilege':[privilege1], - 'subtree':u'ldap:///cn=*,cn=test,cn=accounts,%s' % api.env.basedn, + 'subtree':u'ldap:///%s' % DN(('cn', '*'), ('cn', 'test'), ('cn', 'accounts'), api.env.basedn), 'permissions':[u'write'], 'memberof':u'ipausers', }, @@ -756,7 +761,7 @@ class test_permission(Declarative): value=permission1, summary=u'Added permission "%s"' % permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], objectclass=objectclasses.permission, memberof=u'editors', @@ -784,7 +789,7 @@ class test_permission(Declarative): value=permission1, summary=u'Modified permission "%s"' % permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], memberof=u'admins', permissions=[u'write'], @@ -804,7 +809,7 @@ class test_permission(Declarative): summary=u'Modified permission "%s"' % permission1, value=permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], permissions=[u'write'], type=u'user', @@ -836,7 +841,7 @@ class test_permission(Declarative): value=permission1, summary=u'Added permission "%s"' % permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], objectclass=objectclasses.permission, targetgroup=u'editors', diff --git a/tests/test_xmlrpc/test_privilege_plugin.py b/tests/test_xmlrpc/test_privilege_plugin.py index d8d9b22a..d4784af8 100644 --- a/tests/test_xmlrpc/test_privilege_plugin.py +++ b/tests/test_xmlrpc/test_privilege_plugin.py @@ -24,7 +24,7 @@ Test the `ipalib/plugins/privilege.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN permission1 = u'testperm' permission1_dn = DN(('cn',permission1), @@ -97,7 +97,7 @@ class test_privilege(Declarative): value=permission1, summary=u'Added permission "%s"' % permission1, result=dict( - dn=lambda x: DN(x) == permission1_dn, + dn=permission1_dn, cn=[permission1], objectclass=objectclasses.permission, type=u'user', @@ -116,7 +116,7 @@ class test_privilege(Declarative): value=privilege1, summary=u'Added privilege "%s"' % privilege1, result=dict( - dn=lambda x: DN(x) == privilege1_dn, + dn=privilege1_dn, cn=[privilege1], description=[u'privilege desc. 1'], objectclass=objectclasses.privilege, @@ -138,7 +138,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1], @@ -154,7 +154,7 @@ class test_privilege(Declarative): value=privilege1, summary=None, result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1], @@ -172,7 +172,7 @@ class test_privilege(Declarative): summary=u'1 privilege matched', result=[ { - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1], @@ -191,7 +191,7 @@ class test_privilege(Declarative): summary=u'1 privilege matched', result=[ { - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1], @@ -213,7 +213,7 @@ class test_privilege(Declarative): value=permission2, summary=u'Added permission "%s"' % permission2, result=dict( - dn=lambda x: DN(x) == permission2_dn, + dn=permission2_dn, cn=[permission2], objectclass=objectclasses.permission, type=u'user', @@ -236,7 +236,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1, permission2], @@ -258,7 +258,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1, permission2], @@ -276,7 +276,7 @@ class test_privilege(Declarative): summary=u'1 privilege matched', result=[ { - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'privilege desc. 1'], 'memberof_permission': [permission1, permission2], @@ -316,7 +316,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'New desc 1'], 'memberof_permission': [permission2], @@ -338,7 +338,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'New desc 1'], 'memberof_permission': [permission2], @@ -360,7 +360,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'New desc 1'], 'memberof_permission': [permission2], @@ -382,7 +382,7 @@ class test_privilege(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == privilege1_dn, + 'dn': privilege1_dn, 'cn': [privilege1], 'description': [u'New desc 1'], 'memberof_permission': [permission2], diff --git a/tests/test_xmlrpc/test_range_plugin.py b/tests/test_xmlrpc/test_range_plugin.py index 76ffc58b..ea4bc2b2 100644 --- a/tests/test_xmlrpc/test_range_plugin.py +++ b/tests/test_xmlrpc/test_range_plugin.py @@ -24,7 +24,7 @@ Test the `ipalib/plugins/range.py` module, and XML-RPC in general. from ipalib import api, errors, _ from tests.util import assert_equal, Fuzzy from xmlrpc_test import Declarative -from ipalib.dn import * +from ipapython.dn import * testrange1 = u't-range-1' @@ -41,9 +41,8 @@ class test_range(Declarative): ipabaserid=1000, ipasecondarybaserid=20000)), expected=dict( result=dict( - dn=lambda x: DN(x) == \ - DN(('cn',testrange1),('cn','ranges'),('cn','etc'), - api.env.basedn), + dn=DN(('cn',testrange1),('cn','ranges'),('cn','etc'), + api.env.basedn), cn=[testrange1], objectclass=[u'ipaIDrange', u'ipadomainidrange'], ipabaseid=[u'900000'], @@ -62,9 +61,8 @@ class test_range(Declarative): command=('range_show', [testrange1], dict()), expected=dict( result=dict( - dn=lambda x: DN(x) == \ - DN(('cn',testrange1),('cn','ranges'),('cn','etc'), - api.env.basedn), + dn=DN(('cn',testrange1),('cn','ranges'),('cn','etc'), + api.env.basedn), cn=[testrange1], ipabaseid=[u'900000'], ipabaserid=[u'1000'], diff --git a/tests/test_xmlrpc/test_replace.py b/tests/test_xmlrpc/test_replace.py index f5203607..434f71d7 100644 --- a/tests/test_xmlrpc/test_replace.py +++ b/tests/test_xmlrpc/test_replace.py @@ -28,7 +28,7 @@ gen_modlist code. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN user1=u'tuser1' @@ -66,18 +66,15 @@ class test_replace(Declarative): initials=[u'TU'], mail=[u'test1@example.com', u'test2@example.com'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm),('cn','kerberos'), - api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), diff --git a/tests/test_xmlrpc/test_role_plugin.py b/tests/test_xmlrpc/test_role_plugin.py index e2bd28cd..b847ca9e 100644 --- a/tests/test_xmlrpc/test_role_plugin.py +++ b/tests/test_xmlrpc/test_role_plugin.py @@ -25,7 +25,7 @@ Test the `ipalib/plugins/role.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN search = u'test-role' @@ -117,7 +117,7 @@ class test_role(Declarative): value=role1, summary=u'Added role "%s"' % role1, result=dict( - dn=lambda x: DN(x) == role1_dn, + dn=role1_dn, cn=[role1], description=[u'role desc 1'], objectclass=objectclasses.role, @@ -133,7 +133,7 @@ class test_role(Declarative): value=role1, summary=None, result=dict( - dn=lambda x: DN(x) == role1_dn, + dn=role1_dn, cn=[role1], description=[u'role desc 1'], ), @@ -151,7 +151,7 @@ class test_role(Declarative): value=group1, summary=u'Added group "testgroup1"', result=dict( - dn=lambda x: DN(x) == group1_dn, + dn=group1_dn, cn=[group1], description=[u'group desc 1'], objectclass=objectclasses.group, @@ -170,7 +170,7 @@ class test_role(Declarative): value=privilege1, summary=u'Added privilege "%s"' % privilege1, result=dict( - dn=lambda x: DN(x) == privilege1_dn, + dn=privilege1_dn, cn=[privilege1], description=[u'privilege desc. 1'], objectclass=objectclasses.privilege, @@ -192,7 +192,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'memberof_privilege': [privilege1], @@ -213,7 +213,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'memberof_privilege': [privilege1], @@ -234,7 +234,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'memberof_privilege': [privilege1], @@ -257,7 +257,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'member_group': [group1], @@ -274,7 +274,7 @@ class test_role(Declarative): value=role1, summary=None, result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'member_group': [group1], @@ -293,7 +293,7 @@ class test_role(Declarative): summary=u'1 role matched', result=[ { - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'member_group': [group1], @@ -313,7 +313,7 @@ class test_role(Declarative): summary=u'1 role matched', result=[ { - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'member_group': [group1], @@ -333,7 +333,7 @@ class test_role(Declarative): value=role2, summary=u'Added role "%s"' % role2, result=dict( - dn=lambda x: DN(x) == role2_dn, + dn=role2_dn, cn=[role2], description=[u'role desc 2'], objectclass=objectclasses.role, @@ -351,7 +351,7 @@ class test_role(Declarative): summary=u'1 role matched', result=[ { - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'member_group': [group1], @@ -371,14 +371,14 @@ class test_role(Declarative): summary=u'2 roles matched', result=[ { - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'role desc 1'], 'member_group': [group1], 'memberof_privilege': [privilege1], }, { - 'dn': lambda x: DN(x) == role2_dn, + 'dn': role2_dn, 'cn': [role2], 'description': [u'role desc 2'], }, @@ -412,7 +412,7 @@ class test_role(Declarative): value=role1, summary=None, result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'New desc 1'], 'member_group': [group1], @@ -436,7 +436,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'New desc 1'], 'memberof_privilege': [privilege1], @@ -452,7 +452,7 @@ class test_role(Declarative): value=role1, summary=None, result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'New desc 1'], 'memberof_privilege': [privilege1], @@ -515,7 +515,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'New desc 1'], } @@ -536,7 +536,7 @@ class test_role(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == role1_dn, + 'dn': role1_dn, 'cn': [role1], 'description': [u'New desc 1'], } @@ -586,7 +586,7 @@ class test_role(Declarative): summary=u'1 role matched', result=[ { - 'dn': lambda x: DN(x) == role2_dn, + 'dn': role2_dn, 'cn': [role2], 'description': [u'role desc 2'], }, diff --git a/tests/test_xmlrpc/test_selinuxusermap_plugin.py b/tests/test_xmlrpc/test_selinuxusermap_plugin.py index 2f6f52c6..c1bee54d 100644 --- a/tests/test_xmlrpc/test_selinuxusermap_plugin.py +++ b/tests/test_xmlrpc/test_selinuxusermap_plugin.py @@ -23,7 +23,7 @@ Test the `ipalib/plugins/selinuxusermap.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN from tests.util import Fuzzy rule1 = u'selinuxrule1' @@ -34,15 +34,16 @@ user1 = u'tuser1' group1 = u'testgroup1' host1 = u'testhost1.%s' % api.env.domain hostdn1 = DN(('fqdn',host1),('cn','computers'),('cn','accounts'), - api.env.basedn) + api.env.basedn) hbacrule1 = u'testhbacrule1' hbacrule2 = u'testhbacrule12' +# Note (?i) at the beginning of the regexp is the ingnore case flag fuzzy_selinuxusermapdn = Fuzzy( - 'ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},%s,%s' % (api.env.container_selinux, api.env.basedn) + '(?i)ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},%s,%s' % (api.env.container_selinux, api.env.basedn) ) fuzzy_hbacruledn = Fuzzy( - 'ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},%s,%s' % (api.env.container_hbac, api.env.basedn) + '(?i)ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},%s,%s' % (api.env.container_hbac, api.env.basedn) ) class test_selinuxusermap(Declarative): @@ -204,16 +205,13 @@ class test_selinuxusermap(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid',user1),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid',user1),('cn','users'),('cn','accounts'), + api.env.basedn), has_keytab=False, has_password=False, ), @@ -234,9 +232,8 @@ class test_selinuxusermap(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + dn=DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -256,9 +253,8 @@ class test_selinuxusermap(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + 'dn': DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), 'member_user': (user1,), 'gidnumber': [fuzzy_digits], 'cn': [group1], @@ -281,7 +277,7 @@ class test_selinuxusermap(Declarative): value=host1, summary=u'Added host "%s"' % host1, result=dict( - dn=lambda x: DN(x) == hostdn1, + dn=hostdn1, fqdn=[host1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], diff --git a/tests/test_xmlrpc/test_service_plugin.py b/tests/test_xmlrpc/test_service_plugin.py index 28c6bb66..e06132fe 100644 --- a/tests/test_xmlrpc/test_service_plugin.py +++ b/tests/test_xmlrpc/test_service_plugin.py @@ -27,7 +27,7 @@ from tests.test_xmlrpc.xmlrpc_test import fuzzy_digits, fuzzy_date, fuzzy_issuer from tests.test_xmlrpc.xmlrpc_test import fuzzy_hex from tests.test_xmlrpc import objectclasses import base64 -from ipalib.dn import * +from ipapython.dn import DN fqdn1 = u'testhost1.%s' % api.env.domain fqdn2 = u'testhost2.%s' % api.env.domain @@ -93,7 +93,7 @@ class test_service(Declarative): value=fqdn1, summary=u'Added host "%s"' % fqdn1, result=dict( - dn=lambda x: DN(x) == host1dn, + dn=host1dn, fqdn=[fqdn1], description=[u'Test host 1'], l=[u'Undisclosed location 1'], @@ -121,7 +121,7 @@ class test_service(Declarative): value=fqdn2, summary=u'Added host "%s"' % fqdn2, result=dict( - dn=lambda x: DN(x) == host2dn, + dn=host2dn, fqdn=[fqdn2], description=[u'Test host 2'], l=[u'Undisclosed location 2'], @@ -149,7 +149,7 @@ class test_service(Declarative): value=fqdn3.lower(), summary=u'Added host "%s"' % fqdn3.lower(), result=dict( - dn=lambda x: DN(x) == host3dn, + dn=host3dn, fqdn=[fqdn3.lower()], description=[u'Test host 3'], l=[u'Undisclosed location 3'], @@ -175,7 +175,7 @@ class test_service(Declarative): value=service1, summary=u'Added service "%s"' % service1, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], objectclass=objectclasses.service, ipauniqueid=[fuzzy_uuid], @@ -205,7 +205,7 @@ class test_service(Declarative): value=service1, summary=None, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], has_keytab=False, ipakrbauthzdata=[u'MS-PAC'], @@ -222,7 +222,7 @@ class test_service(Declarative): value=service1, summary=None, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbprincipalalias=[service1], objectclass=objectclasses.service, @@ -244,7 +244,7 @@ class test_service(Declarative): summary=u'1 service matched', result=[ dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], managedby_host=[fqdn1], ipakrbauthzdata=[u'MS-PAC'], @@ -264,7 +264,7 @@ class test_service(Declarative): summary=u'1 service matched', result=[ dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbprincipalalias=[service1], objectclass=objectclasses.service, @@ -285,7 +285,7 @@ class test_service(Declarative): failed=dict(managedby=dict(host=[(u'notfound', u'no such entry')])), completed=0, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbauthzdata=[u'MS-PAC'], managedby_host=[fqdn1], @@ -301,7 +301,7 @@ class test_service(Declarative): failed=dict(managedby=dict(host=[(u'notfound', u'This entry is not a member')])), completed=0, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbauthzdata=[u'MS-PAC'], managedby_host=[fqdn1], @@ -317,7 +317,7 @@ class test_service(Declarative): failed=dict(managedby=dict(host=[])), completed=1, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbauthzdata=[u'MS-PAC'], managedby_host=[fqdn1, fqdn2], @@ -333,7 +333,7 @@ class test_service(Declarative): failed=dict(managedby=dict(host=[])), completed=1, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbauthzdata=[u'MS-PAC'], managedby_host=[fqdn1], @@ -349,7 +349,7 @@ class test_service(Declarative): failed=dict(managedby=dict(host=[])), completed=1, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbauthzdata=[u'MS-PAC'], managedby_host=[fqdn1, fqdn3.lower()], @@ -365,7 +365,7 @@ class test_service(Declarative): failed=dict(managedby=dict(host=[])), completed=1, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, krbprincipalname=[service1], ipakrbauthzdata=[u'MS-PAC'], managedby_host=[fqdn1], @@ -396,8 +396,7 @@ class test_service(Declarative): managedby_host=[fqdn1], valid_not_before=fuzzy_date, valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), + subject=DN(('CN',api.env.host),x509.subject_base()), serial_number=fuzzy_digits, serial_number_hex=fuzzy_hex, md5_fingerprint=fuzzy_hash, @@ -415,7 +414,7 @@ class test_service(Declarative): value=service1, summary=None, result=dict( - dn=lambda x: DN(x) == service1dn, + dn=service1dn, usercertificate=[base64.b64decode(servercert)], krbprincipalname=[service1], has_keytab=False, @@ -425,8 +424,7 @@ class test_service(Declarative): # test case. valid_not_before=fuzzy_date, valid_not_after=fuzzy_date, - subject=lambda x: DN(x) == \ - DN(('CN',api.env.host),x509.subject_base()), + subject=DN(('CN',api.env.host),x509.subject_base()), serial_number=fuzzy_digits, serial_number_hex=fuzzy_hex, md5_fingerprint=fuzzy_hash, diff --git a/tests/test_xmlrpc/test_sudocmd_plugin.py b/tests/test_xmlrpc/test_sudocmd_plugin.py index 4574f774..75b6bbcc 100644 --- a/tests/test_xmlrpc/test_sudocmd_plugin.py +++ b/tests/test_xmlrpc/test_sudocmd_plugin.py @@ -24,7 +24,7 @@ Test the `ipalib/plugins/sudocmd.py` module. from ipalib import api, errors from tests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_uuid from tests.test_xmlrpc import objectclasses -from ipalib.dn import * +from ipapython.dn import DN sudocmd1 = u'/usr/bin/sudotestcmd1' @@ -72,9 +72,8 @@ class test_sudocmd(Declarative): value=sudocmd1, summary=u'Added Sudo Command "%s"' % sudocmd1, result=dict( - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], objectclass=objectclasses.sudocmd, @@ -103,9 +102,8 @@ class test_sudocmd(Declarative): value=sudocmd1, summary=None, result=dict( - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], ), @@ -122,9 +120,8 @@ class test_sudocmd(Declarative): summary=u'1 Sudo Command matched', result=[ dict( - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'), - ('cn','sudo'),api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'), + ('cn','sudo'),api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], ), @@ -155,9 +152,8 @@ class test_sudocmd(Declarative): value=sudocmd1, summary=None, result=dict( - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Updated sudo command 1'], ), diff --git a/tests/test_xmlrpc/test_sudocmdgroup_plugin.py b/tests/test_xmlrpc/test_sudocmdgroup_plugin.py index 2bfbb625..b8c15737 100644 --- a/tests/test_xmlrpc/test_sudocmdgroup_plugin.py +++ b/tests/test_xmlrpc/test_sudocmdgroup_plugin.py @@ -23,7 +23,7 @@ Test the `ipalib/plugins/sudocmdgroup.py` module. from ipalib import api, errors from tests.test_xmlrpc import objectclasses from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid -from ipalib.dn import * +from ipapython.dn import DN sudocmdgroup1 = u'testsudocmdgroup1' sudocmdgroup2 = u'testsudocmdgroup2' @@ -45,9 +45,8 @@ def create_command(sudocmd): sudocmd=[sudocmd], ipauniqueid=[fuzzy_uuid], description=[u'Test sudo command'], - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), ), ), ) @@ -77,9 +76,8 @@ class test_sudocmdgroup(Declarative): sudocmd=[u'/usr/bin/sudotestcmd1'], ipauniqueid=[fuzzy_uuid], description=[u'Test sudo command 1'], - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), ), ), ), @@ -94,9 +92,8 @@ class test_sudocmdgroup(Declarative): result=dict( sudocmd=[sudocmd1], description=[u'Test sudo command 1'], - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), ), ), ), @@ -143,9 +140,8 @@ class test_sudocmdgroup(Declarative): description=[u'Test desc 1'], objectclass=objectclasses.sudocmdgroup, ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn','testsudocmdgroup1'),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn','testsudocmdgroup1'),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), ), ), ), @@ -171,9 +167,8 @@ class test_sudocmdgroup(Declarative): result=dict( cn=[sudocmdgroup1], description=[u'Test desc 1'], - dn=lambda x: DN(x) == \ - DN(('cn','testsudocmdgroup1'),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn','testsudocmdgroup1'),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), ), ), ), @@ -204,9 +199,8 @@ class test_sudocmdgroup(Declarative): result=dict( cn=[sudocmdgroup1], description=[u'New desc 1'], - dn=lambda x: DN(x) == \ - DN(('cn','testsudocmdgroup1'),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn','testsudocmdgroup1'),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), ), summary=None, ), @@ -221,9 +215,8 @@ class test_sudocmdgroup(Declarative): truncated=False, result=[ dict( - dn=lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), cn=[sudocmdgroup1], description=[u'New desc 1'], ), @@ -275,9 +268,8 @@ class test_sudocmdgroup(Declarative): description=[u'Test desc 2'], objectclass=objectclasses.sudocmdgroup, ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn','testsudocmdgroup2'),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn','testsudocmdgroup2'),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), ), ), ), @@ -304,9 +296,8 @@ class test_sudocmdgroup(Declarative): result=dict( cn=[sudocmdgroup2], description=[u'Test desc 2'], - dn=lambda x: DN(x) == \ - DN(('cn','testsudocmdgroup2'),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn','testsudocmdgroup2'),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), ), ), ), @@ -337,9 +328,8 @@ class test_sudocmdgroup(Declarative): result=dict( cn=[sudocmdgroup2], description=[u'New desc 2'], - dn=lambda x: DN(x) == \ - DN(('cn','testsudocmdgroup2'),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn','testsudocmdgroup2'),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), ), summary=None, ), @@ -354,9 +344,8 @@ class test_sudocmdgroup(Declarative): truncated=False, result=[ dict( - dn=lambda x: DN(x) == \ - DN(('cn',sudocmdgroup2),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn',sudocmdgroup2),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), cn=[sudocmdgroup2], description=[u'New desc 2'], ), @@ -375,16 +364,14 @@ class test_sudocmdgroup(Declarative): truncated=False, result=[ dict( - dn=lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), cn=[sudocmdgroup1], description=[u'New desc 1'], ), dict( - dn=lambda x: DN(x) == \ - DN(('cn',sudocmdgroup2),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + dn=DN(('cn',sudocmdgroup2),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), cn=[sudocmdgroup2], description=[u'New desc 2'], ), @@ -410,9 +397,8 @@ class test_sudocmdgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + 'dn': DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), 'member_sudocmd': (sudocmd1,), 'cn': [sudocmdgroup1], 'description': [u'New desc 1'], @@ -427,9 +413,8 @@ class test_sudocmdgroup(Declarative): value=sudocmd1, summary=None, result=dict( - dn=lambda x: DN(x) == \ - DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), - api.env.basedn), + dn=DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], memberof_sudocmdgroup = [u'testsudocmdgroup1'], @@ -451,9 +436,8 @@ class test_sudocmdgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + 'dn': DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), 'member_sudocmd': (u'/usr/bin/sudotestcmd1',), 'cn': [sudocmdgroup1], 'description': [u'New desc 1'], @@ -474,9 +458,8 @@ class test_sudocmdgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + 'dn': DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), 'cn': [sudocmdgroup1], 'description': [u'New desc 1'], }, @@ -497,9 +480,8 @@ class test_sudocmdgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + 'dn': DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), 'cn': [sudocmdgroup1], 'description': [u'New desc 1'], }, @@ -523,9 +505,8 @@ class test_sudocmdgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + 'dn': DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), 'member_sudocmd': (sudocmd_plus,), 'cn': [sudocmdgroup1], 'description': [u'New desc 1'], @@ -546,9 +527,8 @@ class test_sudocmdgroup(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), - ('cn','sudo'),api.env.basedn), + 'dn': DN(('cn',sudocmdgroup1),('cn','sudocmdgroups'), + ('cn','sudo'),api.env.basedn), 'cn': [sudocmdgroup1], 'description': [u'New desc 1'], }, diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py index b257a90a..4a4c69c1 100644 --- a/tests/test_xmlrpc/test_user_plugin.py +++ b/tests/test_xmlrpc/test_user_plugin.py @@ -27,7 +27,7 @@ from ipalib import api, errors from tests.test_xmlrpc import objectclasses from tests.util import assert_equal, assert_not_equal from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid, fuzzy_password, fuzzy_string, fuzzy_dergeneralizedtime -from ipalib.dn import * +from ipapython.dn import DN user1=u'tuser1' user2=u'tuser2' @@ -52,7 +52,7 @@ def not_upg_check(response): class test_user(Declarative): cleanup_commands = [ - ('user_del', [user1, user2], {}), + ('user_del', [user1, user2, renameduser1], {}), ('group_del', [group1], {}), ] @@ -81,7 +81,7 @@ class test_user(Declarative): dict( desc='Try to rename non-existent %r' % user1, - command=('user_mod', [user1], dict(setattr=u'uid=tuser')), + command=('user_mod', [user1], dict(setattr=u'uid=%s' % renameduser1)), expected=errors.NotFound(reason=u'%s: user not found' % user1), ), @@ -109,18 +109,15 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), extra_check = upg_check, @@ -144,9 +141,8 @@ class test_user(Declarative): ), expected=dict( result=dict( - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), givenname=[u'Test'], homedirectory=[u'/home/tuser1'], loginshell=[u'/bin/sh'], @@ -173,9 +169,8 @@ class test_user(Declarative): expected=dict( result=[ { - 'dn': lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'), - ('cn','accounts'),api.env.basedn), + 'dn': DN(('uid','tuser1'),('cn','users'), + ('cn','accounts'),api.env.basedn), 'cn': [u'Test User1'], 'gecos': [u'Test User1'], 'givenname': [u'Test'], @@ -189,12 +184,10 @@ class test_user(Declarative): 'uidnumber': [fuzzy_digits], 'gidnumber': [fuzzy_digits], 'ipauniqueid': [fuzzy_uuid], - 'mepmanagedentry': lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], - 'krbpwdpolicyreference': lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], + 'mepmanagedentry': [DN(('cn',user1),('cn','groups'),('cn','accounts'), + api.env.basedn)], + 'krbpwdpolicyreference': [DN(('cn','global_policy'),('cn',api.env.realm), + ('cn','kerberos'),api.env.basedn)], 'nsaccountlock': False, 'has_keytab': False, 'has_password': False, @@ -217,9 +210,8 @@ class test_user(Declarative): expected=dict( result=[ { - 'dn':lambda x: DN(x) == \ - DN(('uid',user1),('cn','users'), - ('cn','accounts'),api.env.basedn), + 'dn':DN(('uid',user1),('cn','users'), + ('cn','accounts'),api.env.basedn), 'uid': [user1], }, ], @@ -237,9 +229,8 @@ class test_user(Declarative): expected=dict( result=[ dict( - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'), - ('cn','accounts'),api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'), + ('cn','accounts'),api.env.basedn), givenname=[u'Test'], homedirectory=[u'/home/tuser1'], loginshell=[u'/bin/sh'], @@ -267,9 +258,8 @@ class test_user(Declarative): expected=dict( result=[ dict( - dn=lambda x: DN(x) == \ - DN(('uid','admin'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','admin'),('cn','users'),('cn','accounts'), + api.env.basedn), homedirectory=[u'/home/admin'], loginshell=[u'/bin/bash'], sn=[u'Administrator'], @@ -281,9 +271,8 @@ class test_user(Declarative): gidnumber=[fuzzy_digits], ), dict( - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'), - ('cn','accounts'),api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'), + ('cn','accounts'),api.env.basedn), givenname=[u'Test'], homedirectory=[u'/home/tuser1'], loginshell=[u'/bin/sh'], @@ -311,9 +300,8 @@ class test_user(Declarative): expected=dict( result=[ dict( - dn=lambda x: DN(x) == \ - DN(('uid','admin'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','admin'),('cn','users'),('cn','accounts'), + api.env.basedn), homedirectory=[u'/home/admin'], loginshell=[u'/bin/bash'], sn=[u'Administrator'], @@ -465,9 +453,8 @@ class test_user(Declarative): command=('user_show', [user1], {}), expected=dict( result=dict( - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), givenname=[u'Finkle'], homedirectory=[u'/home/tuser1'], loginshell=[u'/bin/sh'], @@ -591,18 +578,15 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), extra_check = upg_check, @@ -632,18 +616,15 @@ class test_user(Declarative): cn=[u'Test User2'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user2),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser2'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser2'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), extra_check = upg_check, @@ -783,9 +764,8 @@ class test_user(Declarative): gidnumber=[fuzzy_digits], objectclass=objectclasses.group + [u'posixgroup'], ipauniqueid=[fuzzy_uuid], - dn=lambda x: DN(x) == \ - DN(('cn',group1),('cn','groups'),('cn','accounts'), - api.env.basedn), + dn=DN(('cn',group1),('cn','groups'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -830,18 +810,15 @@ class test_user(Declarative): postalcode=[u'01234-5678'], telephonenumber=[u'410-555-1212'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -880,12 +857,10 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=True, has_password=True, @@ -893,9 +868,8 @@ class test_user(Declarative): krbextradata=[fuzzy_string], krbpasswordexpiration=[fuzzy_dergeneralizedtime], krblastpwdchange=[fuzzy_dergeneralizedtime], - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -933,18 +907,15 @@ class test_user(Declarative): cn=[u'Test User2'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user2),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser2'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser2'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -1008,18 +979,15 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -1085,18 +1053,15 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -1151,18 +1116,15 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], - mepmanagedentry=lambda x: [DN(i) for i in x] == \ - [DN(('cn',user1),('cn','groups'),('cn','accounts'), - api.env.basedn)], + 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=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -1217,15 +1179,13 @@ class test_user(Declarative): cn=[u'Test User2'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),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, - dn=lambda x: DN(x) == \ - DN(('uid','tuser2'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser2'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -1272,15 +1232,13 @@ class test_user(Declarative): cn=[u'Test User1'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], + krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), + ('cn','kerberos'),api.env.basedn)], memberof_group=[group1], has_keytab=False, has_password=False, - dn=lambda x: DN(x) == \ - DN(('uid','tuser1'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser1'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), extra_check = not_upg_check, @@ -1310,15 +1268,13 @@ class test_user(Declarative): cn=[u'Test User2'], initials=[u'TU'], ipauniqueid=[fuzzy_uuid], - krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \ - [DN(('cn','global_policy'),('cn',api.env.realm), - ('cn','kerberos'),api.env.basedn)], + krbpwdpolicyreference=[DN(('cn','global_policy'),('cn',api.env.realm), + ('cn','kerberos'),api.env.basedn)], memberof_group=[group1], has_keytab=False, has_password=False, - dn=lambda x: DN(x) == \ - DN(('uid','tuser2'),('cn','users'),('cn','accounts'), - api.env.basedn), + dn=DN(('uid','tuser2'),('cn','users'),('cn','accounts'), + api.env.basedn), ), ), ), @@ -1350,9 +1306,8 @@ class test_user(Declarative): ), ), result={ - 'dn': lambda x: DN(x) == \ - DN(('cn', 'admins'), ('cn', 'groups'), - ('cn', 'accounts'), api.env.basedn), + 'dn': DN(('cn', 'admins'), ('cn', 'groups'), + ('cn', 'accounts'), api.env.basedn), 'member_user': [u'admin', user2], 'gidnumber': [fuzzy_digits], 'cn': [u'admins'], diff --git a/tests/test_xmlrpc/xmlrpc_test.py b/tests/test_xmlrpc/xmlrpc_test.py index cfba35fc..7c32be0d 100644 --- a/tests/test_xmlrpc/xmlrpc_test.py +++ b/tests/test_xmlrpc/xmlrpc_test.py @@ -40,9 +40,9 @@ fuzzy_uuid = Fuzzy( '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' ) -# Matches netgroup dn +# Matches netgroup dn. Note (?i) at the beginning of the regexp is the ingnore case flag fuzzy_netgroupdn = Fuzzy( - 'ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},cn=ng,cn=alt,%s' % api.env.basedn + '(?i)ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},cn=ng,cn=alt,%s' % api.env.basedn ) # Matches a hash signature, not enforcing length |