diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-12-15 13:36:14 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-12-16 15:54:55 -0700 |
commit | 8ae0f9c8aadeacb16142198b65e368d2aa7926f4 (patch) | |
tree | ed2500b42ae60d1cd953acdc5454278328ccd2e1 /tests/test_xmlrpc | |
parent | c334ec45849100b454bf775ba2ecaa05c6106546 (diff) | |
download | freeipa-8ae0f9c8aadeacb16142198b65e368d2aa7926f4.tar.gz freeipa-8ae0f9c8aadeacb16142198b65e368d2aa7926f4.tar.xz freeipa-8ae0f9c8aadeacb16142198b65e368d2aa7926f4.zip |
host and hostgroup summary messages, declarative tests; fix tests for 'dn'
Diffstat (limited to 'tests/test_xmlrpc')
-rw-r--r-- | tests/test_xmlrpc/objectclasses.py | 40 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_group_plugin.py | 4 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_host_plugin.py | 325 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_hostgroup_plugin.py | 336 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_user_plugin.py | 4 |
5 files changed, 488 insertions, 221 deletions
diff --git a/tests/test_xmlrpc/objectclasses.py b/tests/test_xmlrpc/objectclasses.py new file mode 100644 index 000000000..58a3671e9 --- /dev/null +++ b/tests/test_xmlrpc/objectclasses.py @@ -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', +) diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py index 89947d22d..0469cc922 100644 --- a/tests/test_xmlrpc/test_group_plugin.py +++ b/tests/test_xmlrpc/test_group_plugin.py @@ -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( diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py index 009e98eb6..dab96c94c 100644 --- a/tests/test_xmlrpc/test_host_plugin.py +++ b/tests/test_xmlrpc/test_host_plugin.py @@ -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 - - -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} - - 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) - - 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) - - 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) - - 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) - - 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) - - 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 +from ipalib import api, errors +from tests.test_xmlrpc.xmlrpc_test import Declarative +from tests.test_xmlrpc import objectclasses + + +fqdn1 = u'testhost1.%s' % api.env.domain + + +class test_host(Declarative): + + cleanup_commands = [ + ('host_del', [fqdn1], {}), + ] + + tests = [ + + 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'), + ), + + + 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'), + ), + + ] diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py index 7fa227a28..76a55cca9 100644 --- a/tests/test_xmlrpc/test_hostgroup_plugin.py +++ b/tests/test_xmlrpc/test_hostgroup_plugin.py @@ -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 - - -class test_hostgroup(XMLRPC_test): - """ - Test the `hostgroup` plugin. - """ - cn = u'testgroup' - description = u'Test host group' - kw = {'cn': cn, 'description': description, 'raw': True} - - 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') - - 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) - - 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 - - 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) - - 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) - - # 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 - - 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 - - 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 +from ipalib import api, errors +from tests.test_xmlrpc.xmlrpc_test import Declarative +from tests.test_xmlrpc import objectclasses + + +fqdn1 = u'testhost1.%s' % api.env.domain + + +class test_hostgroup(Declarative): + + cleanup_commands = [ + ('hostgroup_del', [u'testhostgroup1'], {}), + ('host_del', [fqdn1], {}), + ] + + tests=[ + + dict( + desc='Try to retrieve non-existent testhostgroup1', + command=('hostgroup_show', [u'testhostgroup1'], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + 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'), + ), + + + dict( + desc='Try to delete non-existent testhostgroup1', + command=('hostgroup_del', [u'testhostgroup1'], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + 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'], + ), + + + 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, + ), + ) + + ] diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py index 3fc613aa9..b45300ce1 100644 --- a/tests/test_xmlrpc/test_user_plugin.py +++ b/tests/test_xmlrpc/test_user_plugin.py @@ -78,9 +78,7 @@ class test_user(Declarative): ), summary=u'Added user "tuser1"', ), - ignore_values=( - 'ipauniqueid', 'gidnumber' - ), + ignore_values=['ipauniqueid', 'gidnumber', 'dn'], ), |