From: Jelte Jansen Date: Thu, 15 Dec 2011 09:56:37 +0000 (+0100) Subject: [1414] added class check as well, and test for case-insensitivity X-Git-Tag: perftcpdns_before_epoll~5^2~11^2~1^2~1^2~1^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bdd00552a920331dc3cf1f2e6a7644112caa4b72;p=thirdparty%2Fkea.git [1414] added class check as well, and test for case-insensitivity --- diff --git a/src/bin/zonemgr/tests/zonemgr_test.py b/src/bin/zonemgr/tests/zonemgr_test.py index ec2ced635e..9d60211aed 100644 --- a/src/bin/zonemgr/tests/zonemgr_test.py +++ b/src/bin/zonemgr/tests/zonemgr_test.py @@ -569,6 +569,14 @@ 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) + + # and with case-insensitive checking + config['secondary_zones'] = \ + zone_list_from_name_classes([("Example.NeT.", "IN")]) + 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")]) @@ -580,6 +588,17 @@ class TestZonemgrRefresh(unittest.TestCase): self.assertRaises(ZonemgrException, self.zone_refresh.update_config_data, config, self.cc_session) + # Try a bad class + config['secondary_zones'] = \ + zone_list_from_name_classes([("example.net", "BADCLASS")]) + self.assertRaises(ZonemgrException, + self.zone_refresh.update_config_data, + config, self.cc_session) + config['secondary_zones'] = \ + zone_list_from_name_classes([("example.net", "")]) + self.assertRaises(ZonemgrException, + self.zone_refresh.update_config_data, + config, self.cc_session) def tearDown(self): sys.stderr= self.stderr_backup diff --git a/src/bin/zonemgr/zonemgr.py.in b/src/bin/zonemgr/zonemgr.py.in index 161a5caf81..f1ee2385f3 100755 --- a/src/bin/zonemgr/zonemgr.py.in +++ b/src/bin/zonemgr/zonemgr.py.in @@ -483,11 +483,17 @@ class ZonemgrRefresh: # (then this entire method can be simplified a lot, and we # wouldn't need direct access to the ccsession object) if 'class' in secondary_zone: - name_class = (name, secondary_zone['class']) + rr_class = secondary_zone['class'] else: - name_class = (name, - module_cc_session.get_default_value( - 'secondary_zones/class')) + rr_class = module_cc_session.get_default_value( + 'secondary_zones/class') + # Convert rr_class to and from RRClass to check its value + try: + name_class = (name, isc.dns.RRClass(rr_class).to_text()) + except isc.dns.InvalidRRClass as irce: + raise ZonemgrException("Bad RR class '" + + rr_class + + "' for zone " + name) required[name_class] = True # Add it only if it isn't there already if not name_class in self._zonemgr_refresh_info: