Browse Source

Fix CAA value handling to support tags

pull/1171/head
Ross McFarland 2 years ago
parent
commit
743c3b88db
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
3 changed files with 19 additions and 6 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +2
    -1
      octodns/record/caa.py
  3. +13
    -5
      tests/test_octodns_record_caa.py

+ 4
- 0
CHANGELOG.md View File

@ -1,3 +1,7 @@
## v1.?.? - 2024-??-?? - ???
* Fix CAA rdata parsing to allow values with tags
## v1.7.0 - 2024-04-29 - All the knobs and dials ## v1.7.0 - 2024-04-29 - All the knobs and dials
* Support for specifying per-zone change thresholds, to allow for zones * Support for specifying per-zone change thresholds, to allow for zones


+ 2
- 1
octodns/record/caa.py View File

@ -13,7 +13,8 @@ class CaaValue(EqualityTupleMixin, dict):
@classmethod @classmethod
def parse_rdata_text(cls, value): def parse_rdata_text(cls, value):
try: try:
flags, tag, value = value.split(' ')
# value may contain whitepsace
flags, tag, value = value.split(' ', 2)
except ValueError: except ValueError:
raise RrParseError() raise RrParseError()
try: try:


+ 13
- 5
tests/test_octodns_record_caa.py View File

@ -41,7 +41,7 @@ class TestRecordCaa(TestCase):
self.assertEqual(a_data, a.data) self.assertEqual(a_data, a.data)
b_value = CaaValue( b_value = CaaValue(
{'tag': 'iodef', 'value': 'http://iodef.example.com/'}
{'tag': 'iodef', 'value': 'http://iodef.example.com/; key=value'}
) )
b_data = {'ttl': 30, 'value': b_value} b_data = {'ttl': 30, 'value': b_value}
b = CaaRecord(self.zone, 'b', b_data) b = CaaRecord(self.zone, 'b', b_data)
@ -89,10 +89,6 @@ class TestRecordCaa(TestCase):
with self.assertRaises(RrParseError): with self.assertRaises(RrParseError):
CaaValue.parse_rdata_text('0 tag') CaaValue.parse_rdata_text('0 tag')
# 4th word won't parse
with self.assertRaises(RrParseError):
CaaValue.parse_rdata_text('1 tag value another')
# flags not an int, will parse # flags not an int, will parse
self.assertEqual( self.assertEqual(
{'flags': 'one', 'tag': 'tag', 'value': 'value'}, {'flags': 'one', 'tag': 'tag', 'value': 'value'},
@ -105,12 +101,24 @@ class TestRecordCaa(TestCase):
CaaValue.parse_rdata_text('0 tag 99148c81'), CaaValue.parse_rdata_text('0 tag 99148c81'),
) )
# 4th word will parse, and be part of the value
self.assertEqual(
{'flags': 1, 'tag': 'tag', 'value': 'value another'},
CaaValue.parse_rdata_text('1 tag value another'),
)
# quoted # quoted
self.assertEqual( self.assertEqual(
{'flags': 0, 'tag': 'tag', 'value': '99148c81'}, {'flags': 0, 'tag': 'tag', 'value': '99148c81'},
CaaValue.parse_rdata_text('0 "tag" "99148c81"'), CaaValue.parse_rdata_text('0 "tag" "99148c81"'),
) )
# quoted w/4th word
self.assertEqual(
{'flags': 0, 'tag': 'tag', 'value': '99148c81 key=val'},
CaaValue.parse_rdata_text('0 "tag" "99148c81 key=val"'),
)
zone = Zone('unit.tests.', []) zone = Zone('unit.tests.', [])
a = CaaRecord( a = CaaRecord(
zone, zone,


Loading…
Cancel
Save