mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge branch 'master' into nsone-country-filter-chain
This commit is contained in:
@@ -23,7 +23,7 @@ a:
|
||||
rules:
|
||||
- geos:
|
||||
- EU-GB
|
||||
pool: iad
|
||||
pool: lax
|
||||
- geos:
|
||||
- EU
|
||||
pool: ams
|
||||
@@ -60,7 +60,7 @@ aaaa:
|
||||
rules:
|
||||
- geos:
|
||||
- EU-GB
|
||||
pool: iad
|
||||
pool: lax
|
||||
- geos:
|
||||
- EU
|
||||
pool: ams
|
||||
@@ -96,7 +96,7 @@ cname:
|
||||
rules:
|
||||
- geos:
|
||||
- EU-GB
|
||||
pool: iad
|
||||
pool: lax
|
||||
- geos:
|
||||
- EU
|
||||
pool: ams
|
||||
|
||||
@@ -29,7 +29,7 @@ a:
|
||||
rules:
|
||||
- geos:
|
||||
- EU-GB
|
||||
pool: iad
|
||||
pool: lax
|
||||
- geos:
|
||||
- EU
|
||||
pool: ams
|
||||
|
||||
@@ -29,7 +29,7 @@ aaaa:
|
||||
rules:
|
||||
- geos:
|
||||
- EU-GB
|
||||
pool: iad
|
||||
pool: lax
|
||||
- geos:
|
||||
- EU
|
||||
pool: ams
|
||||
|
||||
@@ -27,7 +27,7 @@ cname:
|
||||
rules:
|
||||
- geos:
|
||||
- EU-GB
|
||||
pool: iad
|
||||
pool: lax
|
||||
- geos:
|
||||
- EU
|
||||
pool: ams
|
||||
|
||||
Vendored
@@ -13,12 +13,13 @@ from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.record import Record
|
||||
from octodns.provider.fastdns import AkamaiProvider
|
||||
from octodns.provider.edgedns import AkamaiProvider
|
||||
from octodns.provider.fastdns import AkamaiProvider as LegacyAkamaiProvider
|
||||
from octodns.provider.yaml import YamlProvider
|
||||
from octodns.zone import Zone
|
||||
|
||||
|
||||
class TestFastdnsProvider(TestCase):
|
||||
class TestEdgeDnsProvider(TestCase):
|
||||
expected = Zone('unit.tests.', [])
|
||||
source = YamlProvider('test', join(dirname(__file__), 'config'))
|
||||
source.populate(expected)
|
||||
@@ -71,7 +72,7 @@ class TestFastdnsProvider(TestCase):
|
||||
# No diffs == no changes
|
||||
with requests_mock() as mock:
|
||||
|
||||
with open('tests/fixtures/fastdns-records.json') as fh:
|
||||
with open('tests/fixtures/edgedns-records.json') as fh:
|
||||
mock.get(ANY, text=fh.read())
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
@@ -95,7 +96,7 @@ class TestFastdnsProvider(TestCase):
|
||||
# tests create update delete through previous state config json
|
||||
with requests_mock() as mock:
|
||||
|
||||
with open('tests/fixtures/fastdns-records-prev.json') as fh:
|
||||
with open('tests/fixtures/edgedns-records-prev.json') as fh:
|
||||
mock.get(ANY, text=fh.read())
|
||||
|
||||
plan = provider.plan(self.expected)
|
||||
@@ -108,7 +109,7 @@ class TestFastdnsProvider(TestCase):
|
||||
|
||||
# Test against a zone that doesn't exist yet
|
||||
with requests_mock() as mock:
|
||||
with open('tests/fixtures/fastdns-records-prev-other.json') as fh:
|
||||
with open('tests/fixtures/edgedns-records-prev-other.json') as fh:
|
||||
mock.get(ANY, status_code=404)
|
||||
|
||||
plan = provider.plan(self.expected)
|
||||
@@ -121,7 +122,7 @@ class TestFastdnsProvider(TestCase):
|
||||
|
||||
# Test against a zone that doesn't exist yet, but gid not provided
|
||||
with requests_mock() as mock:
|
||||
with open('tests/fixtures/fastdns-records-prev-other.json') as fh:
|
||||
with open('tests/fixtures/edgedns-records-prev-other.json') as fh:
|
||||
mock.get(ANY, status_code=404)
|
||||
provider = AkamaiProvider("test", "s", "akam.com", "atok", "ctok",
|
||||
"cid")
|
||||
@@ -149,3 +150,9 @@ class TestFastdnsProvider(TestCase):
|
||||
except NameError as e:
|
||||
expected = "contractId not specified to create zone"
|
||||
self.assertEquals(text_type(e), expected)
|
||||
|
||||
|
||||
class TestDeprecatedAkamaiProvider(TestCase):
|
||||
|
||||
def test_equivilent(self):
|
||||
self.assertEquals(LegacyAkamaiProvider, AkamaiProvider)
|
||||
@@ -3075,7 +3075,7 @@ class TestDynamicRecords(TestCase):
|
||||
'invalid IPv4 address "blip"',
|
||||
], ctx.exception.reasons)
|
||||
|
||||
# missing rules
|
||||
# missing rules, and unused pools
|
||||
a_data = {
|
||||
'dynamic': {
|
||||
'pools': {
|
||||
@@ -3102,7 +3102,10 @@ class TestDynamicRecords(TestCase):
|
||||
}
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
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
|
||||
a_data = {
|
||||
@@ -3132,7 +3135,10 @@ class TestDynamicRecords(TestCase):
|
||||
}
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
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
|
||||
a_data = {
|
||||
@@ -3162,7 +3168,10 @@ class TestDynamicRecords(TestCase):
|
||||
}
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
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
|
||||
a_data = {
|
||||
@@ -3196,7 +3205,10 @@ class TestDynamicRecords(TestCase):
|
||||
}
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
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
|
||||
a_data = {
|
||||
@@ -3231,8 +3243,10 @@ class TestDynamicRecords(TestCase):
|
||||
}
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
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
|
||||
a_data = {
|
||||
@@ -3267,8 +3281,10 @@ class TestDynamicRecords(TestCase):
|
||||
}
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
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
|
||||
a_data = {
|
||||
@@ -3377,6 +3393,45 @@ class TestDynamicRecords(TestCase):
|
||||
self.assertEquals(['rule 2 duplicate default'],
|
||||
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):
|
||||
# Missing pools
|
||||
a_data = {
|
||||
|
||||
Reference in New Issue
Block a user