Browse Source

change all answers from NS1 to absolute for types that require it

pull/247/head
Adam Smith 8 years ago
parent
commit
be6019f119
2 changed files with 14 additions and 5 deletions
  1. +9
    -0
      octodns/provider/ns1.py
  2. +5
    -5
      tests/test_octodns_provider_ns1.py

+ 9
- 0
octodns/provider/ns1.py View File

@ -189,6 +189,15 @@ class Ns1Provider(BaseProvider):
try: try:
nsone_zone = self._client.loadZone(zone.name[:-1]) nsone_zone = self._client.loadZone(zone.name[:-1])
records = nsone_zone.data['records'] records = nsone_zone.data['records']
# change answers for certain types to always be absolute
for record in records:
if record['type'] in ['ALIAS', 'CNAME', 'MX', 'NS', 'PTR',
'SRV']:
for i, a in enumerate(record['short_answers']):
if not a.endswith('.'):
record['short_answers'][i] = '{}.'.format(a)
geo_records = nsone_zone.search(has_geo=True) geo_records = nsone_zone.search(has_geo=True)
exists = True exists = True
except ResourceException as e: except ResourceException as e:


+ 5
- 5
tests/test_octodns_provider_ns1.py View File

@ -133,12 +133,12 @@ class TestNs1Provider(TestCase):
}, { }, {
'type': 'CNAME', 'type': 'CNAME',
'ttl': 34, 'ttl': 34,
'short_answers': ['foo.unit.tests.'],
'short_answers': ['foo.unit.tests'],
'domain': 'cname.unit.tests.', 'domain': 'cname.unit.tests.',
}, { }, {
'type': 'MX', 'type': 'MX',
'ttl': 35, 'ttl': 35,
'short_answers': ['10 mx1.unit.tests.', '20 mx2.unit.tests.'],
'short_answers': ['10 mx1.unit.tests.', '20 mx2.unit.tests'],
'domain': 'unit.tests.', 'domain': 'unit.tests.',
}, { }, {
'type': 'NAPTR', 'type': 'NAPTR',
@ -151,18 +151,18 @@ class TestNs1Provider(TestCase):
}, { }, {
'type': 'NS', 'type': 'NS',
'ttl': 37, 'ttl': 37,
'short_answers': ['ns1.unit.tests.', 'ns2.unit.tests.'],
'short_answers': ['ns1.unit.tests.', 'ns2.unit.tests'],
'domain': 'unit.tests.', 'domain': 'unit.tests.',
}, { }, {
'type': 'SRV', 'type': 'SRV',
'ttl': 38, 'ttl': 38,
'short_answers': ['12 30 30 foo-2.unit.tests.', 'short_answers': ['12 30 30 foo-2.unit.tests.',
'10 20 30 foo-1.unit.tests.'],
'10 20 30 foo-1.unit.tests'],
'domain': '_srv._tcp.unit.tests.', 'domain': '_srv._tcp.unit.tests.',
}, { }, {
'type': 'NS', 'type': 'NS',
'ttl': 39, 'ttl': 39,
'short_answers': ['ns3.unit.tests.', 'ns4.unit.tests.'],
'short_answers': ['ns3.unit.tests.', 'ns4.unit.tests'],
'domain': 'sub.unit.tests.', 'domain': 'sub.unit.tests.',
}, { }, {
'type': 'CAA', 'type': 'CAA',


Loading…
Cancel
Save