1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

add AXFR source to OctoDNS

Adds a new source requested in #239. This source allows a user to pull data from
a legacy system (Bind9, etc.) that does not have an API/existing provider via
AXFR Zone Transfer.
This commit is contained in:
Adam Smith
2018-07-09 01:21:46 -07:00
parent 8268385af2
commit a803371fa4
8 changed files with 248 additions and 3 deletions

View File

@@ -0,0 +1,40 @@
#
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
import dns.zone
from dns.exception import DNSException
from mock import patch
from unittest import TestCase
from octodns.source.axfr import AxfrSource, AxfrSourceZoneTransferFailed
from octodns.zone import Zone
class TestAxfrSource(TestCase):
source = AxfrSource('test', 'localhost')
forward_zonefile = dns.zone.from_file('./tests/zones/unit.tests.db',
'unit.tests', relativize=False)
@patch('dns.zone.from_xfr')
def test_populate(self, from_xfr_mock):
got = Zone('unit.tests.', [])
from_xfr_mock.side_effect = [
self.forward_zonefile,
DNSException
]
self.source.populate(got)
self.assertEquals(11, len(got.records))
with self.assertRaises(AxfrSourceZoneTransferFailed) as ctx:
zone = Zone('unit.tests.', [])
self.source.populate(zone)
self.assertEquals('Unable to Perform Zone Transfer',
ctx.exception.message)

View File

@@ -15,7 +15,7 @@ from helpers import SimpleProvider
class TestTinyDnsFileSource(TestCase):
source = TinyDnsFileSource('test', './tests/zones')
source = TinyDnsFileSource('test', './tests/zones/tinydns')
def test_populate_normal(self):
got = Zone('example.com.', [])

42
tests/zones/unit.tests.db Normal file
View File

@@ -0,0 +1,42 @@
$ORIGIN unit.tests.
@ IN SOA ns1.unit.tests. root.unit.tests. (
2018071501 ; Serial
3600 ; Refresh (1 hour)
600 ; Retry (10 minutes)
604800 ; Expire (1 week)
3600 ; NXDOMAIN ttl (1 hour)
)
; NS Records
@ 3600 IN NS ns1.unit.tests.
@ 3600 IN NS ns2.unit.tests.
under 3600 IN NS ns1.unit.tests.
under 3600 IN NS ns2.unit.tests.
; SRV Records
_srv._tcp 600 IN SRV 10 20 30 foo-1.unit.tests.
_srv._tcp 600 IN SRV 10 20 30 foo-2.unit.tests.
; TXT Records
txt 600 IN TXT "Bah bah black sheep"
txt 600 IN TXT "have you any wool."
txt 600 IN TXT "v=DKIM1;k=rsa;s=email;h=sha256;p=A/kinda+of/long/string+with+numb3rs"
; MX Records
mx 300 IN MX 10 smtp-4.unit.tests.
mx 300 IN MX 20 smtp-2.unit.tests.
mx 300 IN MX 30 smtp-3.unit.tests.
mx 300 IN MX 40 smtp-1.unit.tests.
; A Records
@ 300 IN A 1.2.3.4
@ 300 IN A 1.2.3.5
www 300 IN A 2.2.3.6
wwww.sub 300 IN A 2.2.3.6
; AAAA Records
aaaa 600 IN AAAA 2601:644:500:e210:62f8:1dff:feb8:947a
; CNAME Records
cname 300 IN CNAME unit.tests.
included 300 IN CNAME unit.tests.