Browse Source

Fix handling of NULL SRV records in DigitalOcean provider

pull/668/head
Mark Tearle 5 years ago
parent
commit
39412924da
3 changed files with 48 additions and 4 deletions
  1. +5
    -1
      octodns/provider/digitalocean.py
  2. +22
    -0
      tests/fixtures/digitalocean-page-2.json
  3. +21
    -3
      tests/test_octodns_provider_digitalocean.py

+ 5
- 1
octodns/provider/digitalocean.py View File

@ -186,10 +186,14 @@ class DigitalOceanProvider(BaseProvider):
def _data_for_SRV(self, _type, records):
values = []
for record in records:
target = (
'{}.'.format(record['data'])
if record['data'] != "." else "."
)
values.append({
'port': record['port'],
'priority': record['priority'],
'target': '{}.'.format(record['data']),
'target': target,
'weight': record['weight']
})
return {


+ 22
- 0
tests/fixtures/digitalocean-page-2.json View File

@ -76,6 +76,28 @@
"weight": null,
"flags": 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": {
"pages": {


+ 21
- 3
tests/test_octodns_provider_digitalocean.py View File

@ -83,14 +83,14 @@ class TestDigitalOceanProvider(TestCase):
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals(12, len(zone.records))
self.assertEquals(14, len(zone.records))
changes = self.expected.changes(zone, provider)
self.assertEquals(0, len(changes))
# 2nd populate makes no network calls/all from cache
again = Zone('unit.tests.', [])
provider.populate(again)
self.assertEquals(12, len(again.records))
self.assertEquals(14, len(again.records))
# bust the cache
del provider._zone_records[zone.name]
@ -190,6 +190,24 @@ class TestDigitalOceanProvider(TestCase):
'flags': 0, 'name': '@',
'tag': 'issue',
'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={
'name': '_srv._tcp',
'weight': 20,
@ -200,7 +218,7 @@ class TestDigitalOceanProvider(TestCase):
'port': 30
}),
])
self.assertEquals(24, provider._client._request.call_count)
self.assertEquals(26, provider._client._request.call_count)
provider._client._request.reset_mock()


Loading…
Cancel
Save