summaryrefslogtreecommitdiffstats
path: root/tests/config/keyfile/load_ta.test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/config/keyfile/load_ta.test.lua')
-rw-r--r--tests/config/keyfile/load_ta.test.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/config/keyfile/load_ta.test.lua b/tests/config/keyfile/load_ta.test.lua
new file mode 100644
index 0000000..bfe851b
--- /dev/null
+++ b/tests/config/keyfile/load_ta.test.lua
@@ -0,0 +1,37 @@
+-- test fixtures
+
+-- count warning message, fail with other than allowed message
+warn_msg = {}
+overriding_msg="[ ta ] warning: overriding previously set trust anchors for ."
+warn_msg[overriding_msg] = 0
+function warn(fmt, ...)
+ msg = string.format(fmt, ...)
+ if warn_msg[msg] == nil then
+ fail(string.format("Not allowed warn message: %s", msg))
+ else
+ warn_msg[msg] = warn_msg[msg] + 1
+ end
+end
+
+-- tests
+
+boom(trust_anchors.add_file, {'nonwriteable/root.keys', false},
+ "Managed trust anchor in non-writeable directory")
+
+boom(trust_anchors.add_file, {'nonexist.keys', true},
+ "Nonexist unmanaged trust anchor file")
+
+trust_anchors.add_file('root2.keys', true)
+trust_anchors.add_file('root1.keys', true)
+is(warn_msg[overriding_msg], 1, "Warning message when override trust anchors")
+
+is(trust_anchors.keysets['\0'][1].key_tag, 19036,
+ "Loaded KeyTag from root1.keys")
+
+local function test_loading_from_cmdline()
+ is(trust_anchors.keysets['\0'][1].key_tag , 20326,
+ "Loaded KeyTag from cmdline file root2.keys")
+ is(warn_msg[overriding_msg], 2, "Warning message when override trust anchors")
+end
+
+return {test_loading_from_cmdline}