diff options
author | louiz’ <louiz@louiz.org> | 2017-04-30 15:04:40 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-04-30 15:14:54 +0200 |
commit | 7b3e0e0cf3eddd3537455a3605b04a48ee663f47 (patch) | |
tree | 06658235b0082b1f173c6114d4aeac2388540297 /tests | |
parent | 1472adfa77f9c3a03967e723d8460f33544b545d (diff) | |
download | biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.tar.gz biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.tar.bz2 biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.tar.xz biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.zip |
Make botan’s policy configurable from a file
fix #3244
Diffstat (limited to 'tests')
-rw-r--r-- | tests/network.cpp | 42 | ||||
-rw-r--r-- | tests/utils.cpp | 15 |
2 files changed, 56 insertions, 1 deletions
diff --git a/tests/network.cpp b/tests/network.cpp new file mode 100644 index 0000000..52e9ae3 --- /dev/null +++ b/tests/network.cpp @@ -0,0 +1,42 @@ +#include "catch.hpp" +#include <network/tls_policy.hpp> + +TEST_CASE("tls_policy") +{ + BiboumiTLSPolicy policy; + const auto default_minimum_signature_strength = policy.minimum_signature_strength(); + const auto default_session_ticket_lifetime = policy.session_ticket_lifetime(); + const auto default_minimum_rsa_bits = policy.minimum_rsa_bits(); + + policy.load("does not exist"); + WHEN("we fail to load the file") + { + THEN("all values are the default ones") + { + CHECK(policy.minimum_signature_strength() == default_minimum_signature_strength); + CHECK(policy.minimum_rsa_bits() == default_minimum_rsa_bits); + } + AND_WHEN("we load a valid first file") + { + std::istringstream iss("minimum_signature_strength = 128\nminimum_rsa_bits=12\n"); + policy.load(iss); + THEN("the specified values are updated, and the rest is still the default") + { + CHECK(policy.minimum_signature_strength() == 128); + CHECK(policy.minimum_rsa_bits() == 12); + CHECK(policy.session_ticket_lifetime() == default_session_ticket_lifetime); + } + AND_WHEN("we load a second file") + { + std::istringstream iss("minimum_signature_strength = 15"); + policy.load(iss); + THEN("the specified values are updated, and the rest is untouched") + { + CHECK(policy.minimum_signature_strength() == 15); + CHECK(policy.minimum_rsa_bits() == 12); + CHECK(policy.session_ticket_lifetime() == default_session_ticket_lifetime); + } + } + } + } +} diff --git a/tests/utils.cpp b/tests/utils.cpp index b8a3e75..c5ef7e7 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -10,6 +10,7 @@ #include <utils/time.hpp> #include <utils/system.hpp> #include <utils/scopeguard.hpp> +#include <utils/dirname.hpp> using namespace std::string_literals; @@ -157,4 +158,16 @@ TEST_CASE("system_name") { CHECK(utils::get_system_name() != "Unknown"); CHECK(!utils::get_system_name().empty()); -}
\ No newline at end of file +} + +TEST_CASE("dirname") +{ + CHECK(utils::dirname("/") == "/"); + CHECK(utils::dirname("coucou.txt") == "./"); + CHECK(utils::dirname("../coucou.txt") == "../"); + CHECK(utils::dirname("/etc/biboumi/coucou.txt") == "/etc/biboumi/"); + CHECK(utils::dirname("..") == ".."); + CHECK(utils::dirname("../") == "../"); + CHECK(utils::dirname(".") == "."); + CHECK(utils::dirname("./") == "./"); +} |