Skip to content
Snippets Groups Projects
Verified Commit 7d29907d authored by Vitezslav Kriz's avatar Vitezslav Kriz Committed by Petr Špaček
Browse files

keyfile: added tests

parent 6c2db2b5
No related branches found
No related tags found
1 merge request!358Split CLI for managed and unmanaged trust anchor modes
--keyfile-ro root.keys --keyfile root.keys
\ No newline at end of file
dofile('./test_utils.lua') -- load test utilities
quit()
1
\ No newline at end of file
. 172800 DNSKEY 257 3 8 AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjFFVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoXbfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaDX6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpzW5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relSQageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulqQxA+Uk1ihz0= ; Valid: ; KeyTag:19036
. 172800 DNSKEY 257 3 8 AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU= ; Valid: ; KeyTag:20326
--keyfile-ro root2.keys
\ No newline at end of file
dofile('./test_utils.lua') -- load test utilities
-- 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("Not allowed warn message: %s", msg)
else
warn_msg[msg] = warn_msg[msg] + 1
end
end
-- test
if pcall(trust_anchors.add_file, 'nonwriteable/root.keys', false) then
fail("Managed trsut anchor file in directory without write access should fail")
end
if pcall(trust_anchors.add_file, 'nonexist.keys', true) then
fail("Nonexist unmanaged file should fail")
end
trust_anchors.add_file('root2.keys', true)
trust_anchors.add_file('root1.keys', true)
if warn_msg[overriding_msg] ~= 1 then
fail("Missing warning message for override: %s", overriding_msg)
end
if trust_anchors.keysets['\0'][1].key_tag ~= 19036 then
fail("Not loaded or loaded trust anchor from root1.keys")
end
-- run test after processed config file
ev = event.after(0, function (ev)
-- check overiding trust anchor from cmdline args
if trust_anchors.keysets['\0'][1].key_tag ~= 20326 then
fail("Not loaded or loaded trust anchor from root2.keys")
end
if warn_msg[overriding_msg] ~= 2 then
fail("Missing warning message for override: %s", overriding_msg)
end
quit()
end)
......@@ -38,4 +38,4 @@ function M.not_contains(table, value, message)
return contains(fail, pass, table, value, message)
end
return M
\ No newline at end of file
return M
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment