|
|
@ -3075,7 +3075,7 @@ class TestDynamicRecords(TestCase): |
|
|
'invalid IPv4 address "blip"', |
|
|
'invalid IPv4 address "blip"', |
|
|
], ctx.exception.reasons) |
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# missing rules |
|
|
|
|
|
|
|
|
# missing rules, and unused pools |
|
|
a_data = { |
|
|
a_data = { |
|
|
'dynamic': { |
|
|
'dynamic': { |
|
|
'pools': { |
|
|
'pools': { |
|
|
@ -3102,7 +3102,10 @@ class TestDynamicRecords(TestCase): |
|
|
} |
|
|
} |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
self.assertEquals(['missing rules'], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
self.assertEquals([ |
|
|
|
|
|
'missing rules', |
|
|
|
|
|
'unused pools: "one", "two"', |
|
|
|
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# empty rules |
|
|
# empty rules |
|
|
a_data = { |
|
|
a_data = { |
|
|
@ -3132,7 +3135,10 @@ class TestDynamicRecords(TestCase): |
|
|
} |
|
|
} |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
self.assertEquals(['missing rules'], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
self.assertEquals([ |
|
|
|
|
|
'missing rules', |
|
|
|
|
|
'unused pools: "one", "two"', |
|
|
|
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# rules not a list/tuple |
|
|
# rules not a list/tuple |
|
|
a_data = { |
|
|
a_data = { |
|
|
@ -3162,7 +3168,10 @@ class TestDynamicRecords(TestCase): |
|
|
} |
|
|
} |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
self.assertEquals(['rules must be a list'], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
self.assertEquals([ |
|
|
|
|
|
'rules must be a list', |
|
|
|
|
|
'unused pools: "one", "two"', |
|
|
|
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# rule without pool |
|
|
# rule without pool |
|
|
a_data = { |
|
|
a_data = { |
|
|
@ -3196,7 +3205,10 @@ class TestDynamicRecords(TestCase): |
|
|
} |
|
|
} |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
self.assertEquals(['rule 1 missing pool'], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
self.assertEquals([ |
|
|
|
|
|
'rule 1 missing pool', |
|
|
|
|
|
'unused pools: "two"', |
|
|
|
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# rule with non-string pools |
|
|
# rule with non-string pools |
|
|
a_data = { |
|
|
a_data = { |
|
|
@ -3231,8 +3243,10 @@ class TestDynamicRecords(TestCase): |
|
|
} |
|
|
} |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
self.assertEquals(['rule 1 invalid pool "[]"'], |
|
|
|
|
|
ctx.exception.reasons) |
|
|
|
|
|
|
|
|
self.assertEquals([ |
|
|
|
|
|
'rule 1 invalid pool "[]"', |
|
|
|
|
|
'unused pools: "two"', |
|
|
|
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# rule references non-existent pool |
|
|
# rule references non-existent pool |
|
|
a_data = { |
|
|
a_data = { |
|
|
@ -3267,8 +3281,10 @@ class TestDynamicRecords(TestCase): |
|
|
} |
|
|
} |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
Record.new(self.zone, 'bad', a_data) |
|
|
self.assertEquals(["rule 1 undefined pool \"non-existent\""], |
|
|
|
|
|
ctx.exception.reasons) |
|
|
|
|
|
|
|
|
self.assertEquals([ |
|
|
|
|
|
"rule 1 undefined pool \"non-existent\"", |
|
|
|
|
|
'unused pools: "two"', |
|
|
|
|
|
], ctx.exception.reasons) |
|
|
|
|
|
|
|
|
# rule with invalid geos |
|
|
# rule with invalid geos |
|
|
a_data = { |
|
|
a_data = { |
|
|
@ -3377,6 +3393,45 @@ class TestDynamicRecords(TestCase): |
|
|
self.assertEquals(['rule 2 duplicate default'], |
|
|
self.assertEquals(['rule 2 duplicate default'], |
|
|
ctx.exception.reasons) |
|
|
ctx.exception.reasons) |
|
|
|
|
|
|
|
|
|
|
|
# repeated pool in rules |
|
|
|
|
|
a_data = { |
|
|
|
|
|
'dynamic': { |
|
|
|
|
|
'pools': { |
|
|
|
|
|
'one': { |
|
|
|
|
|
'values': [{ |
|
|
|
|
|
'value': '3.3.3.3', |
|
|
|
|
|
}] |
|
|
|
|
|
}, |
|
|
|
|
|
'two': { |
|
|
|
|
|
'values': [{ |
|
|
|
|
|
'value': '4.4.4.4', |
|
|
|
|
|
}, { |
|
|
|
|
|
'value': '5.5.5.5', |
|
|
|
|
|
}] |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
'rules': [{ |
|
|
|
|
|
'geos': ['EU'], |
|
|
|
|
|
'pool': 'two', |
|
|
|
|
|
}, { |
|
|
|
|
|
'geos': ['AF'], |
|
|
|
|
|
'pool': 'one', |
|
|
|
|
|
}, { |
|
|
|
|
|
'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(['rule 3 invalid, target pool "one" reused'], |
|
|
|
|
|
ctx.exception.reasons) |
|
|
|
|
|
|
|
|
def test_dynamic_lenient(self): |
|
|
def test_dynamic_lenient(self): |
|
|
# Missing pools |
|
|
# Missing pools |
|
|
a_data = { |
|
|
a_data = { |
|
|
|