diff --git a/CMakeLists.txt b/CMakeLists.txt index 447f4d65e3a9b460821f3ea33ac0e082edf44969..064babcb4e6d32dd0d5ead89d548575c76629716 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 0000000000000000000000000000000000000000..e7c36706ff028c94bc881889267cf3f0123a0409 --- /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 49e0b7333d2774515a6a31e4054f6694474e76eb..baa0b7998fc80644d48d2dffc483c01215cc0a01 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 612e01e17ec1d753743fe42bb9a190c23c96d2f0..fb806c36f040e5e972b09e2ccfe1690c070bf488 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 4b62179fa4ff13d467c6e1c17e06d85a434b490c..e9121865137a2291b5ba6e152e14bf669398250a 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");