BIND 10 trac811_new, updated. 94cfeebfec6574350fb4980c2b0cc6a7d84ba4f7 Merge branch 'trac811_new' of git+ssh://bind10.isc.org/var/bind10/git/bind10 into trac811_new
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue May 17 20:09:00 UTC 2011
The branch, trac811_new has been updated
via 94cfeebfec6574350fb4980c2b0cc6a7d84ba4f7 (commit)
via 47e5578077fa332f8476a13aa4ad6ba29e003a1a (commit)
via 830c0ba6c96b009d1c9c4fa31dea7cf4f6de4e37 (commit)
from 9e84764e4911a4ecf9b82df3beb6cd289eb68ada (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 94cfeebfec6574350fb4980c2b0cc6a7d84ba4f7
Merge: 47e5578077fa332f8476a13aa4ad6ba29e003a1a 9e84764e4911a4ecf9b82df3beb6cd289eb68ada
Author: Jelte Jansen <jelte at isc.org>
Date: Tue May 17 22:05:18 2011 +0200
Merge branch 'trac811_new' of git+ssh://bind10.isc.org/var/bind10/git/bind10 into trac811_new
commit 47e5578077fa332f8476a13aa4ad6ba29e003a1a
Author: Jelte Jansen <jelte at isc.org>
Date: Tue May 17 22:03:53 2011 +0200
[trac811] some more comments
added tests for get_default_value() in ConfigData
removed the now unnecessary self.name_str in ZoneInfo
downcase Name objects for storage in internal zones dict
commit 830c0ba6c96b009d1c9c4fa31dea7cf4f6de4e37
Author: Jelte Jansen <jelte at isc.org>
Date: Tue May 17 21:31:02 2011 +0200
[trac811] applied jinmei's proposed patch
-----------------------------------------------------------------------
Summary of changes:
src/bin/xfrin/tests/xfrin_test.py | 55 ++++++++++++++------
src/bin/xfrin/xfrin.py.in | 20 ++++---
.../python/isc/config/tests/config_data_test.py | 20 +++++++
3 files changed, 70 insertions(+), 25 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/xfrin/tests/xfrin_test.py b/src/bin/xfrin/tests/xfrin_test.py
index a773f6c..e5c4fcb 100644
--- a/src/bin/xfrin/tests/xfrin_test.py
+++ b/src/bin/xfrin/tests/xfrin_test.py
@@ -485,7 +485,8 @@ class TestXfrin(unittest.TestCase):
return self.xfr._parse_zone_name_and_class(self.args)
def _do_parse_master_port(self):
- return self.xfr._parse_master_and_port(self.args)
+ name, rrclass = self._do_parse_zone_name_class()
+ return self.xfr._parse_master_and_port(self.args, name, rrclass)
def test_parse_cmd_params(self):
name, rrclass = self._do_parse_zone_name_class()
@@ -603,6 +604,28 @@ class TestXfrin(unittest.TestCase):
self.assertEqual(int(TEST_MASTER_PORT),
self.xfr.xfrin_started_master_port)
+ def test_command_handler_retransfer_short_command4(self):
+ # try it when only specifying the zone name (of known zone, with
+ # different case)
+ short_args = {}
+
+ # swap the case of the zone name in our command
+ short_args['zone_name'] = TEST_ZONE_NAME_STR.swapcase()
+
+ zones = { 'zones': [
+ { 'name': TEST_ZONE_NAME_STR,
+ 'master_addr': TEST_MASTER_IPV4_ADDRESS,
+ 'master_port': TEST_MASTER_PORT
+ }
+ ]}
+ self.xfr.config_handler(zones)
+ self.assertEqual(self.xfr.command_handler("retransfer",
+ short_args)['result'][0], 0)
+ self.assertEqual(TEST_MASTER_IPV4_ADDRESS,
+ self.xfr.xfrin_started_master_addr)
+ self.assertEqual(int(TEST_MASTER_PORT),
+ self.xfr.xfrin_started_master_port)
+
def test_command_handler_retransfer_badcommand(self):
self.args['master'] = 'invalid'
self.assertEqual(self.xfr.command_handler("retransfer",
@@ -701,17 +724,17 @@ class TestXfrin(unittest.TestCase):
self.assertIsNone(zone_info.tsig_key)
def test_command_handler_zones(self):
- zones1 = { 'transfers_in': 3,
+ config1 = { 'transfers_in': 3,
'zones': [
{ 'name': 'test.example.',
'master_addr': '192.0.2.1',
'master_port': 53
}
]}
- self.assertEqual(self.xfr.config_handler(zones1)['result'][0], 0)
- self._check_zones_config(zones1)
+ self.assertEqual(self.xfr.config_handler(config1)['result'][0], 0)
+ self._check_zones_config(config1)
- zones2 = { 'transfers_in': 4,
+ config2 = { 'transfers_in': 4,
'zones': [
{ 'name': 'test.example.',
'master_addr': '192.0.2.2',
@@ -719,8 +742,8 @@ class TestXfrin(unittest.TestCase):
'tsig_key': "example.com:SFuWd/q99SzF8Yzd1QbB9g=="
}
]}
- self.assertEqual(self.xfr.config_handler(zones2)['result'][0], 0)
- self._check_zones_config(zones2)
+ self.assertEqual(self.xfr.config_handler(config2)['result'][0], 0)
+ self._check_zones_config(config2)
# test that configuring the zone multiple times fails
zones = { 'transfers_in': 5,
@@ -736,7 +759,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'name': 'test.example.',
@@ -746,7 +769,7 @@ class TestXfrin(unittest.TestCase):
}
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'master_addr': '192.0.2.4',
@@ -755,7 +778,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'name': 'bad..zone.',
@@ -765,7 +788,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'name': '',
@@ -775,7 +798,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'name': 'test.example',
@@ -785,7 +808,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'name': 'test.example',
@@ -795,7 +818,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
zones = { 'zones': [
{ 'name': 'test.example',
@@ -807,7 +830,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
# let's also add a zone that is correct too, and make sure
# that the new config is not partially taken
@@ -824,7 +847,7 @@ class TestXfrin(unittest.TestCase):
]}
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
# since this has failed, we should still have the previous config
- self._check_zones_config(zones2)
+ self._check_zones_config(config2)
def raise_interrupt():
diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in
index f1c24a2..257d0fa 100755
--- a/src/bin/xfrin/xfrin.py.in
+++ b/src/bin/xfrin/xfrin.py.in
@@ -77,8 +77,8 @@ class XfrinException(Exception):
class XfrinZoneInfoException(Exception):
"""This exception is raised if there is an error in the given
- configuration (part), or when a command does not have the
- required or bad arguments, for instance when the zone's master
+ configuration (part), or when a command does not have a required
+ argument or has bad arguments, for instance when the zone's master
address is not a valid IP address, when the zone does not
have a name, or when multiple settings are given for the same
zone."""
@@ -88,7 +88,12 @@ def _check_zone_name(zone_name_str):
"""Checks if the given zone name is a valid domain name, and returns
it as a Name object. Raises an XfrinException if it is not."""
try:
- return Name(zone_name_str)
+ # In the _zones dict, part of the key is the zone name,
+ # but due to a limitation in the Name class, we
+ # cannot directly use it as a dict key, and we use to_text()
+ #
+ # Downcase the name here for that reason.
+ return Name(zone_name_str, True)
except (EmptyLabel, TooLongLabel, BadLabelType, BadEscape,
TooLongName, IncompleteName) as ne:
raise XfrinZoneInfoException("bad zone name: " + zone_name_str + " (" + str(ne) + ")")
@@ -430,8 +435,6 @@ class ZoneInfo:
"""Set the name for this zone given a name string.
Raises XfrinZoneInfoException if name_str is None or if it
cannot be parsed."""
- #TODO: remove name_str
- self.name_str = name_str
if name_str is None:
raise XfrinZoneInfoException("Configuration zones list "
"element does not contain "
@@ -620,7 +623,8 @@ class Xfrin:
# If the command has specified master address, do transfer from the
# master address, or else do transfer from the configured masters.
(zone_name, rrclass) = self._parse_zone_name_and_class(args)
- master_addr = self._parse_master_and_port(args)
+ master_addr = self._parse_master_and_port(args, zone_name,
+ rrclass)
zone_info = self._get_zone_info(zone_name, rrclass)
tsig_key = None
if zone_info:
@@ -648,7 +652,7 @@ class Xfrin:
return (_check_zone_name(zone_name_str), _check_zone_class(args.get('zone_class')))
- def _parse_master_and_port(self, args):
+ def _parse_master_and_port(self, args, zone_name, zone_class):
"""
Return tuple (family, socktype, sockaddr) for address and port in given
args dict.
@@ -657,8 +661,6 @@ class Xfrin:
"""
# check if we have configured info about this zone, in case
# port or master are not specified
- zone_name = _check_zone_name(args.get('zone_name'))
- zone_class = _check_zone_class(args.get('zone_class'))
zone_info = self._get_zone_info(zone_name, zone_class)
addr_str = args.get('master')
diff --git a/src/lib/python/isc/config/tests/config_data_test.py b/src/lib/python/isc/config/tests/config_data_test.py
index 923e0b6..16d115d 100644
--- a/src/lib/python/isc/config/tests/config_data_test.py
+++ b/src/lib/python/isc/config/tests/config_data_test.py
@@ -237,6 +237,26 @@ class TestConfigData(unittest.TestCase):
self.assertEqual(None, value)
self.assertEqual(False, default)
+ def test_get_default_value(self):
+ self.assertEqual(1, self.cd.get_default_value("item1"))
+ self.assertEqual('default', self.cd.get_default_value("item6/value1"))
+
+ # set some local values to something else, and see if we
+ # still get the default
+ self.cd.set_local_config({"item1": 2, "item6": { "value1": "asdf" } })
+
+ self.assertEqual((2, False), self.cd.get_value("item1"))
+ self.assertEqual(1, self.cd.get_default_value("item1"))
+ self.assertEqual(('asdf', False), self.cd.get_value("item6/value1"))
+ self.assertEqual('default', self.cd.get_default_value("item6/value1"))
+
+ self.assertRaises(isc.cc.data.DataNotFoundError,
+ self.cd.get_default_value,
+ "does_not_exist/value1")
+ self.assertRaises(isc.cc.data.DataNotFoundError,
+ self.cd.get_default_value,
+ "item6/doesnotexist")
+
def test_set_local_config(self):
self.cd.set_local_config({"item1": 2})
value, default = self.cd.get_value("item1")
More information about the bind10-changes
mailing list