Browse Source

Skip unsupported records for NS1 & DNSimple

Implements the unsupported records skipping fix [proposed by ross](https://github.com/github/octodns/issues/176#issuecomment-359294960) in #176 for DNSimple and additionally for NS1.

Fixes #176 and also the NS1 version of it (`AttributeError: 'Ns1Provider' object has no attribute '_data_for_DNSKEY'`) that currently affect domains that have DNSSEC enabled.
pull/227/head
Tommy Yang 8 years ago
parent
commit
b000c07c80
3 changed files with 36 additions and 1 deletions
  1. +1
    -1
      octodns/provider/dnsimple.py
  2. +2
    -0
      octodns/provider/ns1.py
  3. +33
    -0
      tests/test_octodns_provider_ns1.py

+ 1
- 1
octodns/provider/dnsimple.py View File

@ -256,7 +256,7 @@ class DnsimpleProvider(BaseProvider):
values = defaultdict(lambda: defaultdict(list))
for record in self.zone_records(zone):
_type = record['type']
if _type == 'SOA':
if _type not in self.SUPPORTS:
continue
elif _type == 'TXT' and record['content'].startswith('ALIAS for'):
# ALIAS has a "ride along" TXT record with 'ALIAS for XXXX',


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

@ -204,6 +204,8 @@ class Ns1Provider(BaseProvider):
zone_hash = {}
for record in chain(records, geo_records):
_type = record['type']
if _type not in self.SUPPORTS:
continue
data_for = getattr(self, '_data_for_{}'.format(_type))
name = zone.hostname_from_fqdn(record['domain'])
record = Record.new(zone, name, data_for(_type, record),


+ 33
- 0
tests/test_octodns_provider_ns1.py View File

@ -257,6 +257,39 @@ class TestNs1Provider(TestCase):
self.assertEquals(self.expected, zone.records)
self.assertEquals(('unit.tests',), load_mock.call_args[0])
# Test skipping unsupported record type
load_mock.reset_mock()
nsone_zone = DummyZone(self.nsone_records + [{
'type': 'UNSUPPORTED',
'ttl': 42,
'short_answers': ['unsupported'],
'domain': 'unsupported.unit.tests.',
}])
load_mock.side_effect = [nsone_zone]
zone_search = Mock()
zone_search.return_value = [
{
"domain": "geo.unit.tests",
"zone": "unit.tests",
"type": "A",
"answers": [
{'answer': ['1.1.1.1'], 'meta': {}},
{'answer': ['1.2.3.4'],
'meta': {'ca_province': ['ON']}},
{'answer': ['2.3.4.5'], 'meta': {'us_state': ['NY']}},
{'answer': ['3.4.5.6'], 'meta': {'country': ['US']}},
{'answer': ['4.5.6.7'],
'meta': {'iso_region_code': ['NA-US-WA']}},
],
'ttl': 34,
},
]
nsone_zone.search = zone_search
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals(self.expected, zone.records)
self.assertEquals(('unit.tests',), load_mock.call_args[0])
@patch('nsone.NSONE.createZone')
@patch('nsone.NSONE.loadZone')
def test_sync(self, load_mock, create_mock):


Loading…
Cancel
Save