mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
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.
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
#
|
|
#
|
|
#
|
|
|
|
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)
|