On 03/14/2012 05:02 PM, Petr Viktorin wrote:
This patch depends on my patch 0024 (but I can rebase if it needs to be
pushed earlied).

It fixes some of the test bugs that would be found by a fix for
https://fedorahosted.org/freeipa/ticket/2509 (Unknown Command arguments
are allowed (and ignored)).

As you can see it's quite easy, without validation, to use a wrong name
for an argument.

Unfortunately, some of our plugins (automount, dns, delegation,
permission, selfservice) take advantage of the current sloppy
validation, so they'll need some untangling for 3.x to make them more
robust and testable. For now I'm just touching the tests, so we don't
get new bugs in production code.


Rebased onto current master


--
PetrĀ³
From c4b811c84b9427e7754a46467c49c6b67a96b130 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 14 Mar 2012 11:33:41 -0400
Subject: [PATCH] Use valid argument names in tests

Some of our tests used unintended extra options, or options with
misspelled, wrongly copy-pasted or otherwise bad names. These are
ignored, so the intended argument was treated as missing. The test
itself can still pass but may be rendered ineffective or fragile.

This only fixes those of such errors that appear in the test suite.
Fixing code in the framework and actual rejecting of unknown
arguments is deferred for later (ticket #2509).
---
 tests/test_xmlrpc/test_automember_plugin.py |    5 +----
 tests/test_xmlrpc/test_delegation_plugin.py |    2 +-
 tests/test_xmlrpc/test_hbac_plugin.py       |    6 +++---
 tests/test_xmlrpc/test_hbactest_plugin.py   |    2 +-
 tests/test_xmlrpc/test_host_plugin.py       |    2 +-
 tests/test_xmlrpc/test_pwpolicy.py          |    2 +-
 tests/test_xmlrpc/test_role_plugin.py       |    2 +-
 tests/test_xmlrpc/test_sudorule_plugin.py   |    6 +++---
 8 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/tests/test_xmlrpc/test_automember_plugin.py b/tests/test_xmlrpc/test_automember_plugin.py
index 1241bd669c597c1363b86c4f378472031c3e6682..265c3af861b0bfd5ffa102e5fbb3a81857292996 100644
--- a/tests/test_xmlrpc/test_automember_plugin.py
+++ b/tests/test_xmlrpc/test_automember_plugin.py
@@ -718,10 +718,7 @@ class test_automember(Declarative):
         dict(
             desc='Retrieve default automember group for groups',
             command=(
-                'automember_default_group_show', [], dict(
-                    type=u'group',
-                    automemberdefaultgroup=defaultgroup1,
-                )
+                'automember_default_group_show', [], dict(type=u'group')
             ),
             expected=dict(
                 result=dict(
diff --git a/tests/test_xmlrpc/test_delegation_plugin.py b/tests/test_xmlrpc/test_delegation_plugin.py
index 5030f8bc26e869c0553d331c290e481a94514c9e..c4473b9d41d0ef4f728209eaeaf00055aef727ac 100644
--- a/tests/test_xmlrpc/test_delegation_plugin.py
+++ b/tests/test_xmlrpc/test_delegation_plugin.py
@@ -45,7 +45,7 @@ class test_delegation(Declarative):
 
         dict(
             desc='Try to update non-existent %r' % delegation1,
-            command=('delegation_mod', [delegation1], dict(description=u'Foo')),
+            command=('delegation_mod', [delegation1], dict(group=u'admins')),
             expected=errors.NotFound(reason='no such entry'),
         ),
 
diff --git a/tests/test_xmlrpc/test_hbac_plugin.py b/tests/test_xmlrpc/test_hbac_plugin.py
index bbaf9d25b5b1bca524bc4a02a16c484d6e0ebc99..58265dc07c729fbaca0111807d511b0e906fc095 100644
--- a/tests/test_xmlrpc/test_hbac_plugin.py
+++ b/tests/test_xmlrpc/test_hbac_plugin.py
@@ -123,7 +123,7 @@ def test_6_hbacrule_find(self):
         Test searching for HBAC rules using `xmlrpc.hbacrule_find`.
         """
         ret = api.Command['hbacrule_find'](
-            name=self.rule_name, accessruletype=self.rule_type,
+            cn=self.rule_name, accessruletype=self.rule_type,
             description=self.rule_desc_mod
         )
         assert ret['truncated'] is False
@@ -155,7 +155,7 @@ def test_7_hbacrule_init_testing_data(self):
             self.test_sourcehostgroup, description=u'desc'
         )
         self.failsafe_add(api.Object.hbacsvc,
-            self.test_service, description=u'desc', force=True
+            self.test_service, description=u'desc',
         )
 
     def test_8_hbacrule_add_user(self):
@@ -424,7 +424,7 @@ def test_f_hbacrule_exclusiveuser(self):
         """
         api.Command['hbacrule_mod'](self.rule_name, usercategory=u'all')
         try:
-            api.Command['hbacrule_add_user'](self.rule_name, users=u'admin')
+            api.Command['hbacrule_add_user'](self.rule_name, user=u'admin')
         finally:
             api.Command['hbacrule_mod'](self.rule_name, usercategory=u'')
 
diff --git a/tests/test_xmlrpc/test_hbactest_plugin.py b/tests/test_xmlrpc/test_hbactest_plugin.py
index 5d829b14c4fa6e7d96db36b64afe38a171096142..bc12e8974dc4591afa3b4a5f9e68df9ed32e2231 100644
--- a/tests/test_xmlrpc/test_hbactest_plugin.py
+++ b/tests/test_xmlrpc/test_hbactest_plugin.py
@@ -79,7 +79,7 @@ def test_0_hbactest_addrules(self):
             self.test_sourcehostgroup, description=u'desc'
         )
         self.failsafe_add(api.Object.hbacsvc,
-            self.test_service, description=u'desc', force=True
+            self.test_service, description=u'desc'
         )
 
         for i in [0,1,2,3]:
diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py
index 5e49e2bade1a585d5c724d9f7f4fb351d34f3091..2ef99c4a4298df7fe21bcf80b336c8cca5925fd3 100644
--- a/tests/test_xmlrpc/test_host_plugin.py
+++ b/tests/test_xmlrpc/test_host_plugin.py
@@ -123,7 +123,7 @@ class test_host(Declarative):
             command=('host_add', [fqdn1],
                 dict(
                     description=u'Test host 1',
-                    localityname=u'Undisclosed location 1',
+                    locality=u'Undisclosed location 1',
                     force=True,
                 ),
             ),
diff --git a/tests/test_xmlrpc/test_pwpolicy.py b/tests/test_xmlrpc/test_pwpolicy.py
index c0ead9f78443ed82de2a68873e87162daa0ccbb3..6b5d64cf37d33fd576cfea12f4bff57e81f7b15c 100644
--- a/tests/test_xmlrpc/test_pwpolicy.py
+++ b/tests/test_xmlrpc/test_pwpolicy.py
@@ -49,7 +49,7 @@ def test_1_pwpolicy_add(self):
         self.failsafe_add(
             api.Object.user, self.user, givenname=u'Test', sn=u'User'
         )
-        api.Command.group_add_member(self.group, users=self.user)
+        api.Command.group_add_member(self.group, user=self.user)
 
         entry = api.Command['pwpolicy_add'](self.group, **self.kw)['result']
         assert_attr_equal(entry, 'krbminpwdlife', '30')
diff --git a/tests/test_xmlrpc/test_role_plugin.py b/tests/test_xmlrpc/test_role_plugin.py
index 6f6de32147e0fe969cfc63ba3ae42bffdf64eb8a..8a5dede232e888261a0994023ba08dbc531b1b0a 100644
--- a/tests/test_xmlrpc/test_role_plugin.py
+++ b/tests/test_xmlrpc/test_role_plugin.py
@@ -81,7 +81,7 @@ class test_role(Declarative):
 
         dict(
             desc='Try to rename non-existent %r' % role1,
-            command=('role_del', [role1], dict(setattr=u'cn=%s' % renamedrole1)),
+            command=('role_mod', [role1], dict(setattr=u'cn=%s' % renamedrole1)),
             expected=errors.NotFound(reason='no such entry'),
         ),
 
diff --git a/tests/test_xmlrpc/test_sudorule_plugin.py b/tests/test_xmlrpc/test_sudorule_plugin.py
index 2a597c37bea3d621941b66c2b7bec0cf8600be28..7c45256eca281c366a403e922ff6081c2581629e 100644
--- a/tests/test_xmlrpc/test_sudorule_plugin.py
+++ b/tests/test_xmlrpc/test_sudorule_plugin.py
@@ -97,7 +97,7 @@ def test_6_sudorule_find(self):
         Test searching for Sudo rules using `xmlrpc.sudorule_find`.
         """
         ret = api.Command['sudorule_find'](
-            name=self.rule_name,
+            cn=self.rule_name,
             description=self.rule_desc_mod
         )
         assert ret['truncated'] is False
@@ -131,7 +131,7 @@ def test_7_sudorule_init_testing_data(self):
             self.test_sudodenycmdgroup, description=u'desc'
         )
         self.failsafe_add(api.Object.sudocmd,
-            self.test_command, description=u'desc', force=True
+            self.test_command, description=u'desc'
         )
 
     def test_8_sudorule_add_user(self):
@@ -592,7 +592,7 @@ def test_i_sudorule_exclusiverunas(self):
         """
         api.Command['sudorule_mod'](self.rule_name, ipasudorunasusercategory=u'all')
         try:
-            api.Command['sudorule_add_runasuser'](self.rule_name, sudocmd=self.test_user)
+            api.Command['sudorule_add_runasuser'](self.rule_name, user=self.test_user)
         finally:
             api.Command['sudorule_mod'](self.rule_name, ipasudorunasusercategory=u'')
 
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to