Browse Source

Merge branch 'main' into log-processors

pull/1134/head
Ross McFarland 2 years ago
committed by GitHub
parent
commit
72ecc995a8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
12 changed files with 62 additions and 26 deletions
  1. +6
    -0
      CHANGELOG.md
  2. +4
    -7
      octodns/record/base.py
  3. +0
    -2
      octodns/record/caa.py
  4. +0
    -2
      octodns/record/loc.py
  5. +0
    -2
      octodns/record/mx.py
  6. +0
    -2
      octodns/record/naptr.py
  7. +0
    -2
      octodns/record/srv.py
  8. +0
    -2
      octodns/record/sshfp.py
  9. +1
    -3
      octodns/record/target.py
  10. +0
    -2
      octodns/record/tlsa.py
  11. +0
    -2
      octodns/record/urlfwd.py
  12. +51
    -0
      tests/test_octodns_record.py

+ 6
- 0
CHANGELOG.md View File

@ -8,6 +8,12 @@
* Support added for config env variable expansion on nested levels, not just
top-level provider/processor keys
* _ChunkedValue ASCII validation added, SPF & TXT
* Re-work value/values handling to always try and do the "right" thing based on
the content, so both singular values and lists will be handled identically
regardless of whether the key is value or values. This may result in
changes/fixes on the first sync after updating IFF you currently have
`values: a-single-thing`, which would have previously been pushed up as bunch
of single character values.
## v1.4.0 - 2023-12-04 - Minor Meta


+ 4
- 7
octodns/record/base.py View File

@ -278,6 +278,7 @@ class ValuesMixin(object):
reasons = super().validate(name, fqdn, data)
values = data.get('values', data.get('value', []))
values = values if isinstance(values, (list, tuple)) else [values]
reasons.extend(cls._value_type.validate(values, cls._type))
@ -293,13 +294,9 @@ class ValuesMixin(object):
def __init__(self, zone, name, data, source=None, context=None):
super().__init__(zone, name, data, source=source, context=context)
try:
values = data['values']
except KeyError:
try:
values = [data['value']]
except KeyError:
values = []
values = data.get('values', data.get('value', []))
values = values if isinstance(values, (list, tuple)) else [values]
self.values = sorted(self._value_type.process(values))
def changes(self, other, target):


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

@ -26,8 +26,6 @@ class CaaValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:


+ 0
- 2
octodns/record/loc.py View File

@ -110,8 +110,6 @@ class LocValue(EqualityTupleMixin, dict):
direction_keys = ['lat_direction', 'long_direction']
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
for key in int_keys:


+ 0
- 2
octodns/record/mx.py View File

@ -26,8 +26,6 @@ class MxValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:


+ 0
- 2
octodns/record/naptr.py View File

@ -43,8 +43,6 @@ class NaptrValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:


+ 0
- 2
octodns/record/srv.py View File

@ -41,8 +41,6 @@ class SrvValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
# TODO: validate algorithm and fingerprint_type values


+ 0
- 2
octodns/record/sshfp.py View File

@ -34,8 +34,6 @@ class SshfpValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:


+ 1
- 3
octodns/record/target.py View File

@ -51,10 +51,8 @@ class _TargetsValue(str):
@classmethod
def validate(cls, data, _type):
if not data:
if not data or all(not d for d in data):
return ['missing value(s)']
elif not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
value = idna_encode(value)


+ 0
- 2
octodns/record/tlsa.py View File

@ -41,8 +41,6 @@ class TlsaValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:


+ 0
- 2
octodns/record/urlfwd.py View File

@ -13,8 +13,6 @@ class UrlfwdValue(EqualityTupleMixin, dict):
@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:


+ 51
- 0
tests/test_octodns_record.py View File

@ -683,6 +683,57 @@ class TestRecordValidation(TestCase):
lenient=True,
)
def test_values_and_value(self):
# value w/one
r = Record.new(
self.zone, 'thing', {'type': 'TXT', 'ttl': 42, 'value': 'just one'}
)
self.assertEqual(['just one'], r.values)
# value w/multiple
r = Record.new(
self.zone,
'thing',
{'type': 'TXT', 'ttl': 42, 'value': ['the first', 'the second']},
)
self.assertEqual(['the first', 'the second'], r.values)
# values w/one
r = Record.new(
self.zone, 'thing', {'type': 'TXT', 'ttl': 42, 'values': 'just one'}
)
self.assertEqual(['just one'], r.values)
# values w/multiple
r = Record.new(
self.zone,
'thing',
{'type': 'TXT', 'ttl': 42, 'values': ['the first', 'the second']},
)
self.assertEqual(['the first', 'the second'], r.values)
# tuples work too
r = Record.new(
self.zone,
'thing',
{'type': 'TXT', 'ttl': 42, 'values': ('the first', 'the second')},
)
self.assertEqual(['the first', 'the second'], r.values)
# values is preferred over value
# values w/multiple
r = Record.new(
self.zone,
'thing',
{
'type': 'TXT',
'ttl': 42,
'values': ['the first', 'the second'],
'value': ['not used', 'not used'],
},
)
self.assertEqual(['the first', 'the second'], r.values)
def test_validation_context(self):
# fails validation, no context
with self.assertRaises(ValidationError) as ctx:


Loading…
Cancel
Save