BIND 10 trac2113, updated. 28d84a9af289a4fbbdef1eb7da8e3674dc0de9af [2113] Check the MasterFiles params
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Jul 28 16:37:15 UTC 2012
The branch, trac2113 has been updated
via 28d84a9af289a4fbbdef1eb7da8e3674dc0de9af (commit)
from e93f78639de53b00ae47c3232fedcbded6844d62 (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 28d84a9af289a4fbbdef1eb7da8e3674dc0de9af
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Jul 28 18:31:21 2012 +0200
[2113] Check the MasterFiles params
They are skipped in the ClientList, so not checked at all.
-----------------------------------------------------------------------
Summary of changes:
src/bin/cfgmgr/plugins/datasrc_config_plugin.py | 20 ++++++++-
src/bin/cfgmgr/plugins/tests/datasrc_test.py | 53 ++++++++++++++++++++++-
2 files changed, 70 insertions(+), 3 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/plugins/datasrc_config_plugin.py b/src/bin/cfgmgr/plugins/datasrc_config_plugin.py
index 2cd0e7a..88fbc61 100644
--- a/src/bin/cfgmgr/plugins/datasrc_config_plugin.py
+++ b/src/bin/cfgmgr/plugins/datasrc_config_plugin.py
@@ -19,6 +19,8 @@ from bind10_config import PLUGIN_PATHS
import isc.dns
import isc.datasrc
import json
+import os.path
+
spec = module_spec_from_file(path_search('datasrc.spec', PLUGIN_PATHS))
def check(config):
@@ -42,12 +44,26 @@ def check(config):
return str(irc)
dlist = isc.datasrc.ConfigurableClientList(rr_class)
+ client_config = classes.get(rr_class_str)
try:
- dlist.configure(json.dumps(classes.get(rr_class_str)),
- False)
+ dlist.configure(json.dumps(client_config), False)
except isc.datasrc.Error as dse:
return str(dse)
+ for client in client_config:
+ if client['type'] == 'MasterFiles':
+ if not client.get('cache-enable', False):
+ return 'The cache must be enabled in MasterFiles type'
+ params = client.get('params')
+ if type(params) != dict:
+ return 'Params of MasterFiles must be a named set'
+ for name in params:
+ try:
+ isc.dns.Name(name)
+ except Exception as e: # There are many related exceptions
+ return str(e)
+ if not os.path.exists(params[name]):
+ return "Master file " + params[name] + " does not exist"
return None
def load():
diff --git a/src/bin/cfgmgr/plugins/tests/datasrc_test.py b/src/bin/cfgmgr/plugins/tests/datasrc_test.py
index 5d87a16..26d5fe7 100644
--- a/src/bin/cfgmgr/plugins/tests/datasrc_test.py
+++ b/src/bin/cfgmgr/plugins/tests/datasrc_test.py
@@ -17,6 +17,7 @@
import sys
import os
sys.path.extend(os.environ["B10_TEST_PLUGIN_DIR"].split(':'))
+import isc.log
import datasrc_config_plugin
import unittest
@@ -95,5 +96,55 @@ class DatasrcTest(unittest.TestCase):
"type": "No such type"
}]})
+ def test_invalid_mem_params(self):
+ """
+ The client list skips in-memory sources. So we check it locally that
+ invalid things are rejected.
+ """
+ # The 'params' key is mandatory for MasterFiles
+ self.reject({"IN": [{
+ "type": "MasterFiles",
+ "cache-enable": True
+ }]})
+ # The cache must be enabled
+ self.reject({"IN": [{
+ "type": "MasterFiles",
+ "cache-enable": False,
+ "params": {}
+ }]})
+ self.reject({"IN": [{
+ "type": "MasterFiles",
+ "params": {}
+ }]})
+ # Bad params type
+ self.reject({"IN": [{
+ "type": "MasterFiles",
+ "cache-enable": True,
+ "params": []
+ }]})
+ # Bad name
+ self.reject({"IN": [{
+ "type": "MasterFiles",
+ "cache-enable": True,
+ "params": {
+ "example....org.": '/file/does/not/exist'
+ }
+ }]})
+
+ def test_no_such_file_mem(self):
+ """
+ We also check the existance of master files. Not the actual content,
+ though.
+ """
+ self.reject({"IN": [{
+ "type": "MasterFiles",
+ "cache-enable": True,
+ "params": {
+ "example.org.": '/file/does/not/exist'
+ }
+ }]})
+
if __name__ == '__main__':
- unittest.main()
+ isc.log.init("bind10")
+ isc.log.resetUnitTestRootLogger()
+ unittest.main()
More information about the bind10-changes
mailing list