mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Fix handling of NULL SRV records in DigitalOcean provider
This commit is contained in:
@@ -186,10 +186,14 @@ class DigitalOceanProvider(BaseProvider):
|
|||||||
def _data_for_SRV(self, _type, records):
|
def _data_for_SRV(self, _type, records):
|
||||||
values = []
|
values = []
|
||||||
for record in records:
|
for record in records:
|
||||||
|
target = (
|
||||||
|
'{}.'.format(record['data'])
|
||||||
|
if record['data'] != "." else "."
|
||||||
|
)
|
||||||
values.append({
|
values.append({
|
||||||
'port': record['port'],
|
'port': record['port'],
|
||||||
'priority': record['priority'],
|
'priority': record['priority'],
|
||||||
'target': '{}.'.format(record['data']),
|
'target': target,
|
||||||
'weight': record['weight']
|
'weight': record['weight']
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
22
tests/fixtures/digitalocean-page-2.json
vendored
22
tests/fixtures/digitalocean-page-2.json
vendored
@@ -76,6 +76,28 @@
|
|||||||
"weight": null,
|
"weight": null,
|
||||||
"flags": null,
|
"flags": null,
|
||||||
"tag": null
|
"tag": null
|
||||||
|
}, {
|
||||||
|
"id": 11189896,
|
||||||
|
"type": "SRV",
|
||||||
|
"name": "_imap._tcp",
|
||||||
|
"data": ".",
|
||||||
|
"priority": 0,
|
||||||
|
"port": 0,
|
||||||
|
"ttl": 600,
|
||||||
|
"weight": 0,
|
||||||
|
"flags": null,
|
||||||
|
"tag": null
|
||||||
|
}, {
|
||||||
|
"id": 11189897,
|
||||||
|
"type": "SRV",
|
||||||
|
"name": "_pop3._tcp",
|
||||||
|
"data": ".",
|
||||||
|
"priority": 0,
|
||||||
|
"port": 0,
|
||||||
|
"ttl": 600,
|
||||||
|
"weight": 0,
|
||||||
|
"flags": null,
|
||||||
|
"tag": null
|
||||||
}],
|
}],
|
||||||
"links": {
|
"links": {
|
||||||
"pages": {
|
"pages": {
|
||||||
|
@@ -83,14 +83,14 @@ class TestDigitalOceanProvider(TestCase):
|
|||||||
|
|
||||||
zone = Zone('unit.tests.', [])
|
zone = Zone('unit.tests.', [])
|
||||||
provider.populate(zone)
|
provider.populate(zone)
|
||||||
self.assertEquals(12, len(zone.records))
|
self.assertEquals(14, len(zone.records))
|
||||||
changes = self.expected.changes(zone, provider)
|
changes = self.expected.changes(zone, provider)
|
||||||
self.assertEquals(0, len(changes))
|
self.assertEquals(0, len(changes))
|
||||||
|
|
||||||
# 2nd populate makes no network calls/all from cache
|
# 2nd populate makes no network calls/all from cache
|
||||||
again = Zone('unit.tests.', [])
|
again = Zone('unit.tests.', [])
|
||||||
provider.populate(again)
|
provider.populate(again)
|
||||||
self.assertEquals(12, len(again.records))
|
self.assertEquals(14, len(again.records))
|
||||||
|
|
||||||
# bust the cache
|
# bust the cache
|
||||||
del provider._zone_records[zone.name]
|
del provider._zone_records[zone.name]
|
||||||
@@ -190,6 +190,24 @@ class TestDigitalOceanProvider(TestCase):
|
|||||||
'flags': 0, 'name': '@',
|
'flags': 0, 'name': '@',
|
||||||
'tag': 'issue',
|
'tag': 'issue',
|
||||||
'ttl': 3600, 'type': 'CAA'}),
|
'ttl': 3600, 'type': 'CAA'}),
|
||||||
|
call('POST', '/domains/unit.tests/records', data={
|
||||||
|
'name': '_imap._tcp',
|
||||||
|
'weight': 0,
|
||||||
|
'data': '.',
|
||||||
|
'priority': 0,
|
||||||
|
'ttl': 600,
|
||||||
|
'type': 'SRV',
|
||||||
|
'port': 0
|
||||||
|
}),
|
||||||
|
call('POST', '/domains/unit.tests/records', data={
|
||||||
|
'name': '_pop3._tcp',
|
||||||
|
'weight': 0,
|
||||||
|
'data': '.',
|
||||||
|
'priority': 0,
|
||||||
|
'ttl': 600,
|
||||||
|
'type': 'SRV',
|
||||||
|
'port': 0
|
||||||
|
}),
|
||||||
call('POST', '/domains/unit.tests/records', data={
|
call('POST', '/domains/unit.tests/records', data={
|
||||||
'name': '_srv._tcp',
|
'name': '_srv._tcp',
|
||||||
'weight': 20,
|
'weight': 20,
|
||||||
@@ -200,7 +218,7 @@ class TestDigitalOceanProvider(TestCase):
|
|||||||
'port': 30
|
'port': 30
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
self.assertEquals(24, provider._client._request.call_count)
|
self.assertEquals(26, provider._client._request.call_count)
|
||||||
|
|
||||||
provider._client._request.reset_mock()
|
provider._client._request.reset_mock()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user