Browse Source

Fix issue when subzone is a non-dotted endswith for zone

pull/917/head
Ross McFarland 3 years ago
parent
commit
18ee70ddb5
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 15 additions and 3 deletions
  1. +4
    -3
      octodns/manager.py
  2. +11
    -0
      tests/test_octodns_manager.py

+ 4
- 3
octodns/manager.py View File

@ -315,12 +315,13 @@ class Manager(object):
while zones: while zones:
# Grab the one we'lre going to work on now # Grab the one we'lre going to work on now
zone = zones.pop() zone = zones.pop()
trimmer = len(zone) + 1
dotted = f'.{zone}'
trimmer = len(dotted)
subs = set() subs = set()
# look at all the zone names that come after it # look at all the zone names that come after it
for candidate in zones: for candidate in zones:
# If they end with this zone's name them they're a sub
if candidate.endswith(zone):
# If they end with this zone's dotted name, it's a sub
if candidate.endswith(dotted):
# We want subs to exclude the zone portion # We want subs to exclude the zone portion
subs.add(candidate[:-trimmer]) subs.add(candidate[:-trimmer])


+ 11
- 0
tests/test_octodns_manager.py View File

@ -776,6 +776,17 @@ class TestManager(TestCase):
set(), manager.configured_sub_zones('skipped.alevel.unit2.tests.') set(), manager.configured_sub_zones('skipped.alevel.unit2.tests.')
) )
# zones that end with names of others
manager.config['zones'] = {
'unit.tests.': {},
'uunit.tests.': {},
'uuunit.tests.': {},
}
manager._configured_sub_zones = None
self.assertEqual(set(), manager.configured_sub_zones('unit.tests.'))
self.assertEqual(set(), manager.configured_sub_zones('uunit.tests.'))
self.assertEqual(set(), manager.configured_sub_zones('uuunit.tests.'))
class TestMainThreadExecutor(TestCase): class TestMainThreadExecutor(TestCase):
def test_success(self): def test_success(self):


Loading…
Cancel
Save