Browse Source

Ensure that dynamic and geo can't coexist

pull/312/head
Ross McFarland 7 years ago
parent
commit
d4c4c479c4
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
2 changed files with 55 additions and 0 deletions
  1. +2
    -0
      octodns/record/__init__.py
  2. +53
    -0
      tests/test_octodns_record.py

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

@ -486,6 +486,8 @@ class _DynamicMixin(object):
if 'dynamic' not in data:
return reasons
elif 'geo' in data:
reasons.append('"dynamic" record with "geo" content')
try:
pools = data['dynamic']['pools']


+ 53
- 0
tests/test_octodns_record.py View File

@ -3196,6 +3196,59 @@ class TestDynamicRecords(TestCase):
self.assertEquals(a.dynamic.rules[0], a.dynamic.rules[0])
self.assertNotEquals(a.dynamic.rules[0], c.dynamic.rules[0])
def test_dynamic_and_geo_validation(self):
a_data = {
'dynamic': {
'pools': {
'one': {
'values': [{
'value': '3.3.3.3',
}],
},
'two': {
# Testing out of order value sorting here
'values': [{
'value': '5.5.5.5',
}, {
'value': '4.4.4.4',
}],
},
'three': {
'values': [{
'weight': 10,
'value': '4.4.4.4',
}, {
'weight': 12,
'value': '5.5.5.5',
}],
},
},
'rules': [{
'geos': ['AF', 'EU'],
'pool': 'three',
}, {
'geos': ['NA-US-CA'],
'pool': 'two',
}, {
'pool': 'one',
}],
},
'geo': {
'NA': ['1.2.3.5'],
'NA-US': ['1.2.3.5', '1.2.3.6']
},
'type': 'A',
'ttl': 60,
'values': [
'1.1.1.1',
'2.2.2.2',
],
}
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, 'bad', a_data)
self.assertEquals(['"dynamic" record with "geo" content'],
ctx.exception.reasons)
def test_dynamic_eqs(self):
pool_one = _DynamicPool('one', {


Loading…
Cancel
Save