From 76ad0c60b7082b7d3ad03d059aed0bb6c7624f79 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Tue, 6 Jul 2021 11:11:28 +0200 Subject: [PATCH] WIP: conan --- CMakeLists.txt | 10 ++++++++++ README.md | 14 ++++++++++++++ conanfile.txt | 1 - test/CMakeLists.txt | 2 +- test/test_connection.cpp | 27 +++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 447f4d6..064babc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,16 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) 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 add_compile_options(-Wno-unused-parameter -Wno-unused-result -g) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e7c3670 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# 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. + + diff --git a/conanfile.txt b/conanfile.txt index 49e0b73..baa0b79 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,7 +1,6 @@ [requires] caosdb/0.0.2 gtest/1.11.0 -boost/1.76.0 [generators] cmake diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 612e01e..fb806c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -75,7 +75,7 @@ foreach (i RANGE "${len_test_cases}") target_link_libraries(${test_case_name} PRIVATE ${CONAN_LIBS_CAOSDB} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_GRPC} ${CONAN_LIBS_ABSEIL} ${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}) set_target_properties(${test_case_name} PROPERTIES diff --git a/test/test_connection.cpp b/test/test_connection.cpp index 4b62179..e912186 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -54,7 +54,8 @@ TEST(test_connection, connect_somehost_42347_fails) { } 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"); auto config = std::make_shared<InsecureCaosDBConnectionConfig>(host, port); @@ -63,8 +64,9 @@ TEST(test_connection, connection_insecure_authentication_error) { EXPECT_THROW(connection.getVersionInfo(), AuthenticationError); } -TEST(test_connection, connection_ssl_authentication_error) { - auto port = 8443; +TEST(test_connection, connection_ssl_authentication_error_anonymous) { + 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()); @@ -75,8 +77,25 @@ TEST(test_connection, connection_ssl_authentication_error) { 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) { - 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 path = caosdb::utils::get_env_var("CAOSDB_SERVER_CA_PEM", std::string()); const auto user = caosdb::utils::get_env_var("CAOSDB_USER", "admin"); -- GitLab