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.
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):
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():
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()
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: