summaryrefslogtreecommitdiffstats
path: root/tests/test_xmlrpc/test_dns_plugin.py
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-02-28 09:05:01 +0100
committerMartin Kosek <mkosek@redhat.com>2012-02-29 18:52:58 +0100
commit7db1da1d6524aba1319d83bb711c59968557de5f (patch)
tree293ead5ab8f19c36a02f73dc3532cf0f63d281bb /tests/test_xmlrpc/test_dns_plugin.py
parent4e9a2e0983a92829f497bb3ba6b3ab7b6db2967d (diff)
downloadfreeipa-7db1da1d6524aba1319d83bb711c59968557de5f.tar.gz
freeipa-7db1da1d6524aba1319d83bb711c59968557de5f.tar.xz
freeipa-7db1da1d6524aba1319d83bb711c59968557de5f.zip
Improve hostname and domain name validation
DNS plugin did not check DNS zone and DNS record validity and user was thus able to create domains like "foo bar" or other invalid DNS labels which would really confuse both user and bind-dyndb-ldap plugin. This patch at first consolidates hostname/domain name validators so that they use common functions and we don't have regular expressions and other checks defined in several places. These new cleaned validators are then used for zone/record name validation. https://fedorahosted.org/freeipa/ticket/2384
Diffstat (limited to 'tests/test_xmlrpc/test_dns_plugin.py')
-rw-r--r--tests/test_xmlrpc/test_dns_plugin.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py
index 7b1a45321..e3958d23f 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -93,6 +93,19 @@ class test_dns(Declarative):
dict(
+ desc='Try to create zone with invalid name',
+ command=(
+ 'dnszone_add', [u'invalid zone'], {
+ 'idnssoamname': dnszone1_mname,
+ 'idnssoarname': dnszone1_rname,
+ 'ip_address' : u'1.2.3.4',
+ }
+ ),
+ expected=errors.ValidationError(name='idnsname', error=''),
+ ),
+
+
+ dict(
desc='Create zone %r' % dnszone1,
command=(
'dnszone_add', [dnszone1], {
@@ -444,6 +457,13 @@ class test_dns(Declarative):
dict(
+ desc='Try to create record with invalid name in zone %r' % dnszone1,
+ command=('dnsrecord_add', [dnszone1, u'invalid record'], {'arecord': u'127.0.0.1'}),
+ expected=errors.ValidationError(name='idnsname', error=''),
+ ),
+
+
+ dict(
desc='Create record %r in zone %r' % (dnszone1, dnsres1),
command=('dnsrecord_add', [dnszone1, dnsres1], {'arecord': u'127.0.0.1'}),
expected={