diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-12-07 12:22:15 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-12-07 12:22:15 +0200 |
commit | 92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b (patch) | |
tree | a850643f7b86e6cebfddbeec98d7c372478d379c /lib/pluginloader/test | |
parent | Hostlist filter plugin can rewrite hostnames (diff) | |
download | smolbote-92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b.tar.xz |
Rewrite meson build scripts into cmakelists
Diffstat (limited to 'lib/pluginloader/test')
-rw-r--r-- | lib/pluginloader/test/pluginloader-sigmatch.cpp | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/lib/pluginloader/test/pluginloader-sigmatch.cpp b/lib/pluginloader/test/pluginloader-sigmatch.cpp index 0f4789a..fab8b5a 100644 --- a/lib/pluginloader/test/pluginloader-sigmatch.cpp +++ b/lib/pluginloader/test/pluginloader-sigmatch.cpp @@ -23,28 +23,40 @@ TEST_CASE("PluginLoader::signature_state") REQUIRE(PluginLoader::signature_state(true, true, true) >= PluginLoader::SigEnforced); } -TEST_CASE("files") +SCENARIO("PluginLoader") { - REQUIRE(qEnvironmentVariableIsSet("UNSIGNEDFILE")); - REQUIRE(qEnvironmentVariableIsSet("SIGNEDFILE")); - REQUIRE(qEnvironmentVariableIsSet("BADSIGNEDFILE")); -} - -TEST_CASE("PluginLoader::verify missing plugin") -{ - const auto state = PluginLoader::signature_state(false, false, false); - PluginLoader loader("", state); - - REQUIRE_FALSE(loader.verify()); - REQUIRE_FALSE(loader.errorString().isEmpty()); -} - -TEST_CASE("PluginLoader::verify signature ignored") -{ - const auto state = PluginLoader::signature_state(true, false, false); - PluginLoader loader(qgetenv("UNSIGNEDFILE"), state); - - REQUIRE(loader.verify()); + GIVEN("no plugin") { + const auto state = PluginLoader::signature_state(false, false, false); + PluginLoader loader("", state); + + CHECK_FALSE(loader.verify()); + CHECK_FALSE(loader.errorString().isEmpty()); + } + + GIVEN("A plugin with no signature") + { + const auto f = qgetenv("UNSIGNEDFILE"); + REQUIRE(!f.isEmpty()); + + WHEN("sig is ignored") { + const auto state = PluginLoader::signature_state(true, false, false); + PluginLoader loader(f, state); + + THEN("verify ok") { + REQUIRE(loader.verify()); + } + } + } + + GIVEN("A signed plugin") + { + REQUIRE(qEnvironmentVariableIsSet("SIGNEDFILE")); + } + + GIVEN("A badly signed plugin") + { + REQUIRE(qEnvironmentVariableIsSet("BADSIGNEDFILE")); + } } TEST_CASE("PluginLoader::verify signature checked [avialable]") @@ -96,4 +108,4 @@ TEST_CASE("PluginLoader::verify signature enforced [bad]") REQUIRE_FALSE(loader.verify()); REQUIRE_FALSE(loader.errorString().isEmpty()); -} +}
\ No newline at end of file |