summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-03-26 15:58:13 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-03-26 15:58:13 +0000
commit1d04f87b31a03930bcbc96c8bf7f8a9d6b7075b4 (patch)
treee9ec7a00be664564372749530ef7c0a58780192f
parent15e3a715df2dffb343b88b794634e701eeba8047 (diff)
downloadlorry-controller-1d04f87b31a03930bcbc96c8bf7f8a9d6b7075b4.tar.gz
Add a test for an unsupported section type
-rw-r--r--lorrycontroller/readconf.py5
-rw-r--r--yarns.webapp/060-validation.yarn8
2 files changed, 12 insertions, 1 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index b0124a9..64599e4 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -69,8 +69,11 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
existing_lorries = self.without_lorries_for_trovehost(
statedb, existing_lorries, section['trovehost'])
else:
- logging.warning(
+ logging.error(
'Unknown section in configuration: %r', section)
+ return (
+ 'ERROR: Unknown section type in configuration: %r' %
+ section)
for path in existing_lorries:
statedb.remove_lorry(path)
diff --git a/yarns.webapp/060-validation.yarn b/yarns.webapp/060-validation.yarn
index 508f1f2..b7b1a66 100644
--- a/yarns.webapp/060-validation.yarn
+++ b/yarns.webapp/060-validation.yarn
@@ -75,6 +75,14 @@ an artifact of how yarn steps are implemented and is OK.
THEN response matches "ERROR"
AND STATEDB is empty
+What about a section that has a `type` field, but it's set to a
+non-sensical value?
+
+ GIVEN a lorry-controller.conf in CONFGIT containing "[{"type": "BACKUPS!"}]"
+ WHEN admin makes request POST /1.0/read-configuration with dummy=value
+ THEN response matches "ERROR"
+ AND STATEDB is empty
+
Clean up at the end.
FINALLY WEBAPP terminates