summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/plugins/dns.py7
-rw-r--r--tests/test_xmlrpc/test_dns_plugin.py9
2 files changed, 16 insertions, 0 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index d296f66d2..a975d4dbb 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -888,6 +888,12 @@ class RPRecord(DNSRecord):
rfc = 1183
supported = False
+def _srv_target_validator(ugettext, value):
+ if value == u'.':
+ # service not available
+ return
+ return _domain_name_validator(ugettext, value)
+
class SRVRecord(DNSRecord):
rrtype = 'SRV'
rfc = 2782
@@ -908,6 +914,7 @@ class SRVRecord(DNSRecord):
maxvalue=65535,
),
Str('target',
+ _srv_target_validator,
label=_('Target'),
doc=_('The domain name of the target host or \'.\' if the service is decidedly not available at this domain'),
),
diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py
index b177b9d01..9d83d924e 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -566,6 +566,15 @@ class test_dns(Declarative):
),
dict(
+ desc='Try to add invalid SRV record via parts to zone %r using dnsrecord_add' % (dnszone1),
+ command=('dnsrecord_add', [dnszone1, u'_foo._tcp'], {'srv_part_priority': 0,
+ 'srv_part_weight' : 0,
+ 'srv_part_port' : 123,
+ 'srv_part_target' : u'foo bar'}),
+ expected=errors.ValidationError(name='srv_part_target', error=''),
+ ),
+
+ dict(
desc='Add SRV record to zone %r using dnsrecord_add' % (dnszone1),
command=('dnsrecord_add', [dnszone1, u'_foo._tcp'], {'srvrecord': u"0 100 1234 %s" % dnszone1_mname}),
expected={