Skip to content
Snippets Groups Projects
Verified Commit 76ad0c60 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: conan

parent d8f1c30e
No related branches found
No related tags found
No related merge requests found
Pipeline #9879 passed
...@@ -32,6 +32,16 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) ...@@ -32,6 +32,16 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup() conan_basic_setup()
# fix grpc - remove unsecure (no-op ssl implementations)
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC
"${CONAN_LIBS_GRPC}")
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS_GRPC
"${CONAN_PKG_LIBS_GRPC}")
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS
"${CONAN_LIBS}")
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS
"${CONAN_PKG_LIBS}")
# ignore some warnings here # ignore some warnings here
add_compile_options(-Wno-unused-parameter -Wno-unused-result -g) add_compile_options(-Wno-unused-parameter -Wno-unused-result -g)
......
# caosdb-cppinttest
Integration tests for caosdb-cpplib and the caosdb-server
# Run tests
1. `mkdir build && cd build/`
2. `conan install .. -s "compiler.libcxx=libstdc++11"`
3. `cmake -B . ..`
4. `cmake --build .`
5. Setup env vars
6. Run with `ctest` in the build directory.
[requires] [requires]
caosdb/0.0.2 caosdb/0.0.2
gtest/1.11.0 gtest/1.11.0
boost/1.76.0
[generators] [generators]
cmake cmake
...@@ -75,7 +75,7 @@ foreach (i RANGE "${len_test_cases}") ...@@ -75,7 +75,7 @@ foreach (i RANGE "${len_test_cases}")
target_link_libraries(${test_case_name} PRIVATE ${CONAN_LIBS_CAOSDB} target_link_libraries(${test_case_name} PRIVATE ${CONAN_LIBS_CAOSDB}
${CONAN_LIBS_GTEST} ${CONAN_LIBS_GRPC} ${CONAN_LIBS_ABSEIL} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_GRPC} ${CONAN_LIBS_ABSEIL}
${CONAN_LIBS_OPENSSL} ${CONAN_LIBS_C-ARES} ${CONAN_LIBS_BZIP2} ${CONAN_LIBS_OPENSSL} ${CONAN_LIBS_C-ARES} ${CONAN_LIBS_BZIP2}
${CONAN_LIBS_PROTOBUF} ${CONAN_LIBS_ZLIB}) ${CONAN_LIBS_PROTOBUF} ${CONAN_LIBS_ZLIB} ${CONAN_LIBS_RE2})
target_include_directories(${test_case_name} PUBLIC ${CONAN_INCLUDE_DIRS}) target_include_directories(${test_case_name} PUBLIC ${CONAN_INCLUDE_DIRS})
set_target_properties(${test_case_name} set_target_properties(${test_case_name}
PROPERTIES PROPERTIES
......
...@@ -54,7 +54,8 @@ TEST(test_connection, connect_somehost_42347_fails) { ...@@ -54,7 +54,8 @@ TEST(test_connection, connect_somehost_42347_fails) {
} }
TEST(test_connection, connection_insecure_authentication_error) { TEST(test_connection, connection_insecure_authentication_error) {
auto port = 8080; auto port_str = caosdb::utils::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTP", "8080");
auto port = std::stoi(port_str);
const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost"); const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost");
auto config = std::make_shared<InsecureCaosDBConnectionConfig>(host, port); auto config = std::make_shared<InsecureCaosDBConnectionConfig>(host, port);
...@@ -63,8 +64,9 @@ TEST(test_connection, connection_insecure_authentication_error) { ...@@ -63,8 +64,9 @@ TEST(test_connection, connection_insecure_authentication_error) {
EXPECT_THROW(connection.getVersionInfo(), AuthenticationError); EXPECT_THROW(connection.getVersionInfo(), AuthenticationError);
} }
TEST(test_connection, connection_ssl_authentication_error) { TEST(test_connection, connection_ssl_authentication_error_anonymous) {
auto port = 8443; auto port_str = caosdb::utils::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str);
const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost"); const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost");
const auto path = caosdb::utils::get_env_var("CAOSDB_SERVER_CA_PEM", std::string()); const auto path = caosdb::utils::get_env_var("CAOSDB_SERVER_CA_PEM", std::string());
...@@ -75,8 +77,25 @@ TEST(test_connection, connection_ssl_authentication_error) { ...@@ -75,8 +77,25 @@ TEST(test_connection, connection_ssl_authentication_error) {
EXPECT_THROW(connection.getVersionInfo(), AuthenticationError); EXPECT_THROW(connection.getVersionInfo(), AuthenticationError);
} }
TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
auto port_str = caosdb::utils::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str);
const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost");
const auto path = caosdb::utils::get_env_var("CAOSDB_SERVER_CA_PEM", std::string());
const auto *const user = "not-a-user-23461237";
const auto *const password = "very-c-cred";
auto auth = std::make_shared<PlainPasswordAuthenticator>(user, password);
auto ssloptions = std::make_shared<PemFileCACertProvider>(path);
auto config = std::make_shared<SslCaosDBConnectionConfig>(host, port, ssloptions, auth);
auto connection = CaosDBConnection(config);
EXPECT_THROW(connection.getVersionInfo(), AuthenticationError);
}
TEST(test_connection, connection_ssl_authentication_success) { TEST(test_connection, connection_ssl_authentication_success) {
auto port = 8080; auto port_str = caosdb::utils::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str);
const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost"); const auto host = caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost");
const auto path = caosdb::utils::get_env_var("CAOSDB_SERVER_CA_PEM", std::string()); const auto path = caosdb::utils::get_env_var("CAOSDB_SERVER_CA_PEM", std::string());
const auto user = caosdb::utils::get_env_var("CAOSDB_USER", "admin"); const auto user = caosdb::utils::get_env_var("CAOSDB_USER", "admin");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment