Browse Source

SSHFP support for Source AXFR/Zonefile

pull/902/head
Aquifoliales 4 years ago
parent
commit
8b2bfa5dea
3 changed files with 25 additions and 5 deletions
  1. +17
    -1
      octodns/source/axfr.py
  2. +4
    -4
      tests/test_octodns_source_axfr.py
  3. +4
    -0
      tests/zones/unit.tests.tst

+ 17
- 1
octodns/source/axfr.py View File

@ -26,7 +26,7 @@ class AxfrBaseSource(BaseSource):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'LOC', 'MX', 'NS', 'PTR',
'SPF', 'SRV', 'TXT'))
'SPF', 'SRV', 'SSHFP', 'TXT'))
def __init__(self, id):
super(AxfrBaseSource, self).__init__(id)
@ -135,6 +135,22 @@ class AxfrBaseSource(BaseSource):
'values': values
}
def _data_for_SSHFP(self, _type, records):
values = []
for record in records:
algorithm, fingerprint_type, fingerprint = \
record['value'].split(' ', 2)
values.append({
'algorithm': algorithm,
'fingerprint_type': fingerprint_type,
'fingerprint': fingerprint,
})
return {
'type': _type,
'ttl': records[0]['ttl'],
'values': values
}
def populate(self, zone, target=False, lenient=False):
self.log.debug('populate: name=%s, target=%s, lenient=%s', zone.name,
target, lenient)


+ 4
- 4
tests/test_octodns_source_axfr.py View File

@ -35,7 +35,7 @@ class TestAxfrSource(TestCase):
]
self.source.populate(got)
self.assertEqual(15, len(got.records))
self.assertEqual(16, len(got.records))
with self.assertRaises(AxfrSourceZoneTransferFailed) as ctx:
zone = Zone('unit.tests.', [])
@ -72,18 +72,18 @@ class TestZoneFileSource(TestCase):
# Load zonefiles without a specified file extension
valid = Zone('unit.tests.', [])
source.populate(valid)
self.assertEqual(15, len(valid.records))
self.assertEqual(16, len(valid.records))
def test_populate(self):
# Valid zone file in directory
valid = Zone('unit.tests.', [])
self.source.populate(valid)
self.assertEqual(15, len(valid.records))
self.assertEqual(16, len(valid.records))
# 2nd populate does not read file again
again = Zone('unit.tests.', [])
self.source.populate(again)
self.assertEqual(15, len(again.records))
self.assertEqual(16, len(again.records))
# bust the cache
del self.source._zone_records[valid.name]


+ 4
- 0
tests/zones/unit.tests.tst View File

@ -13,6 +13,10 @@ $ORIGIN unit.tests.
under 3600 IN NS ns1.unit.tests.
under 3600 IN NS ns2.unit.tests.
; SSHFP Records
@ 600 IN SSHFP 1 1 bf6b6825d2977c511a475bbefb88aad54a92ac73
@ 600 IN SSHFP 1 1 7491973e5f8b39d5327cd4e08bc81b05f7710b49
; CAA Records
caa 1800 IN CAA 0 issue "ca.unit.tests"
caa 1800 IN CAA 0 iodef "mailto:admin@unit.tests"


Loading…
Cancel
Save