mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
host and hostgroup summary messages, declarative tests; fix tests for 'dn'
This commit is contained in:
parent
c334ec4584
commit
8ae0f9c8aa
@ -21,9 +21,8 @@
|
||||
Groups of hosts.
|
||||
"""
|
||||
|
||||
from ipalib import api
|
||||
from ipalib import Int
|
||||
from ipalib.plugins.baseldap import *
|
||||
from ipalib import api, Int, _, ngettext
|
||||
|
||||
|
||||
class hostgroup(LDAPObject):
|
||||
@ -70,6 +69,8 @@ class hostgroup_add(LDAPCreate):
|
||||
Create new hostgroup.
|
||||
"""
|
||||
|
||||
msg_summary = _('Added hostgroup "%(value)s"')
|
||||
|
||||
api.register(hostgroup_add)
|
||||
|
||||
|
||||
@ -78,6 +79,8 @@ class hostgroup_del(LDAPDelete):
|
||||
Delete hostgroup.
|
||||
"""
|
||||
|
||||
msg_summary = _('Deleted hostgroup "%(value)s"')
|
||||
|
||||
api.register(hostgroup_del)
|
||||
|
||||
|
||||
@ -86,6 +89,8 @@ class hostgroup_mod(LDAPUpdate):
|
||||
Modify hostgroup.
|
||||
"""
|
||||
|
||||
msg_summary = _('Modified hostgroup "%(value)s"')
|
||||
|
||||
api.register(hostgroup_mod)
|
||||
|
||||
|
||||
@ -94,6 +99,10 @@ class hostgroup_find(LDAPSearch):
|
||||
Search for hostgroups.
|
||||
"""
|
||||
|
||||
msg_summary = ngettext(
|
||||
'%(count)d hostgroup matched', '%(count)d hostgroups matched'
|
||||
)
|
||||
|
||||
api.register(hostgroup_find)
|
||||
|
||||
|
||||
@ -119,4 +128,3 @@ class hostgroup_remove_member(LDAPRemoveMember):
|
||||
"""
|
||||
|
||||
api.register(hostgroup_remove_member)
|
||||
|
||||
|
40
tests/test_xmlrpc/objectclasses.py
Normal file
40
tests/test_xmlrpc/objectclasses.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Authors:
|
||||
# Jason Gerard DeRose <jderose@redhat.com>
|
||||
#
|
||||
# Copyright (C) 2008 Red Hat
|
||||
# see file 'COPYING' for use and warranty information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; version 2 only
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
"""
|
||||
Defines the expected objectclass for various entries.
|
||||
"""
|
||||
|
||||
host = (
|
||||
u'ipaobject',
|
||||
u'nshost',
|
||||
u'ipahost',
|
||||
u'pkiuser',
|
||||
u'krbprincipalaux',
|
||||
u'krbprincipal',
|
||||
u'top',
|
||||
)
|
||||
|
||||
hostgroup = (
|
||||
u'ipaobject',
|
||||
u'ipahostgroup',
|
||||
u'nestedGroup',
|
||||
u'groupOfNames',
|
||||
u'top',
|
||||
)
|
@ -64,7 +64,7 @@ class test_group(Declarative):
|
||||
),
|
||||
summary=u'Added group "testgroup1"',
|
||||
),
|
||||
ignore_values=['ipauniqueid'],
|
||||
ignore_values=['ipauniqueid', 'dn'],
|
||||
),
|
||||
|
||||
dict(
|
||||
@ -188,7 +188,7 @@ class test_group(Declarative):
|
||||
),
|
||||
summary=u'Added group "testgroup2"',
|
||||
),
|
||||
ignore_values=['ipauniqueid'],
|
||||
ignore_values=['ipauniqueid', 'dn'],
|
||||
),
|
||||
|
||||
dict(
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Rob Crittenden <rcritten@redhat.com>
|
||||
# Pavel Zuna <pzuna@redhat.com>
|
||||
#
|
||||
# Copyright (C) 2008 Red Hat
|
||||
# Copyright (C) 2008, 2009 Red Hat
|
||||
# see file 'COPYING' for use and warranty information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
@ -17,105 +17,230 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
"""
|
||||
Test the `ipalib/plugins/host.py` module.
|
||||
Test the `ipalib.plugins.host` module.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from xmlrpc_test import XMLRPC_test, assert_attr_equal
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import api, errors
|
||||
from tests.test_xmlrpc.xmlrpc_test import Declarative
|
||||
from tests.test_xmlrpc import objectclasses
|
||||
|
||||
|
||||
class test_host(XMLRPC_test):
|
||||
"""
|
||||
Test the `host` plugin.
|
||||
"""
|
||||
fqdn = u'ipatesthost.%s' % api.env.domain
|
||||
description = u'Test host'
|
||||
localityname = u'Undisclosed location'
|
||||
kw = {'fqdn': fqdn, 'description': description, 'localityname': localityname, 'raw': True}
|
||||
fqdn1 = u'testhost1.%s' % api.env.domain
|
||||
|
||||
def test_1_host_add(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_add` method.
|
||||
"""
|
||||
res = api.Command['host_add'](**self.kw)['result']
|
||||
assert type(res) is dict
|
||||
assert_attr_equal(res, 'description', self.description)
|
||||
assert_attr_equal(res, 'fqdn', self.fqdn)
|
||||
assert_attr_equal(res, 'localityname', self.localityname)
|
||||
assert_attr_equal(res, 'objectclass', 'ipaobject')
|
||||
|
||||
def test_2_host_show(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_show` method with all attributes.
|
||||
"""
|
||||
kw = {'fqdn': self.fqdn, 'all': True, 'raw': True}
|
||||
res = api.Command['host_show'](**kw)['result']
|
||||
assert res
|
||||
assert_attr_equal(res, 'description', self.description)
|
||||
assert_attr_equal(res, 'fqdn', self.fqdn)
|
||||
assert_attr_equal(res, 'l', self.localityname)
|
||||
class test_host(Declarative):
|
||||
|
||||
def test_3_host_show(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_show` method with default attributes.
|
||||
"""
|
||||
kw = {'fqdn': self.fqdn, 'raw': True}
|
||||
res = api.Command['host_show'](**kw)['result']
|
||||
assert res
|
||||
assert_attr_equal(res, 'description', self.description)
|
||||
assert_attr_equal(res, 'fqdn', self.fqdn)
|
||||
assert_attr_equal(res, 'localityname', self.localityname)
|
||||
cleanup_commands = [
|
||||
('host_del', [fqdn1], {}),
|
||||
]
|
||||
|
||||
def test_4_host_find(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_find` method with all attributes.
|
||||
"""
|
||||
kw = {'fqdn': self.fqdn, 'all': True, 'raw': True}
|
||||
res = api.Command['host_find'](**kw)['result']
|
||||
assert res
|
||||
assert_attr_equal(res[0], 'description', self.description)
|
||||
assert_attr_equal(res[0], 'fqdn', self.fqdn)
|
||||
assert_attr_equal(res[0], 'l', self.localityname)
|
||||
tests = [
|
||||
|
||||
def test_5_host_find(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_find` method with default attributes.
|
||||
"""
|
||||
res = api.Command['host_find'](self.fqdn, raw=True)['result']
|
||||
assert res
|
||||
assert_attr_equal(res[0], 'description', self.description)
|
||||
assert_attr_equal(res[0], 'fqdn', self.fqdn)
|
||||
assert_attr_equal(res[0], 'localityname', self.localityname)
|
||||
dict(
|
||||
desc='Try to retrieve non-existent %r' % fqdn1,
|
||||
command=('host_show', [fqdn1], {}),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
def test_6_host_mod(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_mod` method.
|
||||
"""
|
||||
newdesc = u'Updated host'
|
||||
modkw = {'fqdn': self.fqdn, 'description': newdesc, 'raw': True}
|
||||
res = api.Command['host_mod'](**modkw)['result']
|
||||
assert res
|
||||
assert_attr_equal(res, 'description', newdesc)
|
||||
|
||||
# Ok, double-check that it was changed
|
||||
res = api.Command['host_show'](self.fqdn, raw=True)['result']
|
||||
assert res
|
||||
assert_attr_equal(res, 'description', newdesc)
|
||||
assert_attr_equal(res, 'fqdn', self.fqdn)
|
||||
dict(
|
||||
desc='Try to update non-existent %r' % fqdn1,
|
||||
command=('host_mod', [fqdn1], dict(description=u'Nope')),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
def test_7_host_del(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_del` method.
|
||||
"""
|
||||
assert api.Command['host_del'](self.fqdn)['result'] is True
|
||||
|
||||
# Verify that it is gone
|
||||
try:
|
||||
api.Command['host_show'](self.fqdn)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
else:
|
||||
assert False
|
||||
dict(
|
||||
desc='Try to delete non-existent %r' % fqdn1,
|
||||
command=('host_del', [fqdn1], {}),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Create %r' % fqdn1,
|
||||
command=('host_add', [fqdn1],
|
||||
dict(
|
||||
description=u'Test host 1',
|
||||
localityname=u'Undisclosed location 1',
|
||||
),
|
||||
),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=u'Added host "%s"' % fqdn1,
|
||||
result=dict(
|
||||
cn=(fqdn1,), # FIXME: we should only return fqdn
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Test host 1',),
|
||||
localityname=(u'Undisclosed location 1',),
|
||||
krbprincipalname=(u'host/%s@%s' % (fqdn1, api.env.realm),),
|
||||
serverhostname=(u'testhost1',),
|
||||
objectclass=objectclasses.host,
|
||||
),
|
||||
),
|
||||
ignore_values=['ipauniqueid', 'dn'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Try to create duplicate %r' % fqdn1,
|
||||
command=('host_add', [fqdn1],
|
||||
dict(
|
||||
description=u'Test host 1',
|
||||
localityname=u'Undisclosed location 1',
|
||||
),
|
||||
),
|
||||
expected=errors.DuplicateEntry(),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Retrieve %r' % fqdn1,
|
||||
command=('host_show', [fqdn1], {}),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=None,
|
||||
result=dict(
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Test host 1',),
|
||||
localityname=(u'Undisclosed location 1',),
|
||||
),
|
||||
),
|
||||
ignore_values=['dn'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Retrieve %r with all=True' % fqdn1,
|
||||
command=('host_show', [fqdn1], dict(all=True)),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=None,
|
||||
result=dict(
|
||||
cn=(fqdn1,),
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Test host 1',),
|
||||
# FIXME: Why is 'localalityname' returned as 'l' with --all?
|
||||
# It is intuitive for --all to return additional attributes,
|
||||
# but not to return existing attributes under different
|
||||
# names.
|
||||
l=(u'Undisclosed location 1',),
|
||||
krbprincipalname=(u'host/%s@%s' % (fqdn1, api.env.realm),),
|
||||
serverhostname=(u'testhost1',),
|
||||
objectclass=objectclasses.host,
|
||||
),
|
||||
),
|
||||
ignore_values=['dn', 'ipauniqueid'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for %r' % fqdn1,
|
||||
command=('host_find', [fqdn1], {}),
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
summary=u'1 host matched',
|
||||
result=(
|
||||
dict(
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Test host 1',),
|
||||
localityname=(u'Undisclosed location 1',),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for %r with all=True' % fqdn1,
|
||||
command=('host_find', [fqdn1], dict(all=True)),
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
summary=u'1 host matched',
|
||||
result=(
|
||||
dict(
|
||||
cn=(fqdn1,),
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Test host 1',),
|
||||
# FIXME: Why is 'localalityname' returned as 'l' with --all?
|
||||
# It is intuitive for --all to return additional attributes,
|
||||
# but not to return existing attributes under different
|
||||
# names.
|
||||
l=(u'Undisclosed location 1',),
|
||||
krbprincipalname=(u'host/%s@%s' % (fqdn1, api.env.realm),),
|
||||
serverhostname=(u'testhost1',),
|
||||
objectclass=objectclasses.host,
|
||||
),
|
||||
),
|
||||
),
|
||||
# FIXME: With --all, host_show() returns the 'dn', but host_find()
|
||||
# doesn't.
|
||||
ignore_values=['ipauniqueid'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Update %r' % fqdn1,
|
||||
command=('host_mod', [fqdn1], dict(description=u'Updated host 1')),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=u'Modified host "%s"' % fqdn1,
|
||||
result=dict(
|
||||
description=(u'Updated host 1',),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Retrieve %r to verify update' % fqdn1,
|
||||
command=('host_show', [fqdn1], {}),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=None,
|
||||
result=dict(
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Updated host 1',),
|
||||
localityname=(u'Undisclosed location 1',),
|
||||
),
|
||||
),
|
||||
ignore_values=['dn'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Delete %r' % fqdn1,
|
||||
command=('host_del', [fqdn1], {}),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=u'Deleted host "%s"' % fqdn1,
|
||||
result=True,
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Try to retrieve non-existent %r' % fqdn1,
|
||||
command=('host_show', [fqdn1], {}),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Try to update non-existent %r' % fqdn1,
|
||||
command=('host_mod', [fqdn1], dict(description=u'Nope')),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Try to delete non-existent %r' % fqdn1,
|
||||
command=('host_del', [fqdn1], {}),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
]
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Rob Crittenden <rcritten@redhat.com>
|
||||
# Pavel Zuna <pzuna@redhat.com>
|
||||
#
|
||||
# Copyright (C) 2008 Red Hat
|
||||
# Copyright (C) 2008, 2009 Red Hat
|
||||
# see file 'COPYING' for use and warranty information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
@ -17,121 +17,225 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
"""
|
||||
Test the `ipalib/plugins/hostgroup.py` module.
|
||||
Test the `ipalib.plugins.hostgroup` module.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from xmlrpc_test import XMLRPC_test, assert_attr_equal
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib import api, errors
|
||||
from tests.test_xmlrpc.xmlrpc_test import Declarative
|
||||
from tests.test_xmlrpc import objectclasses
|
||||
|
||||
|
||||
class test_hostgroup(XMLRPC_test):
|
||||
"""
|
||||
Test the `hostgroup` plugin.
|
||||
"""
|
||||
cn = u'testgroup'
|
||||
description = u'Test host group'
|
||||
kw = {'cn': cn, 'description': description, 'raw': True}
|
||||
fqdn1 = u'testhost1.%s' % api.env.domain
|
||||
|
||||
host_fqdn = u'ipatesthost.%s' % api.env.domain
|
||||
host_description = u'Test host'
|
||||
host_localityname = u'Undisclosed location'
|
||||
|
||||
def test_1_hostgroup_add(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_add` method.
|
||||
"""
|
||||
entry = api.Command['hostgroup_add'](**self.kw)['result']
|
||||
assert_attr_equal(entry, 'description', self.description)
|
||||
assert_attr_equal(entry, 'cn', self.cn)
|
||||
assert_attr_equal(entry, 'objectclass', 'ipaobject')
|
||||
class test_hostgroup(Declarative):
|
||||
|
||||
def test_2_host_add(self):
|
||||
"""
|
||||
Add a host to test add/remove member.
|
||||
"""
|
||||
kw = {'fqdn': self.host_fqdn, 'description': self.host_description, 'localityname': self.host_localityname, 'raw': True}
|
||||
entry = api.Command['host_add'](**kw)['result']
|
||||
assert_attr_equal(entry, 'description', self.host_description)
|
||||
assert_attr_equal(entry, 'fqdn', self.host_fqdn)
|
||||
cleanup_commands = [
|
||||
('hostgroup_del', [u'testhostgroup1'], {}),
|
||||
('host_del', [fqdn1], {}),
|
||||
]
|
||||
|
||||
def test_3_hostgroup_add_member(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_add_member` method.
|
||||
"""
|
||||
kw = {'raw': True}
|
||||
kw['host'] = self.host_fqdn
|
||||
ret = api.Command['hostgroup_add_member'](self.cn, **kw)
|
||||
assert ret['result']['member'] != []
|
||||
assert ret['completed'] == 1
|
||||
tests=[
|
||||
|
||||
def test_4_hostgroup_show(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_show` method.
|
||||
"""
|
||||
entry = api.Command['hostgroup_show'](self.cn, raw=True)['result']
|
||||
assert_attr_equal(entry, 'description', self.description)
|
||||
assert_attr_equal(entry, 'cn', self.cn)
|
||||
dict(
|
||||
desc='Try to retrieve non-existent testhostgroup1',
|
||||
command=('hostgroup_show', [u'testhostgroup1'], {}),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
def test_5_hostgroup_find(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_find` method.
|
||||
"""
|
||||
ret = api.Command['hostgroup_find'](cn=self.cn, raw=True)
|
||||
assert ret['truncated'] is False
|
||||
entries = ret['result']
|
||||
assert_attr_equal(entries[0], 'description', self.description)
|
||||
assert_attr_equal(entries[0], 'cn', self.cn)
|
||||
|
||||
def test_6_hostgroup_mod(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_mod` method.
|
||||
"""
|
||||
newdesc = u'Updated host group'
|
||||
modkw = {'cn': self.cn, 'description': newdesc, 'raw': True}
|
||||
entry = api.Command['hostgroup_mod'](**modkw)['result']
|
||||
assert_attr_equal(entry, 'description', newdesc)
|
||||
dict(
|
||||
desc='Try to update non-existent testhostgroup1',
|
||||
command=('hostgroup_mod', [u'testhostgroup1'],
|
||||
dict(description=u'Updated hostgroup 1')
|
||||
),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
# Ok, double-check that it was changed
|
||||
entry = api.Command['hostgroup_show'](self.cn, raw=True)['result']
|
||||
assert_attr_equal(entry, 'description', newdesc)
|
||||
assert_attr_equal(entry, 'cn', self.cn)
|
||||
|
||||
def test_7_hostgroup_remove_member(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_remove_member` method.
|
||||
"""
|
||||
kw = {'raw': True}
|
||||
kw['host'] = self.host_fqdn
|
||||
ret = api.Command['hostgroup_remove_member'](self.cn, **kw)
|
||||
assert ret['completed'] == 1
|
||||
dict(
|
||||
desc='Try to delete non-existent testhostgroup1',
|
||||
command=('hostgroup_del', [u'testhostgroup1'], {}),
|
||||
expected=errors.NotFound(reason='no such entry'),
|
||||
),
|
||||
|
||||
def test_8_hostgroup_del(self):
|
||||
"""
|
||||
Test the `xmlrpc.hostgroup_del` method.
|
||||
"""
|
||||
assert api.Command['hostgroup_del'](self.cn)['result'] is True
|
||||
|
||||
# Verify that it is gone
|
||||
try:
|
||||
api.Command['hostgroup_show'](self.cn)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
else:
|
||||
assert False
|
||||
dict(
|
||||
desc='Create hostgroup testhostgroup1',
|
||||
command=('hostgroup_add', [u'testhostgroup1'],
|
||||
dict(description=u'Test hostgroup 1')
|
||||
),
|
||||
expected=dict(
|
||||
value=u'testhostgroup1',
|
||||
summary=u'Added hostgroup "testhostgroup1"',
|
||||
result=dict(
|
||||
cn=(u'testhostgroup1',),
|
||||
objectclass=objectclasses.hostgroup,
|
||||
description=(u'Test hostgroup 1',),
|
||||
),
|
||||
),
|
||||
ignore_values=['ipauniqueid', 'dn'],
|
||||
),
|
||||
|
||||
def test_9_host_del(self):
|
||||
"""
|
||||
Test the `xmlrpc.host_del` method.
|
||||
"""
|
||||
assert api.Command['host_del'](self.host_fqdn)['result'] is True
|
||||
|
||||
# Verify that it is gone
|
||||
try:
|
||||
api.Command['host_show'](self.host_fqdn)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
else:
|
||||
assert False
|
||||
dict(
|
||||
desc='Try to create duplicate testhostgroup1',
|
||||
command=('hostgroup_add', [u'testhostgroup1'],
|
||||
dict(description=u'Test hostgroup 1')
|
||||
),
|
||||
expected=errors.DuplicateEntry(),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Create host %r' % fqdn1,
|
||||
command=('host_add', [fqdn1],
|
||||
dict(
|
||||
description=u'Test host 1',
|
||||
localityname=u'Undisclosed location 1',
|
||||
),
|
||||
),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=u'Added host "%s"' % fqdn1,
|
||||
result=dict(
|
||||
cn=(fqdn1,), # FIXME: we should only return fqdn
|
||||
fqdn=(fqdn1,),
|
||||
description=(u'Test host 1',),
|
||||
localityname=(u'Undisclosed location 1',),
|
||||
krbprincipalname=(u'host/%s@%s' % (fqdn1, api.env.realm),),
|
||||
serverhostname=(u'testhost1',),
|
||||
objectclass=objectclasses.host,
|
||||
),
|
||||
),
|
||||
ignore_values=['ipauniqueid', 'dn'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc=u'Add %r to testhostgroup1' % fqdn1,
|
||||
command=(
|
||||
'hostgroup_add_member', [u'testhostgroup1'], dict(host=fqdn1)
|
||||
),
|
||||
expected=dict(
|
||||
completed=1,
|
||||
failed=dict(
|
||||
member=dict(
|
||||
host=tuple(),
|
||||
hostgroup=tuple(),
|
||||
),
|
||||
),
|
||||
result={
|
||||
'member host': (fqdn1,),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Retrieve testhostgroup1',
|
||||
command=('hostgroup_show', [u'testhostgroup1'], {}),
|
||||
expected=dict(
|
||||
value=u'testhostgroup1',
|
||||
summary=None,
|
||||
result={
|
||||
'member host': (u'testhost1.example.com',),
|
||||
'cn': (u'testhostgroup1',),
|
||||
'description': (u'Test hostgroup 1',)
|
||||
},
|
||||
),
|
||||
ignore_values=['dn'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for testhostgroup1',
|
||||
command=('hostgroup_find', [], dict(cn=u'testhostgroup1')),
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
summary=u'1 hostgroup matched',
|
||||
result=(
|
||||
{
|
||||
'member host': (u'testhost1.example.com',),
|
||||
'cn': (u'testhostgroup1',),
|
||||
'description': (u'Test hostgroup 1',),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Update testhostgroup1',
|
||||
command=('hostgroup_mod', [u'testhostgroup1'],
|
||||
dict(description=u'Updated hostgroup 1')
|
||||
),
|
||||
expected=dict(
|
||||
value=u'testhostgroup1',
|
||||
summary=u'Modified hostgroup "testhostgroup1"',
|
||||
result=dict(
|
||||
description=(u'Updated hostgroup 1',),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Retrieve testhostgroup1 to verify update',
|
||||
command=('hostgroup_show', [u'testhostgroup1'], {}),
|
||||
expected=dict(
|
||||
value=u'testhostgroup1',
|
||||
summary=None,
|
||||
result={
|
||||
'member host': (u'testhost1.example.com',),
|
||||
'cn': (u'testhostgroup1',),
|
||||
'description': (u'Updated hostgroup 1',)
|
||||
},
|
||||
),
|
||||
ignore_values=['dn'],
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Remove %s from testhostgroup1',
|
||||
command=('hostgroup_remove_member', [u'testhostgroup1'],
|
||||
dict(host=fqdn1)
|
||||
),
|
||||
expected=dict(
|
||||
failed=dict(
|
||||
member=dict(
|
||||
host=tuple(),
|
||||
hostgroup=tuple(),
|
||||
),
|
||||
),
|
||||
completed=1,
|
||||
result={},
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Delete testhostgroup1',
|
||||
command=('hostgroup_del', [u'testhostgroup1'], {}),
|
||||
expected=dict(
|
||||
value=u'testhostgroup1',
|
||||
summary=u'Deleted hostgroup "testhostgroup1"',
|
||||
result=True,
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Delete %s' % fqdn1,
|
||||
command=('host_del', [fqdn1], {}),
|
||||
expected=dict(
|
||||
value=fqdn1,
|
||||
summary=u'Deleted host "%s"' % fqdn1,
|
||||
result=True,
|
||||
),
|
||||
)
|
||||
|
||||
]
|
||||
|
@ -78,9 +78,7 @@ class test_user(Declarative):
|
||||
),
|
||||
summary=u'Added user "tuser1"',
|
||||
),
|
||||
ignore_values=(
|
||||
'ipauniqueid', 'gidnumber'
|
||||
),
|
||||
ignore_values=['ipauniqueid', 'gidnumber', 'dn'],
|
||||
),
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user