summaryrefslogtreecommitdiffstats
path: root/tests/test_xmlrpc
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-05-18 08:19:45 -0400
committerMartin Kosek <mkosek@redhat.com>2012-05-28 16:03:28 +0200
commitae1257517064362188b893a939cb336c48097256 (patch)
tree562cebc2f059b59584e57b30ab5e8dcac2d5b056 /tests/test_xmlrpc
parent74293426d9b88dad1fffa1762d2be83b1eb45d02 (diff)
downloadfreeipa-ae1257517064362188b893a939cb336c48097256.tar.gz
freeipa-ae1257517064362188b893a939cb336c48097256.tar.xz
freeipa-ae1257517064362188b893a939cb336c48097256.zip
Fix the pwpolicy_find post_callback
Always call convert_time_for_output so time gets reported correctly. That method has its own checks for whether the attributes are present; an additional check is unnecessary. Use a key function for sorting; cmp is deprecated, slower and more complicated. Add a test https://fedorahosted.org/freeipa/ticket/2726
Diffstat (limited to 'tests/test_xmlrpc')
-rw-r--r--tests/test_xmlrpc/test_pwpolicy_plugin.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_xmlrpc/test_pwpolicy_plugin.py b/tests/test_xmlrpc/test_pwpolicy_plugin.py
index 974aa87ff..4f57c23fd 100644
--- a/tests/test_xmlrpc/test_pwpolicy_plugin.py
+++ b/tests/test_xmlrpc/test_pwpolicy_plugin.py
@@ -180,6 +180,21 @@ class test_pwpolicy(XMLRPC_test):
assert_attr_equal(entry, 'cospriority', '3')
def test_c_pwpolicy_find(self):
+ """Test that password policies are sorted and reported properly"""
+ result = api.Command['pwpolicy_find']()['result']
+ assert len(result) == 4
+ assert result[0]['cn'] == (self.group,)
+ assert result[1]['cn'] == (self.group2,)
+ assert result[2]['cn'] == (self.group3,)
+ assert result[3]['cn'] == ('global_policy',)
+
+ # Test that returned values match the arguments
+ # Only test the second and third results; the first one was modified
+ for entry, expected in (result[1], self.kw2), (result[2], self.kw3):
+ for name, value in expected.iteritems():
+ assert_attr_equal(entry, name, str(value))
+
+ def test_c_pwpolicy_find_pkey_only(self):
"""Test that password policies are sorted properly with --pkey-only"""
result = api.Command['pwpolicy_find'](pkey_only=True)['result']
assert len(result) == 4
@@ -225,4 +240,3 @@ class test_pwpolicy(XMLRPC_test):
# Remove the user we created
api.Command['user_del'](self.user)
-