Browse Source

Add test to validate non-dotted subdomain zones are vaild

This confirms that in addition to the recently added support for dotted
subdomains that subdomains that are not dotted are supported.  From
RFC1034 Section 3.5 this would be a <subdomain> that contains a single
<label> without <subdomain> recurring.
pull/908/head
Sachi King 4 years ago
parent
commit
04be906c3c
3 changed files with 17 additions and 11 deletions
  1. +5
    -0
      tests/config/unit.tests.yaml
  2. +7
    -7
      tests/test_octodns_manager.py
  3. +5
    -4
      tests/test_octodns_provider_yaml.py

+ 5
- 0
tests/config/unit.tests.yaml View File

@ -167,6 +167,11 @@ sub.txt:
values: values:
- ns1.test. - ns1.test.
- ns2.test. - ns2.test.
subzone:
type: 'NS'
values:
- 192.0.2.1.
- 192.0.2.8.
txt: txt:
ttl: 600 ttl: 600
type: TXT type: TXT


+ 7
- 7
tests/test_octodns_manager.py View File

@ -121,12 +121,12 @@ class TestManager(TestCase):
environ['YAML_TMP_DIR'] = tmpdir.dirname environ['YAML_TMP_DIR'] = tmpdir.dirname
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
.sync(dry_run=False) .sync(dry_run=False)
self.assertEqual(27, tc)
self.assertEqual(28, tc)
# try with just one of the zones # try with just one of the zones
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
.sync(dry_run=False, eligible_zones=['unit.tests.']) .sync(dry_run=False, eligible_zones=['unit.tests.'])
self.assertEqual(21, tc)
self.assertEqual(22, tc)
# the subzone, with 2 targets # the subzone, with 2 targets
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
@ -141,18 +141,18 @@ class TestManager(TestCase):
# Again with force # Again with force
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
.sync(dry_run=False, force=True) .sync(dry_run=False, force=True)
self.assertEqual(27, tc)
self.assertEqual(28, tc)
# Again with max_workers = 1 # Again with max_workers = 1
tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \ tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \
.sync(dry_run=False, force=True) .sync(dry_run=False, force=True)
self.assertEqual(27, tc)
self.assertEqual(28, tc)
# Include meta # Include meta
tc = Manager(get_config_filename('simple.yaml'), max_workers=1, tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
include_meta=True) \ include_meta=True) \
.sync(dry_run=False, force=True) .sync(dry_run=False, force=True)
self.assertEqual(32, tc)
self.assertEqual(33, tc)
def test_eligible_sources(self): def test_eligible_sources(self):
with TemporaryDirectory() as tmpdir: with TemporaryDirectory() as tmpdir:
@ -220,13 +220,13 @@ class TestManager(TestCase):
# compare doesn't use _process_desired_zone and thus doesn't filter # compare doesn't use _process_desired_zone and thus doesn't filter
# out root NS records, that seems fine/desirable # out root NS records, that seems fine/desirable
changes = manager.compare(['in'], ['dump'], 'unit.tests.') changes = manager.compare(['in'], ['dump'], 'unit.tests.')
self.assertEqual(22, len(changes))
self.assertEqual(23, len(changes))
# Compound sources with varying support # Compound sources with varying support
changes = manager.compare(['in', 'nosshfp'], changes = manager.compare(['in', 'nosshfp'],
['dump'], ['dump'],
'unit.tests.') 'unit.tests.')
self.assertEqual(21, len(changes))
self.assertEqual(22, len(changes))
with self.assertRaises(ManagerException) as ctx: with self.assertRaises(ManagerException) as ctx:
manager.compare(['nope'], ['dump'], 'unit.tests.') manager.compare(['nope'], ['dump'], 'unit.tests.')


+ 5
- 4
tests/test_octodns_provider_yaml.py View File

@ -34,7 +34,7 @@ class TestYamlProvider(TestCase):
# without it we see everything # without it we see everything
source.populate(zone) source.populate(zone)
self.assertEqual(24, len(zone.records))
self.assertEqual(25, len(zone.records))
source.populate(dynamic_zone) source.populate(dynamic_zone)
self.assertEqual(6, len(dynamic_zone.records)) self.assertEqual(6, len(dynamic_zone.records))
@ -57,12 +57,12 @@ class TestYamlProvider(TestCase):
# We add everything # We add everything
plan = target.plan(zone) plan = target.plan(zone)
self.assertEqual(21, len([c for c in plan.changes
self.assertEqual(22, len([c for c in plan.changes
if isinstance(c, Create)])) if isinstance(c, Create)]))
self.assertFalse(isfile(yaml_file)) self.assertFalse(isfile(yaml_file))
# Now actually do it # Now actually do it
self.assertEqual(21, target.apply(plan))
self.assertEqual(22, target.apply(plan))
self.assertTrue(isfile(yaml_file)) self.assertTrue(isfile(yaml_file))
# Dynamic plan # Dynamic plan
@ -90,7 +90,7 @@ class TestYamlProvider(TestCase):
# A 2nd sync should still create everything # A 2nd sync should still create everything
plan = target.plan(zone) plan = target.plan(zone)
self.assertEqual(21, len([c for c in plan.changes
self.assertEqual(22, len([c for c in plan.changes
if isinstance(c, Create)])) if isinstance(c, Create)]))
with open(yaml_file) as fh: with open(yaml_file) as fh:
@ -112,6 +112,7 @@ class TestYamlProvider(TestCase):
self.assertTrue('values' in data.pop('loc')) self.assertTrue('values' in data.pop('loc'))
self.assertTrue('values' in data.pop('urlfwd')) self.assertTrue('values' in data.pop('urlfwd'))
self.assertTrue('values' in data.pop('sub.txt')) self.assertTrue('values' in data.pop('sub.txt'))
self.assertTrue('values' in data.pop('subzone'))
# these are stored as singular 'value' # these are stored as singular 'value'
self.assertTrue('value' in data.pop('_imap._tcp')) self.assertTrue('value' in data.pop('_imap._tcp'))
self.assertTrue('value' in data.pop('_pop3._tcp')) self.assertTrue('value' in data.pop('_pop3._tcp'))


Loading…
Cancel
Save