Browse Source

Add a validation requiring single value weight=1

pull/715/head
Ross McFarland 5 years ago
parent
commit
e1d262a301
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 32 additions and 1 deletions
  1. +4
    -0
      octodns/record/__init__.py
  2. +28
    -1
      tests/test_octodns_record.py

+ 4
- 0
octodns/record/__init__.py View File

@ -573,6 +573,10 @@ class _DynamicMixin(object):
reasons.append('missing value in pool "{}" '
'value {}'.format(_id, value_num))
if len(values) == 1 and values[0].get('weight', 1) != 1:
reasons.append('pool "{}" has single value with '
'weight!=1'.format(_id))
fallback = pool.get('fallback', None)
if fallback is not None:
if fallback in pools:


+ 28
- 1
tests/test_octodns_record.py View File

@ -3412,7 +3412,7 @@ class TestDynamicRecords(TestCase):
self.assertEquals(['pool "one" is missing values'],
ctx.exception.reasons)
# pool valu not a dict
# pool value not a dict
a_data = {
'dynamic': {
'pools': {
@ -3596,6 +3596,33 @@ class TestDynamicRecords(TestCase):
self.assertEquals(['invalid weight "foo" in pool "three" value 2'],
ctx.exception.reasons)
# single value with weight!=1
a_data = {
'dynamic': {
'pools': {
'one': {
'values': [{
'weight': 12,
'value': '6.6.6.6',
}],
},
},
'rules': [{
'pool': 'one',
}],
},
'ttl': 60,
'type': 'A',
'values': [
'1.1.1.1',
'2.2.2.2',
],
}
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, 'bad', a_data)
self.assertEquals(['pool "one" has single value with weight!=1'],
ctx.exception.reasons)
# invalid fallback
a_data = {
'dynamic': {


Loading…
Cancel
Save