From 69bd0ed6a987791842d294e69f327b691ba25a5c Mon Sep 17 00:00:00 2001 From: Tim Ebbeke Date: Fri, 3 Apr 2026 22:09:54 +0200 Subject: [PATCH 1/3] Fixed tests with new parameter. --- ssh/test/ssh/common_fixture.hpp | 6 +- ssh/test/ssh/test_ssh_session.hpp | 249 ++++++++++++++++++------------ 2 files changed, 151 insertions(+), 104 deletions(-) diff --git a/ssh/test/ssh/common_fixture.hpp b/ssh/test/ssh/common_fixture.hpp index cb747918..f1ac65b6 100644 --- a/ssh/test/ssh/common_fixture.hpp +++ b/ssh/test/ssh/common_fixture.hpp @@ -125,7 +125,11 @@ namespace SecureShell::Test }, nullptr, nullptr, - nullptr + nullptr, + []() + { + std::cout << "connection lost." << std::endl; + } ); } diff --git a/ssh/test/ssh/test_ssh_session.hpp b/ssh/test/ssh/test_ssh_session.hpp index 6cef2699..ac390b68 100644 --- a/ssh/test/ssh/test_ssh_session.hpp +++ b/ssh/test/ssh/test_ssh_session.hpp @@ -25,25 +25,27 @@ namespace SecureShell::Test programDirectory / "temp" / "log.txt", programDirectory / "temp" / ("log_"s + ::testing::UnitTest::GetInstance()->current_test_info()->test_case_name() + "_"s + - ::testing::UnitTest::GetInstance()->current_test_info()->name() + ".txt")); + ::testing::UnitTest::GetInstance()->current_test_info()->name() + ".txt") + ); } } }; TEST_F(SshSessionTests, CanCreateSshSession) { - SecureShell::Session client{}; + SecureShell::Session client{[]() {}}; } TEST_F(SshSessionTests, CanStartAndStopSession) { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -59,10 +61,11 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -91,13 +94,15 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; - auto sessionScope = [this, &result]() { + auto sessionScope = [this, &result]() + { auto expectedSession = makePasswordTestSession(result->port); ASSERT_TRUE(expectedSession.has_value()); @@ -112,13 +117,15 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; - auto sessionScope = [this, &result]() { + auto sessionScope = [this, &result]() + { auto expectedSession = makePasswordTestSession(result->port); ASSERT_TRUE(expectedSession.has_value()); @@ -137,11 +144,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -161,18 +169,26 @@ namespace SecureShell::Test std::string channel2Output{}; std::promise awaiter1{}; - channelStartReading(channel1, [&channel1Output, &awaiter1](std::string const& output) { - channel1Output += output; - if (channel1Output.find("bashrc") != std::string::npos) - awaiter1.set_value(); - }); + channelStartReading( + channel1, + [&channel1Output, &awaiter1](std::string const& output) + { + channel1Output += output; + if (channel1Output.find("bashrc") != std::string::npos) + awaiter1.set_value(); + } + ); std::promise awaiter2{}; - channelStartReading(channel2, [&channel2Output, &awaiter2](std::string const& output) { - channel2Output += output; - if (channel2Output.find("bashrc") != std::string::npos) - awaiter2.set_value(); - }); + channelStartReading( + channel2, + [&channel2Output, &awaiter2](std::string const& output) + { + channel2Output += output; + if (channel2Output.find("bashrc") != std::string::npos) + awaiter2.set_value(); + } + ); channel1->write("ls -lah"); channel1->write("\r"); @@ -201,22 +217,26 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto session = makeSession( getSessionOptions(result->port), - +[](char const*, char* buf, std::size_t length, int, int, void*) { + +[](char const*, char* buf, std::size_t length, int, int, void*) + { static constexpr std::string_view pw = "wrong"; std::strncpy(buf, pw.data(), std::min(pw.size(), length - 1)); return 0; }, nullptr, nullptr, - nullptr); + nullptr, + []() {} + ); EXPECT_FALSE(session.has_value()); } @@ -225,22 +245,26 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto session = makeSession( getSessionOptions(result->port, "wrong"), - +[](char const*, char* buf, std::size_t length, int, int, void*) { + +[](char const*, char* buf, std::size_t length, int, int, void*) + { static constexpr std::string_view pw = "test"; std::strncpy(buf, pw.data(), std::min(pw.size(), length - 1)); return 0; }, nullptr, nullptr, - nullptr); + nullptr, + []() {} + ); EXPECT_FALSE(session.has_value()); } @@ -250,14 +274,17 @@ namespace SecureShell::Test std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); auto session = makeSession( getSessionOptions(0), - +[](char const*, char* buf, std::size_t length, int, int, void*) { + +[](char const*, char* buf, std::size_t length, int, int, void*) + { static constexpr std::string_view pw = "test"; std::strncpy(buf, pw.data(), std::min(pw.size(), length - 1)); return 0; }, nullptr, nullptr, - nullptr); + nullptr, + []() {} + ); auto diff = std::chrono::steady_clock::now() - start; // 1s leniency EXPECT_LT(diff, (connectTimeout + 1s)); @@ -269,14 +296,17 @@ namespace SecureShell::Test std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); auto session = makeSession( getSessionOptions(22, "test", "0100::"), - +[](char const*, char* buf, std::size_t length, int, int, void*) { + +[](char const*, char* buf, std::size_t length, int, int, void*) + { static constexpr std::string_view pw = "test"; std::strncpy(buf, pw.data(), std::min(pw.size(), length - 1)); return 0; }, nullptr, nullptr, - nullptr); + nullptr, + []() {} + ); auto diff = std::chrono::steady_clock::now() - start; // 1s leniency EXPECT_LT(diff, (connectTimeout + 1s)); @@ -288,12 +318,13 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - // result->command("exit"); - result->terminate(); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + // result->command("exit"); + result->terminate(); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -309,11 +340,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -339,11 +371,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -365,11 +398,15 @@ namespace SecureShell::Test channel1->close(); std::promise awaiter2{}; - channelStartReading(channel2, [&channel2Output, &awaiter2](std::string const& output) { - channel2Output += output; - if (channel2Output.find("bashrc") != std::string::npos) - awaiter2.set_value(); - }); + channelStartReading( + channel2, + [&channel2Output, &awaiter2](std::string const& output) + { + channel2Output += output; + if (channel2Output.find("bashrc") != std::string::npos) + awaiter2.set_value(); + } + ); channel2->write("ls -lah"); channel2->write("\r"); @@ -389,13 +426,15 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; - auto sessionScope = [this, &result]() { + auto sessionScope = [this, &result]() + { auto expectedSession = makePasswordTestSession(result->port); ASSERT_TRUE(expectedSession.has_value()); @@ -420,11 +459,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -446,11 +486,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -471,11 +512,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); @@ -498,11 +540,12 @@ namespace SecureShell::Test { auto [result, processThread] = createSshServer(); ASSERT_TRUE(result); - auto joiner = Nui::ScopeExit{[&]() noexcept { - result->command("exit"); - if (processThread.joinable()) - processThread.join(); - }}; + auto joiner = Nui::ScopeExit{[&]() noexcept + { + result->command("exit"); + if (processThread.joinable()) + processThread.join(); + }}; auto expectedSession = makePasswordTestSession(result->port); From 44947b3d211386c231f967d782b9ace3deb3ff55 Mon Sep 17 00:00:00 2001 From: Tim Ebbeke Date: Fri, 3 Apr 2026 23:58:07 +0200 Subject: [PATCH 2/3] Fixed test builds. --- backend/test/backend/real_server_tests.hpp | 10 +++++----- ssh/test/ssh/test_ssh_session.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/test/backend/real_server_tests.hpp b/backend/test/backend/real_server_tests.hpp index 27b5d509..3042b40a 100644 --- a/backend/test/backend/real_server_tests.hpp +++ b/backend/test/backend/real_server_tests.hpp @@ -82,10 +82,9 @@ class RealServerTests : public ::testing::Test .host = host, .port = port, .user = user, - .sshOptions = - Persistence::SshOptions{ - .connectTimeoutSeconds = connectTimeout.count(), - }, + .sshOptions = Persistence::SshOptions{ + .connectTimeoutSeconds = connectTimeout.count(), + }, }; } @@ -101,7 +100,8 @@ class RealServerTests : public ::testing::Test }, nullptr, nullptr, - nullptr + nullptr, + []() {} ); } diff --git a/ssh/test/ssh/test_ssh_session.hpp b/ssh/test/ssh/test_ssh_session.hpp index ac390b68..f17739e3 100644 --- a/ssh/test/ssh/test_ssh_session.hpp +++ b/ssh/test/ssh/test_ssh_session.hpp @@ -332,7 +332,7 @@ namespace SecureShell::Test auto session = std::move(expectedSession).value(); session->start(); - auto expectedChannel = session->createPtyChannel({.terminalType = "invalid"}).get(); + auto expectedChannel = session->createPtyChannel({.terminalType = "invalid", .termios = {}}).get(); ASSERT_FALSE(expectedChannel.has_value()); } From 3e979e27993ba2c9435efbfd3b37664f85fa6d4b Mon Sep 17 00:00:00 2001 From: Tim Ebbeke Date: Sat, 4 Apr 2026 00:18:13 +0200 Subject: [PATCH 3/3] Removed new broken quantum algorithms by default setting. mlkem76 fails with "Failed to construct client init buffer" --- persistence/source/persistence/state_holder_backend.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/persistence/source/persistence/state_holder_backend.cpp b/persistence/source/persistence/state_holder_backend.cpp index cac7e8d6..dbdb40f7 100644 --- a/persistence/source/persistence/state_holder_backend.cpp +++ b/persistence/source/persistence/state_holder_backend.cpp @@ -211,7 +211,13 @@ namespace Persistence #endif .usePasswordAuth = true, .logVerbosity = SshLogVerbosity::Off, + .keyExchangeAlgorithms = + "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256," + "ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1", .strictHostKeyCheck = true, +#ifdef __WIN32 + .bypassConfig = true, +#endif .connectTimeoutSeconds = 5, .localeEnv = "en_US.UTF-8", };