Commit 36af5032 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac875] The checking function

parent f8c763ef
......@@ -11,7 +11,7 @@ endif
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env B10_TEST_PLUGIN_DIR=$(abs_srcdir)/..:$(abs_builddir)/.. \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr:$(abs_top_builddir)/src/lib/dns/python/.libs \
$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ; \
done
......@@ -74,7 +74,7 @@ class TSigKeysTest(unittest.TestCase):
"""
Test we reject when we have multiple keys with the same name.
"""
self.assertEqual("Multiple TSIG keys with name 'test.key'",
self.assertEqual("Multiple TSIG keys with name 'test.key.'",
tsig_keys.check({'keys':
['test.key:QklORCAxMCBpcyBjb29sCg==',
'test.key:b3RoZXIK']}))
......
......@@ -15,11 +15,30 @@
from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from isc.dns import TSIGKey
import pydnspp
from bind10_config import PLUGIN_PATHS
spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))
def check(config):
pass
# Check the data layout first
errors=[]
if not spec.validate_config(False, config, errors):
return ' '.join(errors)
# Get the list of keys, if any
keys = config.get('keys', [])
# Run trough them, check they can be constructed and there are no dupes
keyNames = set()
for key in keys:
try:
name = str(TSIGKey(key).get_key_name())
except pydnspp.InvalidParameter as e:
return "TSIG: " + str(e)
if name in keyNames:
return "Multiple TSIG keys with name '" + name + "'"
keyNames.add(name)
# No error found, so let's assume it's OK
return None
def load():
return (spec, check)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment