diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-04-30 07:29:08 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-05-11 08:14:20 +0200 |
commit | 1565ce3a8c39326f814c9781b3df24c42402c1b5 (patch) | |
tree | 010f750b8f28cdc2cf53c465407cb302e8212880 /tests/test_xmlrpc/test_sudorule_plugin.py | |
parent | f19218f7d87f5847d51f79b5d2850f90b0ae8407 (diff) | |
download | freeipa-1565ce3a8c39326f814c9781b3df24c42402c1b5.tar.gz freeipa-1565ce3a8c39326f814c9781b3df24c42402c1b5.tar.xz freeipa-1565ce3a8c39326f814c9781b3df24c42402c1b5.zip |
Validate externalhost (when added by --addattr/--setattr)
Change the externalhost attribute of hbacrule, netgroup
and sudorule into a full-fledged Parameter, and attach
a validator to it.
The validator is relaxed to allow underscores, so that
some hosts with nonstandard names can be added.
Tests included.
https://fedorahosted.org/freeipa/ticket/2649
Diffstat (limited to 'tests/test_xmlrpc/test_sudorule_plugin.py')
-rw-r--r-- | tests/test_xmlrpc/test_sudorule_plugin.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_xmlrpc/test_sudorule_plugin.py b/tests/test_xmlrpc/test_sudorule_plugin.py index 6aabd2b27..f0e6cd34f 100644 --- a/tests/test_xmlrpc/test_sudorule_plugin.py +++ b/tests/test_xmlrpc/test_sudorule_plugin.py @@ -484,6 +484,23 @@ class test_sudorule(XMLRPC_test): else: assert False + def test_a_sudorule_mod_externalhost_invalid_addattr(self): + """ + Test adding an invalid external host to Sudo rule using + `xmlrpc.sudorule_mod --addattr`. + """ + try: + api.Command['sudorule_mod']( + self.rule_name, + addattr='externalhost=%s' % self.test_invalid_host + ) + except errors.ValidationError, e: + assert unicode(e) == ("invalid 'externalhost': only letters, " + + "numbers, _, and - are allowed. " + + "DNS label may not start or end with -") + else: + assert False + def test_b_sudorule_remove_externalhost(self): """ Test removing an external host from Sudo rule using |