diff options
Diffstat (limited to 'tests/test_xmlrpc')
-rw-r--r-- | tests/test_xmlrpc/test_group_plugin.py | 22 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_host_plugin.py | 42 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_role_plugin.py | 10 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_user_plugin.py | 36 |
4 files changed, 110 insertions, 0 deletions
diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py index 86c0d90d..3ef60f69 100644 --- a/tests/test_xmlrpc/test_group_plugin.py +++ b/tests/test_xmlrpc/test_group_plugin.py @@ -602,6 +602,28 @@ class test_group(Declarative): expected=errors.ValidationError(name='cn', error='may only include letters, numbers, _, -, . and $'), ), + # The assumption on these next 4 tests is that if we don't get a + # validation error then the request was processed normally. + dict( + desc='Test that validation is disabled on mods', + command=('group_mod', [invalidgroup1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on deletes', + command=('group_del', [invalidgroup1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on show', + command=('group_show', [invalidgroup1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + ##### managed entry tests dict( diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py index 0323ac39..4f24b6e3 100644 --- a/tests/test_xmlrpc/test_host_plugin.py +++ b/tests/test_xmlrpc/test_host_plugin.py @@ -47,6 +47,7 @@ dn3 = DN(('fqdn',fqdn3),('cn','computers'),('cn','accounts'), fqdn4 = u'testhost2.lab.%s' % api.env.domain dn4 = DN(('fqdn',fqdn4),('cn','computers'),('cn','accounts'), api.env.basedn) +invalidfqdn1 = u'foo_bar.lab.%s' % api.env.domain # We can use the same cert we generated for the service tests fd = open('tests/test_xmlrpc/service.crt', 'r') @@ -670,4 +671,45 @@ class test_host(Declarative): expected=errors.ValidationError(name='fqdn', error='An IPA master host cannot be deleted'), ), + dict( + desc='Test that validation is enabled on adds', + command=('host_add', [invalidfqdn1], {}), + expected=errors.ValidationError(name='fqdn', error='may only include letters, numbers, and -'), + ), + + + # The assumption on these next 4 tests is that if we don't get a + # validation error then the request was processed normally. + dict( + desc='Test that validation is disabled on mods', + command=('host_mod', [invalidfqdn1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on deletes', + command=('host_del', [invalidfqdn1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on show', + command=('host_show', [invalidfqdn1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on find', + command=('host_find', [invalidfqdn1], {}), + expected=dict( + count=0, + truncated=False, + summary=u'0 hosts matched', + result=[], + ), + ), + ] diff --git a/tests/test_xmlrpc/test_role_plugin.py b/tests/test_xmlrpc/test_role_plugin.py index 9c405cff..f871e268 100644 --- a/tests/test_xmlrpc/test_role_plugin.py +++ b/tests/test_xmlrpc/test_role_plugin.py @@ -33,6 +33,7 @@ role1 = u'test-role-1' role1_dn = DN(('cn',role1),api.env.container_rolegroup, api.env.basedn) renamedrole1 = u'test-role' +invalidrole1 = u' whitespace ' role2 = u'test-role-2' role2_dn = DN(('cn',role2),api.env.container_rolegroup, @@ -101,6 +102,15 @@ class test_role(Declarative): dict( + desc='Create invalid %r' % invalidrole1, + command=('role_add', [invalidrole1], + dict(description=u'role desc 1') + ), + expected=errors.ValidationError(name='cn', error='Leading and trailing spaces are not allowed'), + ), + + + dict( desc='Create %r' % role1, command=('role_add', [role1], dict(description=u'role desc 1') diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py index d1cdb2f9..b21737f8 100644 --- a/tests/test_xmlrpc/test_user_plugin.py +++ b/tests/test_xmlrpc/test_user_plugin.py @@ -643,6 +643,42 @@ class test_user(Declarative): expected=errors.ValidationError(name='uid', error='can be at most 33 characters'), ), + + # The assumption on these next 4 tests is that if we don't get a + # validation error then the request was processed normally. + dict( + desc='Test that validation is disabled on deletes', + command=('user_del', [invaliduser1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on show', + command=('user_show', [invaliduser1], {}), + expected=errors.NotFound(reason='no such entry'), + ), + + + dict( + desc='Test that validation is disabled on find', + command=('user_find', [invaliduser1], {}), + expected=dict( + count=0, + truncated=False, + summary=u'0 users matched', + result=[], + ), + ), + + + dict( + desc='Try to rename to invalid username %r' % user1, + command=('user_mod', [user1], dict(rename=invaliduser1)), + expected=errors.ValidationError(name='uid', error='may only include letters, numbers, _, -, . and $'), + ), + + dict( desc='Create %r' % group1, command=( |