From 92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 7 Dec 2020 12:22:15 +0200 Subject: Rewrite meson build scripts into cmakelists --- lib/pluginloader/test/pluginloader-sigmatch.cpp | 56 +++++++++++++++---------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'lib/pluginloader/test') 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 -- cgit v1.2.1