mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Add record targets normalizaltion
This commit is contained in:
@@ -87,6 +87,14 @@ class GandiClient(object):
|
||||
if record['rrset_name'] == '@':
|
||||
record['rrset_name'] = ''
|
||||
|
||||
# Change relative targets to absolute ones.
|
||||
if record['rrset_type'] in ['ALIAS', 'CNAME', 'DNAME', 'MX',
|
||||
'NS', 'SRV']:
|
||||
for i, value in enumerate(record['rrset_values']):
|
||||
if not value.endswith('.'):
|
||||
record['rrset_values'][i] = '{}.{}.'.format(
|
||||
value, zone_name)
|
||||
|
||||
return records
|
||||
|
||||
def record_create(self, zone_name, data):
|
||||
|
||||
@@ -98,5 +98,14 @@
|
||||
"rrset_values": [
|
||||
"32128 13 1 6823D9BB1B03DF714DD0EB163E20B341C96D18C0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"rrset_type": "CNAME",
|
||||
"rrset_ttl": 10800,
|
||||
"rrset_name": "relative",
|
||||
"rrset_href": "https://api.gandi.net/v5/livedns/domains/unit.tests/records/relative/CNAME",
|
||||
"rrset_values": [
|
||||
"target"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -126,19 +126,19 @@ class TestGandiProvider(TestCase):
|
||||
with requests_mock() as mock:
|
||||
base = 'https://api.gandi.net/v5/livedns/domains/unit.tests' \
|
||||
'/records'
|
||||
with open('tests/fixtures/gandi-default-zone.json') as fh:
|
||||
with open('tests/fixtures/gandi-records.json') as fh:
|
||||
mock.get(base, text=fh.read())
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(10, len(zone.records))
|
||||
self.assertEquals(11, len(zone.records))
|
||||
changes = self.expected.changes(zone, provider)
|
||||
self.assertEquals(22, len(changes))
|
||||
self.assertEquals(23, len(changes))
|
||||
|
||||
# 2nd populate makes no network calls/all from cache
|
||||
again = Zone('unit.tests.', [])
|
||||
provider.populate(again)
|
||||
self.assertEquals(10, len(again.records))
|
||||
self.assertEquals(11, len(again.records))
|
||||
|
||||
# bust the cache
|
||||
del provider._zone_records[zone.name]
|
||||
|
||||
Reference in New Issue
Block a user