mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fixed some of the test_xmlrpc unit tests
This commit is contained in:
parent
5717c9d668
commit
0211c76cd0
@ -605,15 +605,15 @@ class NotFound(ExecutionError):
|
||||
|
||||
For example:
|
||||
|
||||
>>> raise NotFound(msg='Entry not found')
|
||||
>>> raise NotFound()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
NotFound: Entry not found
|
||||
NotFound: entry not found
|
||||
|
||||
"""
|
||||
|
||||
errno = 4001
|
||||
format = _('%(msg)s')
|
||||
format = _('entry not found')
|
||||
|
||||
class DuplicateEntry(ExecutionError):
|
||||
"""
|
||||
|
@ -26,7 +26,7 @@ This wraps the python-ldap bindings.
|
||||
|
||||
import ldap as _ldap
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import errors2
|
||||
from ipalib.crud import CrudBackend
|
||||
from ipaserver import servercore, ipaldap
|
||||
import krbV
|
||||
|
@ -270,7 +270,7 @@ def search(base, filter, attributes, timelimit=1, sizelimit=3000):
|
||||
results = context.ldap.conn.getListAsync(base, ldap.SCOPE_SUBTREE,
|
||||
filter, attributes, 0, None, None, timelimit, sizelimit)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
raise errors2.NotFound
|
||||
raise errors2.NotFound()
|
||||
|
||||
counter = results[0]
|
||||
entries = [counter]
|
||||
@ -317,7 +317,7 @@ def get_ipa_config():
|
||||
config = get_sub_entry("cn=etc," + api.env.basedn, searchfilter)
|
||||
except ldap.NO_SUCH_OBJECT, e:
|
||||
# FIXME
|
||||
raise errors2.NotFound
|
||||
raise errors2.NotFound()
|
||||
|
||||
return config
|
||||
|
||||
@ -409,12 +409,12 @@ def add_member_to_group(member_dn, group_dn, memberattr='member'):
|
||||
|
||||
group = get_entry_by_dn(group_dn, None)
|
||||
if group is None:
|
||||
raise errors2.NotFound
|
||||
raise errors2.NotFound()
|
||||
|
||||
# check to make sure member_dn exists
|
||||
member_entry = get_base_entry(member_dn, "(objectClass=*)", ['dn','objectclass'])
|
||||
if not member_entry:
|
||||
raise errors2.NotFound
|
||||
raise errors2.NotFound()
|
||||
|
||||
# Add the new member to the group member attribute
|
||||
members = group.get(memberattr, [])
|
||||
@ -433,7 +433,7 @@ def remove_member_from_group(member_dn, group_dn, memberattr='member'):
|
||||
|
||||
group = get_entry_by_dn(group_dn, None)
|
||||
if group is None:
|
||||
raise errors2.NotFound
|
||||
raise errors2.NotFound()
|
||||
"""
|
||||
if group.get('cn') == "admins":
|
||||
member = get_entry_by_dn(member_dn, ['dn','uid'])
|
||||
|
@ -24,16 +24,16 @@ Test the `ipalib/plugins/f_group` module.
|
||||
import sys
|
||||
from xmlrpc_test import XMLRPC_test
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import errors2
|
||||
|
||||
|
||||
class test_Group(XMLRPC_test):
|
||||
"""
|
||||
Test the `f_group` plugin.
|
||||
"""
|
||||
cn='testgroup'
|
||||
cn2='testgroup2'
|
||||
description='This is a test'
|
||||
cn = u'testgroup'
|
||||
cn2 = u'testgroup2'
|
||||
description = u'This is a test'
|
||||
kw={'description':description,'cn':cn}
|
||||
|
||||
def test_add(self):
|
||||
@ -109,7 +109,7 @@ class test_Group(XMLRPC_test):
|
||||
"""
|
||||
modkw = self.kw
|
||||
modkw['cn'] = self.cn
|
||||
modkw['description'] = 'New description'
|
||||
modkw['description'] = u'New description'
|
||||
res = api.Command['group_mod'](**modkw)
|
||||
assert res
|
||||
assert res.get('description','') == 'New description'
|
||||
|
@ -31,9 +31,9 @@ class test_Host(XMLRPC_test):
|
||||
"""
|
||||
Test the `f_host` plugin.
|
||||
"""
|
||||
cn='ipaexample.%s' % api.env.domain
|
||||
description='Test host'
|
||||
localityname='Undisclosed location'
|
||||
cn = api.env.host.decode('UTF-8')
|
||||
description = u'Test host'
|
||||
localityname = u'Undisclosed location'
|
||||
kw={'cn': cn, 'description': description, 'localityname': localityname}
|
||||
|
||||
def test_add(self):
|
||||
@ -41,10 +41,10 @@ class test_Host(XMLRPC_test):
|
||||
Test the `xmlrpc.host_add` method.
|
||||
"""
|
||||
res = api.Command['host_add'](**self.kw)
|
||||
assert res
|
||||
assert res.get('description','') == self.description
|
||||
assert res.get('cn','') == self.cn
|
||||
assert res.get('l','') == self.localityname
|
||||
assert type(res) is dict
|
||||
assert res['description'] == self.description
|
||||
assert res['cn'] == self.cn
|
||||
assert res['l'] == self.localityname
|
||||
|
||||
def test_doshow_all(self):
|
||||
"""
|
||||
@ -95,7 +95,7 @@ class test_Host(XMLRPC_test):
|
||||
"""
|
||||
Test the `xmlrpc.host_mod` method.
|
||||
"""
|
||||
newdesc='Updated host'
|
||||
newdesc = u'Updated host'
|
||||
modkw={'cn': self.cn, 'description': newdesc}
|
||||
res = api.Command['host_mod'](**modkw)
|
||||
assert res
|
||||
|
@ -31,13 +31,13 @@ class test_Host(XMLRPC_test):
|
||||
"""
|
||||
Test the `f_hostgroup` plugin.
|
||||
"""
|
||||
cn='testgroup'
|
||||
description='Test host group'
|
||||
cn=u'testgroup'
|
||||
description=u'Test host group'
|
||||
kw={'cn': cn, 'description': description}
|
||||
|
||||
host_cn='ipaexample.%s' % api.env.domain
|
||||
host_description='Test host'
|
||||
host_localityname='Undisclosed location'
|
||||
host_cn = api.env.host.decode('UTF-8')
|
||||
host_description = u'Test host'
|
||||
host_localityname = u'Undisclosed location'
|
||||
|
||||
def test_add(self):
|
||||
"""
|
||||
@ -83,7 +83,7 @@ class test_Host(XMLRPC_test):
|
||||
"""
|
||||
res = api.Command['hostgroup_find'](self.cn)
|
||||
assert res
|
||||
assert len(res) == 2
|
||||
assert len(res) == 2, res
|
||||
assert res[1].get('description','') == self.description
|
||||
assert res[1].get('cn','') == self.cn
|
||||
assert res[1].get('member','').startswith('cn=%s' % self.host_cn)
|
||||
@ -92,7 +92,7 @@ class test_Host(XMLRPC_test):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_mod` method.
|
||||
"""
|
||||
newdesc='Updated host group'
|
||||
newdesc=u'Updated host group'
|
||||
modkw={'cn': self.cn, 'description': newdesc}
|
||||
res = api.Command['hostgroup_mod'](**modkw)
|
||||
assert res
|
||||
|
@ -24,7 +24,7 @@ Test the `ipalib/plugins/f_netgroup` module.
|
||||
import sys
|
||||
from xmlrpc_test import XMLRPC_test
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import errors2
|
||||
|
||||
|
||||
def is_member_of(members, candidate):
|
||||
@ -41,27 +41,27 @@ class test_Netgroup(XMLRPC_test):
|
||||
"""
|
||||
Test the `f_netgroup` plugin.
|
||||
"""
|
||||
ng_cn='ng1'
|
||||
ng_description='Netgroup'
|
||||
ng_cn=u'ng1'
|
||||
ng_description=u'Netgroup'
|
||||
ng_kw={'cn': ng_cn, 'description': ng_description}
|
||||
|
||||
host_cn='ipaexample.%s' % api.env.domain
|
||||
host_description='Test host'
|
||||
host_localityname='Undisclosed location'
|
||||
host_cn = api.env.host.decode('UTF-8')
|
||||
host_description=u'Test host'
|
||||
host_localityname=u'Undisclosed location'
|
||||
host_kw={'cn': host_cn, 'description': host_description, 'localityname': host_localityname}
|
||||
|
||||
hg_cn='ng1'
|
||||
hg_description='Netgroup'
|
||||
hg_cn=u'ng1'
|
||||
hg_description=u'Netgroup'
|
||||
hg_kw={'cn': hg_cn, 'description': hg_description}
|
||||
|
||||
user_uid='jexample'
|
||||
user_givenname='Jim'
|
||||
user_sn='Example'
|
||||
user_home='/home/%s' % user_uid
|
||||
user_uid=u'jexample'
|
||||
user_givenname=u'Jim'
|
||||
user_sn=u'Example'
|
||||
user_home=u'/home/%s' % user_uid
|
||||
user_kw={'givenname':user_givenname,'sn':user_sn,'uid':user_uid,'homedirectory':user_home}
|
||||
|
||||
group_cn='testgroup'
|
||||
group_description='This is a test'
|
||||
group_cn = u'testgroup'
|
||||
group_description = u'This is a test'
|
||||
group_kw={'description':group_description,'cn':group_cn}
|
||||
|
||||
def test_add(self):
|
||||
@ -87,7 +87,7 @@ class test_Netgroup(XMLRPC_test):
|
||||
# Add a hostgroup
|
||||
res = api.Command['hostgroup_add'](**self.hg_kw)
|
||||
assert res
|
||||
assert res.get('description','') == self.hg_description
|
||||
assert res.get('description', '') == self.hg_description
|
||||
assert res.get('cn','') == self.hg_cn
|
||||
|
||||
# Add a user
|
||||
@ -155,7 +155,7 @@ class test_Netgroup(XMLRPC_test):
|
||||
Test adding external hosts
|
||||
"""
|
||||
kw={}
|
||||
kw['hosts'] = "nosuchhost"
|
||||
kw['hosts'] = u"nosuchhost"
|
||||
res = api.Command['netgroup_add_member'](self.ng_cn, **kw)
|
||||
assert res == tuple()
|
||||
res = api.Command['netgroup_show'](self.ng_cn)
|
||||
@ -179,9 +179,9 @@ class test_Netgroup(XMLRPC_test):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_find` method.
|
||||
"""
|
||||
res = api.Command['netgroup_find'](self.ng_cn)
|
||||
res = api.Command.netgroup_find(self.ng_cn)
|
||||
assert res
|
||||
assert len(res) == 2
|
||||
assert len(res) == 2, repr(res)
|
||||
assert res[1].get('description','') == self.ng_description
|
||||
assert res[1].get('cn','') == self.ng_cn
|
||||
|
||||
@ -189,7 +189,7 @@ class test_Netgroup(XMLRPC_test):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_mod` method.
|
||||
"""
|
||||
newdesc='Updated host group'
|
||||
newdesc=u'Updated host group'
|
||||
modkw={'cn': self.ng_cn, 'description': newdesc}
|
||||
res = api.Command['netgroup_mod'](**modkw)
|
||||
assert res
|
||||
|
@ -24,15 +24,15 @@ Test the `ipalib/plugins/f_service` module.
|
||||
import sys
|
||||
from xmlrpc_test import XMLRPC_test
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import errors2
|
||||
|
||||
|
||||
class test_Service(XMLRPC_test):
|
||||
"""
|
||||
Test the `f_service` plugin.
|
||||
"""
|
||||
principal='HTTP/ipatest.%s@%s' % (api.env.domain, api.env.realm)
|
||||
hostprincipal='host/ipatest.%s@%s' % (api.env.domain, api.env.realm)
|
||||
principal=u'HTTP/ipatest.%s@%s' % (api.env.domain, api.env.realm)
|
||||
hostprincipal=u'host/ipatest.%s@%s' % (api.env.domain, api.env.realm)
|
||||
kw={'principal':principal}
|
||||
|
||||
def test_add(self):
|
||||
@ -60,7 +60,7 @@ class test_Service(XMLRPC_test):
|
||||
"""
|
||||
Test adding a malformed principal ('foo').
|
||||
"""
|
||||
kw={'principal':'foo'}
|
||||
kw={'principal': u'foo'}
|
||||
try:
|
||||
res = api.Command['service_add'](**kw)
|
||||
except errors2.MalformedServicePrincipal:
|
||||
@ -72,7 +72,7 @@ class test_Service(XMLRPC_test):
|
||||
"""
|
||||
Test adding a malformed principal ('HTTP/foo@FOO.NET').
|
||||
"""
|
||||
kw={'principal':'HTTP/foo@FOO.NET'}
|
||||
kw={'principal': u'HTTP/foo@FOO.NET'}
|
||||
try:
|
||||
res = api.Command['service_add'](**kw)
|
||||
except errors2.RealmMismatch:
|
||||
|
@ -24,18 +24,18 @@ Test the `ipalib/plugins/f_user` module.
|
||||
import sys
|
||||
from xmlrpc_test import XMLRPC_test
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import errors2
|
||||
|
||||
|
||||
class test_User(XMLRPC_test):
|
||||
"""
|
||||
Test the `f_user` plugin.
|
||||
"""
|
||||
uid='jexample'
|
||||
givenname='Jim'
|
||||
sn='Example'
|
||||
home='/home/%s' % uid
|
||||
principalname='%s@%s' % (uid, api.env.realm)
|
||||
uid=u'jexample'
|
||||
givenname=u'Jim'
|
||||
sn=u'Example'
|
||||
home=u'/home/%s' % uid
|
||||
principalname=u'%s@%s' % (uid, api.env.realm)
|
||||
kw={'givenname':givenname,'sn':sn,'uid':uid,'homedirectory':home}
|
||||
|
||||
def test_add(self):
|
||||
@ -117,7 +117,7 @@ class test_User(XMLRPC_test):
|
||||
Test the `xmlrpc.user_mod` method.
|
||||
"""
|
||||
modkw = self.kw
|
||||
modkw['givenname'] = 'Finkle'
|
||||
modkw['givenname'] = u'Finkle'
|
||||
res = api.Command['user_mod'](**modkw)
|
||||
assert res
|
||||
assert res.get('givenname','') == 'Finkle'
|
||||
@ -126,7 +126,7 @@ class test_User(XMLRPC_test):
|
||||
# Ok, double-check that it was changed
|
||||
res = api.Command['user_show'](self.uid)
|
||||
assert res
|
||||
assert res.get('givenname','') == 'Finkle'
|
||||
assert res.get('givenname','') == u'Finkle'
|
||||
assert res.get('sn','') == self.sn
|
||||
assert res.get('uid','') == self.uid
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user