From: Michal 'vorner' Vaner Date: Sat, 28 Jul 2012 12:32:56 +0000 (+0200) Subject: [2113] Check the configuration by creating the list X-Git-Tag: trac2351_base~97^2~7^2~2^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e93f78639de53b00ae47c3232fedcbded6844d62;p=thirdparty%2Fkea.git [2113] Check the configuration by creating the list A small bugfix in the validation is included. There's no test for it directly - it is tested implicitly in the plugin test, but I wasn't able to reproduce it on small test spec files. If we weren't planning for replacement of the whole thing, it would need some investigation. --- diff --git a/src/bin/cfgmgr/plugins/datasrc_config_plugin.py b/src/bin/cfgmgr/plugins/datasrc_config_plugin.py index a3f204f103..2cd0e7a3fa 100644 --- a/src/bin/cfgmgr/plugins/datasrc_config_plugin.py +++ b/src/bin/cfgmgr/plugins/datasrc_config_plugin.py @@ -17,6 +17,8 @@ from isc.config.module_spec import module_spec_from_file from isc.util.file import path_search from bind10_config import PLUGIN_PATHS import isc.dns +import isc.datasrc +import json spec = module_spec_from_file(path_search('datasrc.spec', PLUGIN_PATHS)) def check(config): @@ -39,6 +41,13 @@ def check(config): except isc.dns.InvalidRRClass as irc: return str(irc) + dlist = isc.datasrc.ConfigurableClientList(rr_class) + try: + dlist.configure(json.dumps(classes.get(rr_class_str)), + False) + except isc.datasrc.Error as dse: + return str(dse) + 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 e703d5dbb0..5d87a16929 100644 --- a/src/bin/cfgmgr/plugins/tests/datasrc_test.py +++ b/src/bin/cfgmgr/plugins/tests/datasrc_test.py @@ -73,5 +73,27 @@ class DatasrcTest(unittest.TestCase): for c in ["IN", "CH", "HS"]: self.accept({c: []}) + def test_mem_ok(self): + """ + Test we accept an in-memory data source. It doesn't really matter + which one it is. We just want to make sure we accept something + and this one does not need any kind of path mangling to find + plugins. + """ + self.accept({"IN": [{ + "type": "MasterFiles", + "cache-enable": True, + "params": {} + }]}) + + def test_dstype_bad(self): + """ + The configuration is correct by the spec, but it would be rejected + by the client list. Check we reject it. + """ + self.reject({"IN": [{ + "type": "No such type" + }]}) + if __name__ == '__main__': unittest.main() diff --git a/src/lib/python/isc/config/module_spec.py b/src/lib/python/isc/config/module_spec.py index b79f928237..e5568f6a32 100644 --- a/src/lib/python/isc/config/module_spec.py +++ b/src/lib/python/isc/config/module_spec.py @@ -386,6 +386,8 @@ def _validate_format(spec, value, errors): return True def _validate_item(spec, full, data, errors): + if spec.get('item_type') == 'any': + return True if not _validate_type(spec, data, errors): return False elif type(data) == list: