summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/errors.py20
-rw-r--r--ipalib/errors2.py79
-rw-r--r--ipalib/plugins/f_automount.py10
-rw-r--r--ipalib/plugins/f_delegation.py1
-rw-r--r--ipalib/plugins/f_group.py10
-rw-r--r--ipalib/plugins/f_host.py6
-rw-r--r--ipalib/plugins/f_hostgroup.py10
-rw-r--r--ipalib/plugins/f_netgroup.py4
-rw-r--r--ipalib/plugins/f_service.py10
-rw-r--r--ipalib/plugins/f_user.py9
-rw-r--r--ipaserver/ipaldap.py12
-rw-r--r--ipaserver/plugins/b_ldap.py29
-rw-r--r--ipaserver/servercore.py14
-rw-r--r--tests/test_xmlrpc/test_automount_plugin.py12
-rw-r--r--tests/test_xmlrpc/test_group_plugin.py10
-rw-r--r--tests/test_xmlrpc/test_host_plugin.py2
-rw-r--r--tests/test_xmlrpc/test_hostgroup_plugin.py8
-rw-r--r--tests/test_xmlrpc/test_netgroup_plugin.py30
-rw-r--r--tests/test_xmlrpc/test_service_plugin.py31
-rw-r--r--tests/test_xmlrpc/test_user_plugin.py4
-rw-r--r--tests/test_xmlrpc/xmlrpc_test.py4
21 files changed, 206 insertions, 109 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index beb6342d9..722de7658 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -320,14 +320,6 @@ class MidairCollision(GenericError):
"""Change collided with another change"""
faultCode = 1002
-class NotFound(GenericError):
- """Entry not found"""
- faultCode = 1003
-
-class DuplicateEntry(GenericError):
- """This entry already exists"""
- faultCode = 1004
-
class MissingDN(GenericError):
"""The distinguished name (DN) is missing"""
faultCode = 1005
@@ -360,14 +352,6 @@ class PrincipalError(GenericError):
"""There is a problem with the kerberos principal"""
faultCode = 1012
-class MalformedServicePrincipal(PrincipalError):
- """The requested service principal is not of the form: service/fully-qualified host name"""
- faultCode = 1013
-
-class RealmMismatch(PrincipalError):
- """The realm for the principal does not match the realm for this IPA server"""
- faultCode = 1014
-
class PrincipalRequired(PrincipalError):
"""You cannot remove IPA server service principals"""
faultCode = 1015
@@ -412,10 +396,6 @@ class DefaultGroup(ConfigurationError):
"""You cannot remove the default users group"""
faultCode = 1025
-class HostService(ConfigurationError):
- """You must enroll a host in order to create a host service"""
- faultCode = 1026
-
class InsufficientAccess(GenericError):
"""You do not have permission to perform this task"""
faultCode = 1027
diff --git a/ipalib/errors2.py b/ipalib/errors2.py
index 4a6a517dd..83ea2aab4 100644
--- a/ipalib/errors2.py
+++ b/ipalib/errors2.py
@@ -599,6 +599,85 @@ class ExecutionError(PublicError):
errno = 4000
+class NotFound(ExecutionError):
+ """
+ **4001** Raised when an entry is not found.
+
+ For example:
+
+ >>> raise NotFound(msg='Entry not found')
+ Traceback (most recent call last):
+ ...
+ NotFound: Entry not found
+
+ """
+
+ errno = 4001
+ format = _('%(msg)s')
+
+class DuplicateEntry(ExecutionError):
+ """
+ **4002** Raised when an entry already exists.
+
+ For example:
+
+ >>> raise DuplicateEntry
+ Traceback (most recent call last):
+ ...
+ DuplicateEntry: This entry already exists
+
+ """
+
+ errno = 4002
+ format = _('This entry already exists')
+
+class HostService(ExecutionError):
+ """
+ **4003** Raised when a host service principal is requested
+
+ For example:
+
+ >>> raise HostService
+ Traceback (most recent call last):
+ ...
+ HostService: You must enroll a host in order to create a host service
+
+ """
+
+ errno = 4003
+ format = _('You must enroll a host in order to create a host service')
+
+class MalformedServicePrincipal(ExecutionError):
+ """
+ **4004** Raised when a service principal is not of the form: service/fully-qualified host name
+
+ For example:
+
+ >>> raise MalformedServicePrincipal
+ Traceback (most recent call last):
+ ...
+ MalformedServicePrincipal: Service principal is not of the form: service/fully-qualified host name
+
+ """
+
+ errno = 4004
+ format = _('Service principal is not of the form: service/fully-qualified host name')
+
+class RealmMismatch(ExecutionError):
+ """
+ **4005** Raised when the requested realm does not match the IPA realm
+
+ For example:
+
+ >>> raise RealmMismatch
+ Traceback (most recent call last):
+ ...
+ RealmMismatch: The realm for the principal does not match the realm for this IPA server
+
+ """
+
+ errno = 4005
+ format = _('The realm for the principal does not match the realm for this IPA server')
class BuiltinError(ExecutionError):
"""
diff --git a/ipalib/plugins/f_automount.py b/ipalib/plugins/f_automount.py
index 2365ce221..1c6511e5c 100644
--- a/ipalib/plugins/f_automount.py
+++ b/ipalib/plugins/f_automount.py
@@ -24,7 +24,7 @@ RFC 2707bis http://www.padl.com/~lukeh/rfc2307bis.txt
"""
from ldap import explode_dn
-from ipalib import crud, errors
+from ipalib import crud, errors2
from ipalib import api, Str, Flag, Object, Command
map_attributes = ['automountMapName', 'description', ]
@@ -199,7 +199,7 @@ class automount_delkey(crud.Del):
keydn = k.get('dn')
break
if not keydn:
- raise errors.NotFound
+ raise errors2.NotFound(msg='Entry not found')
return ldap.delete(keydn)
def output_for_cli(self, textui, result, *args, **options):
"""
@@ -277,7 +277,7 @@ class automount_modkey(crud.Mod):
keydn = k.get('dn')
break
if not keydn:
- raise errors.NotFound
+ raise errors2.NotFound(msg='Entry not found')
return ldap.update(keydn, **kw)
def output_for_cli(self, textui, result, *args, **options):
@@ -425,7 +425,7 @@ class automount_showkey(crud.Get):
keydn = k.get('dn')
break
if not keydn:
- raise errors.NotFound
+ raise errors2.NotFound(msg='Entry not found')
# FIXME: should kw contain the list of attributes to display?
if kw.get('all', False):
return ldap.retrieve(keydn)
@@ -466,7 +466,7 @@ class automount_getkeys(Command):
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
try:
keys = ldap.get_one_entry(dn, 'objectclass=*', ['automountkey'])
- except errors.NotFound:
+ except errors2.NotFound:
keys = []
return keys
diff --git a/ipalib/plugins/f_delegation.py b/ipalib/plugins/f_delegation.py
index fbf8cfbff..4c207b338 100644
--- a/ipalib/plugins/f_delegation.py
+++ b/ipalib/plugins/f_delegation.py
@@ -25,7 +25,6 @@ from ipalib import frontend
from ipalib import crud
from ipalib.frontend import Param
from ipalib import api
-from ipalib import errors
class delegation(frontend.Object):
"""
diff --git a/ipalib/plugins/f_group.py b/ipalib/plugins/f_group.py
index 740b32f8c..99a8e1324 100644
--- a/ipalib/plugins/f_group.py
+++ b/ipalib/plugins/f_group.py
@@ -21,7 +21,7 @@
Frontend plugins for group (Identity).
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str, Int # Parameter types
@@ -283,7 +283,7 @@ class group_add_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m)
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -293,7 +293,7 @@ class group_add_member(Command):
try:
member_dn = ldap.find_entry_dn("uid", m)
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -350,7 +350,7 @@ class group_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m)
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
@@ -359,7 +359,7 @@ class group_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("uid", m,)
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
diff --git a/ipalib/plugins/f_host.py b/ipalib/plugins/f_host.py
index ea819a77d..17bec9774 100644
--- a/ipalib/plugins/f_host.py
+++ b/ipalib/plugins/f_host.py
@@ -21,7 +21,7 @@
Frontend plugins for host/machine Identity.
"""
-from ipalib import api, crud, errors, util
+from ipalib import api, crud, errors2, util
from ipalib import Object # Plugin base class
from ipalib import Str, Flag # Parameter types
@@ -38,7 +38,7 @@ def get_host(hostname):
hostname = hostname[:-1]
try:
dn = ldap.find_entry_dn("cn", hostname, "ipaHost")
- except errors.NotFound:
+ except errors2.NotFound:
dn = ldap.find_entry_dn("serverhostname", hostname, "ipaHost")
return dn
@@ -120,7 +120,7 @@ class host_add(crud.Add):
current = util.get_current_principal()
if not current:
- raise errors.NotFound('Unable to determine current user')
+ raise errors2.NotFound('Unable to determine current user')
kw['enrolledby'] = ldap.find_entry_dn("krbPrincipalName", current, "posixAccount")
# Get our configuration
diff --git a/ipalib/plugins/f_hostgroup.py b/ipalib/plugins/f_hostgroup.py
index 706712c9a..85dbfc496 100644
--- a/ipalib/plugins/f_hostgroup.py
+++ b/ipalib/plugins/f_hostgroup.py
@@ -21,7 +21,7 @@
Frontend plugins for groups of hosts
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str # Parameter types
@@ -249,7 +249,7 @@ class hostgroup_add_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, hostgroup_filter)
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -259,7 +259,7 @@ class hostgroup_add_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, "ipaHost")
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -317,7 +317,7 @@ class hostgroup_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, hostgroup_filter)
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
@@ -327,7 +327,7 @@ class hostgroup_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, "ipaHost")
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
diff --git a/ipalib/plugins/f_netgroup.py b/ipalib/plugins/f_netgroup.py
index 6ee55b0db..3fa81c7e3 100644
--- a/ipalib/plugins/f_netgroup.py
+++ b/ipalib/plugins/f_netgroup.py
@@ -21,7 +21,7 @@
Frontend plugin for netgroups.
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str # Parameter types
from ipalib import uuid
@@ -53,7 +53,7 @@ def find_members(ldap, failed, members, attribute, filter=None):
try:
member_dn = ldap.find_entry_dn(attribute, m, filter)
found.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
failed.append(m)
continue
diff --git a/ipalib/plugins/f_service.py b/ipalib/plugins/f_service.py
index 06d6a5d08..99446b598 100644
--- a/ipalib/plugins/f_service.py
+++ b/ipalib/plugins/f_service.py
@@ -22,7 +22,7 @@
Frontend plugins for service (Identity).
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object # Plugin base classes
from ipalib import Str, Flag # Parameter types
@@ -72,11 +72,11 @@ class service_add(crud.Add):
# may not include the realm.
sp = principal.split('/')
if len(sp) != 2:
- raise errors.MalformedServicePrincipal
+ raise errors2.MalformedServicePrincipal
service = sp[0]
if service.lower() == "host":
- raise errors.HostService
+ raise errors2.HostService
sr = sp[1].split('@')
if len(sr) == 1:
@@ -86,7 +86,7 @@ class service_add(crud.Add):
hostname = sr[0].lower()
realm = sr[1]
else:
- raise MalformedServicePrincipal
+ raise errors2.MalformedServicePrincipal
"""
FIXME once DNS client is done
@@ -102,7 +102,7 @@ class service_add(crud.Add):
# At some point we'll support multiple realms
if (realm != self.api.env.realm):
- raise errors.RealmMismatch
+ raise errors2.RealmMismatch
# Put the principal back together again
princ_name = service + "/" + hostname + "@" + realm
diff --git a/ipalib/plugins/f_user.py b/ipalib/plugins/f_user.py
index 58ff53cda..ce880b24e 100644
--- a/ipalib/plugins/f_user.py
+++ b/ipalib/plugins/f_user.py
@@ -21,7 +21,7 @@
Frontend plugins for user (Identity).
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str, Password, Flag, Int # Parameter types
@@ -99,6 +99,9 @@ class user(Object):
cli_name='uid',
doc='The uid to use for this user. If not included one is automatically set.',
),
+ Str('street?',
+ doc='The street address',
+ ),
)
api.register(user)
@@ -151,9 +154,9 @@ class user_add(crud.Add):
default_group = ldap.retrieve(group_dn, ['dn','gidNumber'])
if default_group:
kw['gidnumber'] = default_group.get('gidnumber')
- except errors.NotFound:
+ except errors2.NotFound:
# Fake an LDAP error so we can return something useful to the kw
- raise errors.NotFound, "The default group for new kws, '%s', cannot be found." % config.get('ipadefaultprimarygroup')
+ raise errors2.NotFound, "The default group for new kws, '%s', cannot be found." % config.get('ipadefaultprimarygroup')
except Exception, e:
# catch everything else
raise e
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index 4a2e4e31c..e7177b3e2 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -32,7 +32,7 @@ import ldap.sasl
from ldap.controls import LDAPControl,DecodeControlTuples,EncodeControlTuples
from ldap.ldapobject import SimpleLDAPObject
from ipaserver import ipautil
-from ipalib import errors
+from ipalib import errors, errors2
# Global variable to define SASL auth
sasl_auth = ldap.sasl.sasl({},'GSSAPI')
@@ -294,12 +294,12 @@ class IPAdmin(SimpleLDAPObject):
res = self.search(*args)
objtype, obj = self.result(res)
except ldap.NO_SUCH_OBJECT, e:
- raise errors.NotFound, notfound(args)
+ raise errors2.NotFound(msg=notfound(args))
except ldap.LDAPError, e:
raise errors.DatabaseError, e
if not obj:
- raise errors.NotFound, notfound(args)
+ raise errors2.NotFound(msg=notfound(args))
elif isinstance(obj,Entry):
return obj
@@ -323,7 +323,7 @@ class IPAdmin(SimpleLDAPObject):
raise e
if not obj:
- raise errors.NotFound, notfound(args)
+ raise errors2.NotFound(msg=notfound(args))
entries = []
for s in obj:
@@ -360,7 +360,7 @@ class IPAdmin(SimpleLDAPObject):
raise e
if not entries:
- raise errors.NotFound, notfound(args)
+ raise errors2.NotFound(msg=notfound(args))
if partial == 1:
counter = -1
@@ -380,7 +380,7 @@ class IPAdmin(SimpleLDAPObject):
self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl)
self.add_s(*args)
except ldap.ALREADY_EXISTS, e:
- raise errors.DuplicateEntry, "Entry already exists"
+ raise errors2.DuplicateEntry
except ldap.LDAPError, e:
raise errors.DatabaseError, e
return True
diff --git a/ipaserver/plugins/b_ldap.py b/ipaserver/plugins/b_ldap.py
index 1160bf9e7..20fd01ec9 100644
--- a/ipaserver/plugins/b_ldap.py
+++ b/ipaserver/plugins/b_ldap.py
@@ -82,6 +82,16 @@ class ldap(CrudBackend):
self.api.env.basedn,
)
+ def make_taskgroup_dn(self, cn):
+ """
+ Construct group of tasks dn from cn.
+ """
+ return 'cn=%s,%s,%s' % (
+ self.dn.escape_dn_chars(cn),
+ self.api.env.container_taskgroup,
+ self.api.env.basedn,
+ )
+
def make_service_dn(self, principal):
"""
Construct service principal dn from principal name
@@ -227,14 +237,12 @@ class ldap(CrudBackend):
else:
assert type(value) in (str, unicode, bool, int, float)
yield (key, value)
- yield (key, value)
def create(self, **kw):
if servercore.entry_exists(kw['dn']):
- raise errors.DuplicateEntry("entry already exists")
+ raise errors2.DuplicateEntry
kw = dict(self.strip_none(kw))
-
entry = ipaldap.Entry(kw['dn'])
# dn isn't allowed to be in the entry itself
@@ -251,19 +259,20 @@ class ldap(CrudBackend):
return servercore.get_entry_by_dn(dn, attributes)
def update(self, dn, **kw):
- result = self.retrieve(dn, ["*"])
- start_keys = kw.keys()
+ result = self.retrieve(dn, ["*"] + kw.keys())
entry = ipaldap.Entry((dn, servercore.convert_scalar_values(result)))
+ start_keys = kw.keys()
kw = dict(self.strip_none(kw))
+ end_keys = kw.keys()
+ removed_keys = list(set(start_keys) - set(end_keys))
for k in kw:
entry.setValues(k, kw[k])
- remove_keys = list(set(start_keys) - set(kw.keys()))
- for k in remove_keys:
+ for k in removed_keys:
entry.delAttr(k)
- servercore.update_entry(entry.toDict(), remove_keys)
+ servercore.update_entry(entry.toDict(), removed_keys)
return self.retrieve(dn)
@@ -300,13 +309,13 @@ class ldap(CrudBackend):
try:
exact_results = servercore.search(search_base,
exact_match_filter, attributes)
- except errors.NotFound:
+ except errors2.NotFound:
exact_results = [0]
try:
partial_results = servercore.search(search_base,
partial_match_filter, attributes)
- except errors.NotFound:
+ except errors2.NotFound:
partial_results = [0]
exact_counter = exact_results[0]
diff --git a/ipaserver/servercore.py b/ipaserver/servercore.py
index 19adb019f..c97148b37 100644
--- a/ipaserver/servercore.py
+++ b/ipaserver/servercore.py
@@ -23,7 +23,7 @@ import re
from ipalib.request import context
from ipaserver import ipaldap
import ipautil
-from ipalib import errors
+from ipalib import errors, errors2
from ipalib import api
def convert_entry(ent):
@@ -186,7 +186,7 @@ def entry_exists(dn):
try:
get_base_entry(dn, "objectclass=*", ['dn','objectclass'])
return True
- except errors.NotFound:
+ except errors2.NotFound:
return False
def get_user_by_uid (uid, sattrs):
@@ -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 errors.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 errors.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 errors.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 errors.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 errors.NotFound
+ raise errors2.NotFound
"""
if group.get('cn') == "admins":
member = get_entry_by_dn(member_dn, ['dn','uid'])
diff --git a/tests/test_xmlrpc/test_automount_plugin.py b/tests/test_xmlrpc/test_automount_plugin.py
index 9de53ea1e..fde86629f 100644
--- a/tests/test_xmlrpc/test_automount_plugin.py
+++ b/tests/test_xmlrpc/test_automount_plugin.py
@@ -70,7 +70,7 @@ class test_Service(XMLRPC_test):
"""
try:
res = api.Command['automount_addkey'](**self.key_kw)
- except errors.DuplicateEntry:
+ except errors2.DuplicateEntry:
pass
else:
assert False
@@ -145,7 +145,7 @@ class test_Service(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['automount_showkey'](**delkey_kw)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -160,7 +160,7 @@ class test_Service(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['automount_showmap'](self.mapname)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -173,7 +173,7 @@ class test_Service(XMLRPC_test):
key_kw={'automountmapname': self.mapname, 'automountkey': self.keyname2}
try:
res = api.Command['automount_showkey'](**key_kw)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -216,7 +216,7 @@ class test_Indirect(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['automount_showkey'](**delkey_kw)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -231,7 +231,7 @@ class test_Indirect(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['automount_showmap'](self.mapname)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py
index 48cb3c97f..127c0b2bf 100644
--- a/tests/test_xmlrpc/test_group_plugin.py
+++ b/tests/test_xmlrpc/test_group_plugin.py
@@ -51,10 +51,10 @@ class test_Group(XMLRPC_test):
"""
try:
res = api.Command['group_add'](**self.kw)
- except errors.DuplicateEntry:
+ except errors2.DuplicateEntry:
pass
- def test_add2(self):
+ def test_add3(self):
"""
Test the `xmlrpc.group_add` method.
"""
@@ -71,7 +71,7 @@ class test_Group(XMLRPC_test):
kw={}
kw['groups'] = self.cn2
res = api.Command['group_add_member'](self.cn, **kw)
- assert res == []
+ assert res == tuple()
def test_add_member2(self):
"""
@@ -152,7 +152,7 @@ class test_Group(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['group_show'](self.cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -167,7 +167,7 @@ class test_Group(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['group_show'](self.cn2)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py
index f9e4108ee..a3921ce16 100644
--- a/tests/test_xmlrpc/test_host_plugin.py
+++ b/tests/test_xmlrpc/test_host_plugin.py
@@ -117,7 +117,7 @@ class test_Host(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['host_show'](self.cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py
index 1f1a5f3d1..ba6c255e0 100644
--- a/tests/test_xmlrpc/test_hostgroup_plugin.py
+++ b/tests/test_xmlrpc/test_hostgroup_plugin.py
@@ -65,7 +65,7 @@ class test_Host(XMLRPC_test):
kw={}
kw['hosts'] = self.host_cn
res = api.Command['hostgroup_add_member'](self.cn, **kw)
- assert res == []
+ assert res == tuple()
def test_doshow(self):
"""
@@ -111,7 +111,7 @@ class test_Host(XMLRPC_test):
kw={}
kw['hosts'] = self.host_cn
res = api.Command['hostgroup_remove_member'](self.cn, **kw)
- assert res == []
+ assert res == tuple()
def test_remove(self):
"""
@@ -123,7 +123,7 @@ class test_Host(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['hostgroup_show'](self.cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -138,7 +138,7 @@ class test_Host(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['host_show'](self.host_cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/test_netgroup_plugin.py b/tests/test_xmlrpc/test_netgroup_plugin.py
index 056ee0056..231adfd90 100644
--- a/tests/test_xmlrpc/test_netgroup_plugin.py
+++ b/tests/test_xmlrpc/test_netgroup_plugin.py
@@ -28,6 +28,8 @@ from ipalib import errors
def is_member_of(members, candidate):
+ if isinstance(members, tuple):
+ members = list(members)
if not isinstance(members, list):
members = [members]
for m in members:
@@ -107,22 +109,22 @@ class test_Netgroup(XMLRPC_test):
kw={}
kw['hosts'] = self.host_cn
res = api.Command['netgroup_add_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
kw={}
kw['hostgroups'] = self.hg_cn
res = api.Command['netgroup_add_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
kw={}
kw['users'] = self.user_uid
res = api.Command['netgroup_add_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
kw={}
kw['groups'] = self.group_cn
res = api.Command['netgroup_add_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
def test_addmembers2(self):
"""
@@ -155,7 +157,7 @@ class test_Netgroup(XMLRPC_test):
kw={}
kw['hosts'] = "nosuchhost"
res = api.Command['netgroup_add_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
res = api.Command['netgroup_show'](self.ng_cn)
assert res
assert is_member_of(res.get('externalhost',[]), kw['hosts'])
@@ -206,22 +208,22 @@ class test_Netgroup(XMLRPC_test):
kw={}
kw['hosts'] = self.host_cn
res = api.Command['netgroup_remove_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
kw={}
kw['hostgroups'] = self.hg_cn
res = api.Command['netgroup_remove_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
kw={}
kw['users'] = self.user_uid
res = api.Command['netgroup_remove_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
kw={}
kw['groups'] = self.group_cn
res = api.Command['netgroup_remove_member'](self.ng_cn, **kw)
- assert res == []
+ assert res == tuple()
def test_member_remove2(self):
"""
@@ -257,7 +259,7 @@ class test_Netgroup(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['netgroup_show'](self.ng_cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -273,7 +275,7 @@ class test_Netgroup(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['host_show'](self.host_cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -285,7 +287,7 @@ class test_Netgroup(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['hostgroup_show'](self.hg_cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -297,7 +299,7 @@ class test_Netgroup(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['user_show'](self.user_uid)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
@@ -309,7 +311,7 @@ class test_Netgroup(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['group_show'](self.group_cn)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/test_service_plugin.py b/tests/test_xmlrpc/test_service_plugin.py
index ca5d7e01e..1390d34ea 100644
--- a/tests/test_xmlrpc/test_service_plugin.py
+++ b/tests/test_xmlrpc/test_service_plugin.py
@@ -45,12 +45,37 @@ class test_Service(XMLRPC_test):
def test_add_host(self):
"""
- Test adding a host principal using `xmlrpc.service_add` method.
+ Test adding a host principal using `xmlrpc.service_add`. Host
+ services are not allowed.
"""
kw={'principal':self.hostprincipal}
try:
res = api.Command['service_add'](**kw)
- except errors.HostService:
+ except errors2.HostService:
+ pass
+ else:
+ assert False
+
+ def test_add_malformed1(self):
+ """
+ Test adding a malformed principal ('foo').
+ """
+ kw={'principal':'foo'}
+ try:
+ res = api.Command['service_add'](**kw)
+ except errors2.MalformedServicePrincipal:
+ pass
+ else:
+ assert False
+
+ def test_add_wrongrealm(self):
+ """
+ Test adding a malformed principal ('HTTP/foo@FOO.NET').
+ """
+ kw={'principal':'HTTP/foo@FOO.NET'}
+ try:
+ res = api.Command['service_add'](**kw)
+ except errors2.RealmMismatch:
pass
else:
assert False
@@ -82,7 +107,7 @@ class test_Service(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['service_show'](self.principal)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py
index 72b5e808b..ec21f4aaf 100644
--- a/tests/test_xmlrpc/test_user_plugin.py
+++ b/tests/test_xmlrpc/test_user_plugin.py
@@ -55,7 +55,7 @@ class test_User(XMLRPC_test):
"""
try:
res = api.Command['user_add'](**self.kw)
- except errors.DuplicateEntry:
+ except errors2.DuplicateEntry:
pass
def test_doshow(self):
@@ -140,7 +140,7 @@ class test_User(XMLRPC_test):
# Verify that it is gone
try:
res = api.Command['user_show'](self.uid)
- except errors.NotFound:
+ except errors2.NotFound:
pass
else:
assert False
diff --git a/tests/test_xmlrpc/xmlrpc_test.py b/tests/test_xmlrpc/xmlrpc_test.py
index 08f7eab89..1070196e1 100644
--- a/tests/test_xmlrpc/xmlrpc_test.py
+++ b/tests/test_xmlrpc/xmlrpc_test.py
@@ -25,7 +25,7 @@ import sys
import socket
import nose
from ipalib import api, request
-from ipalib import errors, errors2
+from ipalib import errors2
class XMLRPC_test(object):
@@ -40,7 +40,7 @@ class XMLRPC_test(object):
res = api.Command['user_show'](u'notfound')
except errors2.NetworkError:
raise nose.SkipTest()
- except errors.NotFound:
+ except errors2.NotFound:
pass
def tearDown(self):