Commit 23350205 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1414] address some more comments

parent ebfebb1b
......@@ -551,19 +551,16 @@ class TestZonemgrRefresh(unittest.TestCase):
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertEqual(self.zone_refresh._zonemgr_refresh_info, {})
# Put something in
#config.set_zone_list_from_name_classes([ZONE_NAME_CLASS1_IN])
config['secondary_zones'] = \
zone_list_from_name_classes([ZONE_NAME_CLASS1_IN])
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertTrue(("example.net.", "IN") in
self.zone_refresh._zonemgr_refresh_info)
# This one does not exist
# Reset the data, set to use a different class, and make sure
# it does not get set to IN
config['secondary_zones'] = \
zone_list_from_name_classes(["example.net", "CH"])
zone_list_from_name_classes([ZONE_NAME_CLASS1_CH])
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertFalse(("example.net.", "CH") in
self.zone_refresh._zonemgr_refresh_info)
# Simply skip loading soa for the zone, the other configs should be updated successful
self.assertFalse(("example.net.", "IN") in
self.zone_refresh._zonemgr_refresh_info)
# Make sure it works even when we "accidentally" forget the final dot
......@@ -572,6 +569,17 @@ class TestZonemgrRefresh(unittest.TestCase):
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertTrue(("example.net.", "IN") in
self.zone_refresh._zonemgr_refresh_info)
# Try some bad names
config['secondary_zones'] = \
zone_list_from_name_classes([("example..net", "IN")])
self.assertRaises(ZonemgrException,
self.zone_refresh.update_config_data,
config, self.cc_session)
config['secondary_zones'] = \
zone_list_from_name_classes([("", "IN")])
self.assertRaises(ZonemgrException,
self.zone_refresh.update_config_data,
config, self.cc_session)
def tearDown(self):
sys.stderr= self.stderr_backup
......
......@@ -28,6 +28,7 @@ import os
import time
import signal
import isc
import isc.dns
import random
import threading
import select
......@@ -461,9 +462,16 @@ class ZonemgrRefresh:
raise ZonemgrException("Secondary zone specified "
"without a name")
name = secondary_zone['name']
# Be tolerant to sclerotic users who forget the final dot
if name[-1] != '.':
name = name + '.'
# Convert to Name and back (both to check and to normalize)
try:
name = isc.dns.Name(name, True).to_text()
# Name() can raise a number of different exceptions, just
# catch 'em all.
except Exception as isce:
raise ZonemgrException("Bad zone name '" + name +
"': " + str(isce))
# Currently we use an explicit get_default_value call
# in case the class hasn't been set. Alternatively, we
# could use
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment