1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

CAA unit tests for provider support

This commit is contained in:
Ross McFarland
2017-08-26 15:28:09 -07:00
parent 22591ae84b
commit c24c793bcb
8 changed files with 77 additions and 15 deletions

View File

@@ -68,7 +68,7 @@ class PowerDnsBaseProvider(BaseProvider):
values.append({
'flags': flags,
'tag': tag,
'value': value,
'value': value[1:-1],
})
return {
'type': rrset['type'],

View File

@@ -31,6 +31,11 @@
values:
- 6.2.3.4.
- 7.2.3.4.
- type: CAA
values:
- flags: 0
tag: issue
value: ca.unit.tests
_srv._tcp:
ttl: 600
type: SRV

View File

@@ -230,6 +230,18 @@
],
"ttl": 300,
"type": "A"
},
{
"comments": [],
"name": "unit.tests.",
"records": [
{
"content": "0 issue \"ca.unit.tests\"",
"disabled": false
}
],
"ttl": 3600,
"type": "CAA"
}
],
"serial": 2017012803,

View File

@@ -109,6 +109,14 @@ class TestDynProvider(TestCase):
'weight': 22,
'port': 20,
'target': 'foo-2.unit.tests.'
}]}),
('', {
'type': 'CAA',
'ttl': 308,
'values': [{
'flags': 0,
'tag': 'issue',
'value': 'ca.unit.tests'
}]})):
expected.add_record(Record.new(expected, name, data))
@@ -321,6 +329,16 @@ class TestDynProvider(TestCase):
'ttl': 307,
'zone': 'unit.tests',
}],
'caa_records': [{
'fqdn': 'unit.tests',
'rdata': {'flags': 0,
'tag': 'issue',
'value': 'ca.unit.tests'},
'record_id': 12,
'record_type': 'cAA',
'ttl': 308,
'zone': 'unit.tests',
}],
}}
]
got = Zone('unit.tests.', [])
@@ -414,10 +432,10 @@ class TestDynProvider(TestCase):
update_mock.assert_called()
add_mock.assert_called()
# Once for each dyn record (8 Records, 2 of which have dual values)
self.assertEquals(14, len(add_mock.call_args_list))
self.assertEquals(15, len(add_mock.call_args_list))
execute_mock.assert_has_calls([call('/Zone/unit.tests/', 'GET', {}),
call('/Zone/unit.tests/', 'GET', {})])
self.assertEquals(9, len(plan.changes))
self.assertEquals(10, len(plan.changes))
execute_mock.reset_mock()

View File

@@ -96,6 +96,15 @@ class TestNs1Provider(TestCase):
'type': 'NS',
'values': ['ns3.unit.tests.', 'ns4.unit.tests.'],
}))
expected.add(Record.new(zone, '', {
'ttl': 40,
'type': 'CAA',
'value': {
'flags': 0,
'tag': 'issue',
'value': 'ca.unit.tests',
},
}))
nsone_records = [{
'type': 'A',
@@ -141,6 +150,11 @@ class TestNs1Provider(TestCase):
'ttl': 39,
'short_answers': ['ns3.unit.tests.', 'ns4.unit.tests.'],
'domain': 'sub.unit.tests.',
}, {
'type': 'CAA',
'ttl': 40,
'short_answers': ['0 issue ca.unit.tests'],
'domain': 'unit.tests.',
}]
@patch('nsone.NSONE.loadZone')

View File

@@ -79,7 +79,7 @@ class TestPowerDnsProvider(TestCase):
source = YamlProvider('test', join(dirname(__file__), 'config'))
source.populate(expected)
expected_n = len(expected.records) - 1
self.assertEquals(14, expected_n)
self.assertEquals(15, expected_n)
# No diffs == no changes
with requests_mock() as mock:
@@ -87,7 +87,7 @@ class TestPowerDnsProvider(TestCase):
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals(14, len(zone.records))
self.assertEquals(15, len(zone.records))
changes = expected.changes(zone, provider)
self.assertEquals(0, len(changes))
@@ -167,7 +167,7 @@ class TestPowerDnsProvider(TestCase):
expected = Zone('unit.tests.', [])
source = YamlProvider('test', join(dirname(__file__), 'config'))
source.populate(expected)
self.assertEquals(15, len(expected.records))
self.assertEquals(16, len(expected.records))
# A small change to a single record
with requests_mock() as mock:

View File

@@ -77,6 +77,12 @@ class TestRoute53Provider(TestCase):
{'ttl': 67, 'type': 'NS', 'values': ['8.2.3.4.', '9.2.3.4.']}),
('sub',
{'ttl': 68, 'type': 'NS', 'values': ['5.2.3.4.', '6.2.3.4.']}),
('',
{'ttl': 69, 'type': 'CAA', 'value': {
'flags': 0,
'tag': 'issue',
'value': 'ca.unit.tests'
}}),
):
record = Record.new(expected, name, data)
expected.add_record(record)
@@ -300,6 +306,13 @@ class TestRoute53Provider(TestCase):
'Value': 'ns1.unit.tests.',
}],
'TTL': 69,
}, {
'Name': 'unit.tests.',
'Type': 'CAA',
'ResourceRecords': [{
'Value': '0 issue "ca.unit.tests"',
}],
'TTL': 69,
}],
'IsTruncated': False,
'MaxItems': '100',
@@ -347,7 +360,7 @@ class TestRoute53Provider(TestCase):
{'HostedZoneId': 'z42'})
plan = provider.plan(self.expected)
self.assertEquals(8, len(plan.changes))
self.assertEquals(9, len(plan.changes))
for change in plan.changes:
self.assertIsInstance(change, Create)
stubber.assert_no_pending_responses()
@@ -366,7 +379,7 @@ class TestRoute53Provider(TestCase):
'SubmittedAt': '2017-01-29T01:02:03Z',
}}, {'HostedZoneId': 'z42', 'ChangeBatch': ANY})
self.assertEquals(8, provider.apply(plan))
self.assertEquals(9, provider.apply(plan))
stubber.assert_no_pending_responses()
# Delete by monkey patching in a populate that includes an extra record
@@ -579,7 +592,7 @@ class TestRoute53Provider(TestCase):
{})
plan = provider.plan(self.expected)
self.assertEquals(8, len(plan.changes))
self.assertEquals(9, len(plan.changes))
for change in plan.changes:
self.assertIsInstance(change, Create)
stubber.assert_no_pending_responses()
@@ -626,7 +639,7 @@ class TestRoute53Provider(TestCase):
'SubmittedAt': '2017-01-29T01:02:03Z',
}}, {'HostedZoneId': 'z42', 'ChangeBatch': ANY})
self.assertEquals(8, provider.apply(plan))
self.assertEquals(9, provider.apply(plan))
stubber.assert_no_pending_responses()
def test_health_checks_pagination(self):
@@ -1174,16 +1187,16 @@ class TestRoute53Provider(TestCase):
@patch('octodns.provider.route53.Route53Provider._really_apply')
def test_apply_1(self, really_apply_mock):
# 17 RRs with max of 18 should only get applied in one call
provider, plan = self._get_test_plan(18)
# 18 RRs with max of 19 should only get applied in one call
provider, plan = self._get_test_plan(19)
provider.apply(plan)
really_apply_mock.assert_called_once()
@patch('octodns.provider.route53.Route53Provider._really_apply')
def test_apply_2(self, really_apply_mock):
# 17 RRs with max of 17 should only get applied in two calls
provider, plan = self._get_test_plan(17)
# 18 RRs with max of 17 should only get applied in two calls
provider, plan = self._get_test_plan(18)
provider.apply(plan)
self.assertEquals(2, really_apply_mock.call_count)

View File

@@ -30,7 +30,7 @@ class TestYamlProvider(TestCase):
# without it we see everything
source.populate(zone)
self.assertEquals(15, len(zone.records))
self.assertEquals(16, len(zone.records))
# Assumption here is that a clean round-trip means that everything
# worked as expected, data that went in came back out and could be