Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
36af5032
Commit
36af5032
authored
May 11, 2011
by
Michal 'vorner' Vaner
Browse files
[trac875] The checking function
parent
f8c763ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/cfgmgr/plugins/tests/Makefile.am
View file @
36af5032
...
...
@@ -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
src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
View file @
36af5032
...
...
@@ -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'
]}))
...
...
src/bin/cfgmgr/plugins/tsig_keys.py
View file @
36af5032
...
...
@@ -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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment