Skip to content

Commit

Permalink
Make ssl related unit tests verbosity not print debug output by default
Browse files Browse the repository at this point in the history
These unit tests are quite nosiy on a normal unit test run. Lower the
SSL verbosity for them to avoid a lot of debug output during unit tests.

Signed-off-by: Arne Schwabe <[email protected]>
  • Loading branch information
schwabe authored and Jenkins-dev committed Aug 22, 2024
1 parent 3fe0138 commit e46f663
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/unittests/test_acc_certcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ I/+4kAlXuAKdhsXohHeBhC2ijg/kTOMDxEbEVv+SkCIUyM+dB8UtlPKOH9HEL5Xi
+BpDSqO6Bha5+NAVUU7OdDsnzRwSWaD6lwIBAgICAOE=
-----END DH PARAMETERS-----)";

static constexpr int debug_output = 0;

static inline bool xfer_oneway(SslApiBuilder &sender, SslApiBuilder &recv, std::string out)
{
if (sender.get().read_ciphertext_ready())
Expand Down Expand Up @@ -283,12 +285,12 @@ static inline void xfer(AccHandshaker &cli, AccHandshaker &serv)

do
{
if (sdata)
if (sdata && debug_output)
std::cout << "CLIENT <-- SERVER: " << sdata->size() << " bytes\n";
cdata = cli.process_msg(sdata);
try
{
if (cdata)
if (cdata && debug_output)
std::cout << "CLIENT --> SERVER: " << cdata->size() << " bytes\n";
sdata = serv.process_msg(cdata);
}
Expand Down Expand Up @@ -319,6 +321,8 @@ SSLLib::SSLAPI::Config::Ptr CreateServerConfig(const std::string &pvtKey,
config->load_cert(cert);
config->load_private_key(pvtKey);
config->load_ca(ca, false);
// Do not log extra data during unit test
config->set_debug_level(debug_output);

return config;
}
Expand All @@ -344,6 +348,9 @@ SSLLib::SSLAPI::Config::Ptr CreateClientConfig(const std::string &pvtKey,
else
config->load_ca(ca, false);

// Do not log extra data during unit test
config->set_debug_level(debug_output);

return config;
}

Expand Down
8 changes: 8 additions & 0 deletions test/unittests/test_sslctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ I/+4kAlXuAKdhsXohHeBhC2ijg/kTOMDxEbEVv+SkCIUyM+dB8UtlPKOH9HEL5Xi
TEST(sslctx_ut, create_config)
{
SSLLib::SSLAPI::Config::Ptr config = new SSLLib::SSLAPI::Config;
// Do not log extra data during unit test
config->set_debug_level(0);
EXPECT_TRUE(config);
}

Expand All @@ -263,6 +265,9 @@ TEST(sslctx_ut, config_new_factory_server)
config->load_private_key(pvt_key_txt);
config->load_ca(cert_txt, false);

// Do not log extra data during unit test
config->set_debug_level(0);

auto factory_server = config->new_factory();
EXPECT_TRUE(factory_server);

Expand All @@ -283,6 +288,9 @@ TEST(sslctx_ut, config_new_factory_client)
config->load_private_key(pvt_key_txt);
config->load_ca(cert_txt, false);

// Do not log extra data during unit test
config->set_debug_level(0);

auto factory_client = config->new_factory();
EXPECT_TRUE(factory_client);

Expand Down

0 comments on commit e46f663

Please sign in to comment.