diff options
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 |