diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-03-22 17:35:39 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-03-22 19:30:13 +0100 |
commit | 5b8e1e8c62bb899145e3572dc8bfa7cb0570fd05 (patch) | |
tree | c429d57b979a81cae5fcb938dc1d36926b142ce3 /tests | |
parent | 735618a1c6aee05d1c6455320da46fc52c85ca8c (diff) | |
download | freeipa-5b8e1e8c62bb899145e3572dc8bfa7cb0570fd05.tar.gz freeipa-5b8e1e8c62bb899145e3572dc8bfa7cb0570fd05.tar.xz freeipa-5b8e1e8c62bb899145e3572dc8bfa7cb0570fd05.zip |
Harden raw record processing in DNS plugin
There were cases where DNS plugin was too tolerant in a raw DNS
record option (--<rrtype-rec) processing. It let people specify
DNS record parts options in dnsrecord-mod operations for some
record without specifying the record that should be updated. It
also ignored DNS record parts in dnsrecord-add operation when the
raw DNS record value was already set via --<rrtype>-rec option.
This patch hardens the processing and returns error in both
described cases to make the processes clearer and more robust.
All these use cases were also covered by new unit tests.
https://fedorahosted.org/freeipa/ticket/2551
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_xmlrpc/test_dns_plugin.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py index 93093ec8a..1e5ab7917 100644 --- a/tests/test_xmlrpc/test_dns_plugin.py +++ b/tests/test_xmlrpc/test_dns_plugin.py @@ -622,6 +622,18 @@ class test_dns(Declarative): ), dict( + desc='Try to add SRV record to zone %r both via parts and a raw value' % (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.', + 'srvrecord': [u"1 100 1234 %s" \ + % dnszone1_mname]}), + expected=errors.ValidationError(name='srv_target', + error='Raw value of a DNS record was already set by a_rec option'), + ), + + 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={ @@ -637,6 +649,40 @@ class test_dns(Declarative): ), dict( + desc='Try to modify SRV record in zone %r without specifying modified value' % (dnszone1), + command=('dnsrecord_mod', [dnszone1, u'_foo._tcp'], {'srv_part_priority': 1,}), + expected=errors.RequirementError(name='srvrecord'), + ), + + dict( + desc='Try to modify SRV record in zone %r with non-existent modified value' % (dnszone1), + command=('dnsrecord_mod', [dnszone1, u'_foo._tcp'], {'srv_part_priority': 1, + 'srvrecord' : [u"0 100 1234 does.not.exist."] }), + expected=errors.AttrValueNotFound(attr='SRV', value=u'0 100 1234 ns1.dnszone.test.'), + ), + + dict( + desc='Try to modify SRV record in zone %r with invalid part value' % (dnszone1), + command=('dnsrecord_mod', [dnszone1, u'_foo._tcp'], {'srv_part_priority': 100000, + 'srvrecord' : [u"0 100 1234 %s" % dnszone1_mname] }), + expected=errors.ValidationError(name='srv_priority', error=u'can be at most 65535'), + ), + + dict( + desc='Modify SRV record in zone %r using parts' % (dnszone1), + command=('dnsrecord_mod', [dnszone1, u'_foo._tcp'], {'srv_part_priority': 1, + 'srvrecord' : [u"0 100 1234 %s" % dnszone1_mname] }), + expected={ + 'value': u'_foo._tcp', + 'summary': None, + 'result': { + 'idnsname': [u'_foo._tcp'], + 'srvrecord': [u"1 100 1234 %s" % dnszone1_mname], + }, + }, + ), + + dict( desc='Try to add invalid LOC record to zone %r using dnsrecord_add' % (dnszone1), command=('dnsrecord_add', [dnszone1, u'@'], {'locrecord': u"91 11 42.4 N 16 36 29.6 E 227.64" }), expected=errors.ValidationError(name='locrecord', error=''), |