Skip to content
Snippets Groups Projects
Commit 2de49a5c authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Add check if CAOSDB_SERVER_CERT was set

parent ad7f2d22
Branches
No related tags found
2 merge requests!41Release 0.3.0,!39Add test for connection error if certificate is not valid
Pipeline #57527 passed
......@@ -78,6 +78,7 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
auto port = std::stoi(port_str);
const auto *const host = linkahead::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = linkahead::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string());
EXPECT_FALSE(path.empty()) << "CAOSDB_SERVER_CERT must be set to run this test.";
auto cert = PemFileCertificateProvider(path);
auto config = TlsConnectionConfiguration(host, port, cert);
......@@ -95,6 +96,8 @@ TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
auto port = std::stoi(port_str);
const auto *const host = linkahead::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = linkahead::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string());
EXPECT_FALSE(path.empty()) << "CAOSDB_SERVER_CERT must be set to run this test.";
const auto *const user = "not-a-user-23461237";
const auto *const password = "very-c-cred";
......@@ -115,6 +118,8 @@ TEST(test_connection, connection_ssl_authentication_error_wrong_certificate) {
auto port = std::stoi(port_str);
const auto *const host = linkahead::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = linkahead::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string());
EXPECT_FALSE(path.empty()) << "CAOSDB_SERVER_CERT must be set to run this test.";
// TODO (JTS): This is a hack. We should use the credentials in the linkahead-client.json
const auto *const user = "admin";
......@@ -150,12 +155,11 @@ X+F/0oljKZKJ2SswKDLztD0CY3VZhdDHfWlfIls1ttax4eEN1HgMtTyZ0JYdr9Iy
Dbc8hkR8vIDcwFu31jiHx/BWmv+pjzx4F2qX7tgTG8wM3WHJwqzgrA1IeLliQpo6
yVMsKq9927ZJXZbL/ewiA1Mm6IBe+SpJ8IafmUk=
-----END CERTIFICATE-----)");
auto bad_config = TlsConnectionConfiguration(host, port, bad_cert, auth);
auto bad_connection = Connection(bad_config);
auto bad_status = bad_connection.RetrieveVersionInfoNoExceptions();
EXPECT_EQ(bad_status.GetCode(), StatusCode::CONNECTION_ERROR);
}
TEST(test_connection, connection_ssl_authentication_success) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment