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

Merge branch 'release-0.3.0' into 'main'

Release 0.3.0

See merge request !41
parents b05ab59b ae9441ed
Branches main
No related tags found
1 merge request!41Release 0.3.0
Pipeline #64301 passed
Showing with 1008 additions and 756 deletions
...@@ -5,21 +5,19 @@ COPY .docker/wait-for-it.sh /wait-for-it.sh ...@@ -5,21 +5,19 @@ COPY .docker/wait-for-it.sh /wait-for-it.sh
# build and install caosdb-cpplib # build and install caosdb-cpplib
WORKDIR /libcaosdb/ WORKDIR /libcaosdb/
RUN mkdir build RUN conan profile detect -f
WORKDIR /libcaosdb/build RUN make conan
RUN conan create -s "compiler.libcxx=libstdc++11" -o caosdb:build_acm=True .. "caosdb/$(conan inspect --raw version ..)@_/_"
COPY . /caosdb-cppinttest COPY . /caosdb-cppinttest
WORKDIR /caosdb-cppinttest WORKDIR /caosdb-cppinttest
RUN rm -rf .git RUN rm -rf .git
COPY .docker/caosdb-client.json /caosdb-client.json COPY .docker/caosdb-client.json /caosdb-client.json
COPY .docker/linkahead-client.json /linkahead-client.json
# build and run tests # Build and run tests.
CMD mkdir build && \ # If no other command is given to the Docker image
cd build && \ CMD make build-release &&\
conan install .. -s "compiler.libcxx=libstdc++11" && \ cd build/Release &&\
cmake .. && \
cmake --build . && \
/wait-for-it.sh caosdb-server:10443 -t 500 -- \ /wait-for-it.sh caosdb-server:10443 -t 500 -- \
ctest -V ctest -V
#!/bin/bash #!/bin/bash
# ** header v3.0 # ** header v3.0
# This file is a part of the CaosDB Project. # This file is a part of the LinkAhead Project.
# #
# Copyright (C) 2019 Daniel Hornung, Göttingen # Copyright (C) 2019 Daniel Hornung, Göttingen
# #
......
{
"connections": {
"default": {
"host": "caosdb-server",
"port": 8443,
"server_certificate_path": "/cert/caosdb.cert.pem",
"authentication": {
"type": "plain",
"username": "admin",
"password": "caosdb"
}
}
}
}
...@@ -5,7 +5,7 @@ services: ...@@ -5,7 +5,7 @@ services:
environment: environment:
CAOSDB_SERVER_HOST: caosdb-server CAOSDB_SERVER_HOST: caosdb-server
CAOSDB_SERVER_CERT: /cert/caosdb.cert.pem CAOSDB_SERVER_CERT: /cert/caosdb.cert.pem
CAOSDB_CLIENT_CONFIGURATION: /caosdb-client.json LINKAHEAD_CLIENT_CONFIGURATION: /linkahead-client.json
networks: networks:
- docker_caosnet - docker_caosnet
volumes: volumes:
......
# General # General
build/ build/
include/libcaosdbConfig.h include/liblinkaheadConfig.h
cert/ cert/
.*
# CMake # CMake
CMakeLists.txt.user CMakeLists.txt.user
......
# #
# This file is a part of the CaosDB Project. # This file is a part of the LinkAhead Project.
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
...@@ -38,7 +38,7 @@ variables: ...@@ -38,7 +38,7 @@ variables:
TRIGGERED_BY_HASH: $CI_COMMIT_SHORT_SHA TRIGGERED_BY_HASH: $CI_COMMIT_SHORT_SHA
# This is the caosdb-deploy branch which build the images for caosdb-server and caosdb-mysql # This is the caosdb-deploy branch which builds the images for caosdb-server and caosdb-mysql
DEPLOY_REF: dev DEPLOY_REF: dev
DEFAULT_CAOSDB_TAG: dev DEFAULT_CAOSDB_TAG: dev
...@@ -78,16 +78,12 @@ build-testenv: &build-testenv ...@@ -78,16 +78,12 @@ build-testenv: &build-testenv
stage: setup stage: setup
timeout: 2h timeout: 2h
needs: [] needs: []
only:
- pipelines
- schedules
- web
script: script:
- *env - *env
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
#build testenv image #build testenv image
- docker pull $CPPLIB_REGISTRY_IMAGE || { CPPLIB_REGISTRY_IMAGE="$CI_REGISTRY/caosdb/src/caosdb-cpplib/testenv:dev" ; docker pull $CPPLIB_REGISTRY_IMAGE ; } - docker pull $CPPLIB_REGISTRY_IMAGE || { CPPLIB_REGISTRY_IMAGE="$CI_REGISTRY/caosdb/src/caosdb-cpplib/testenv:dev" ; echo "Using cpplib@dev instead."; docker pull $CPPLIB_REGISTRY_IMAGE ; }
- docker build - docker build
--build-arg CPPLIB_REGISTRY_IMAGE=$CPPLIB_REGISTRY_IMAGE --build-arg CPPLIB_REGISTRY_IMAGE=$CPPLIB_REGISTRY_IMAGE
--file .docker/Dockerfile --file .docker/Dockerfile
...@@ -104,12 +100,8 @@ build-test: ...@@ -104,12 +100,8 @@ build-test:
tags: [ docker ] tags: [ docker ]
stage: build stage: build
script: script:
- echo $PWD - echo $PWD
- mkdir build - make build-release
- cd build
- conan install .. -s "compiler.libcxx=libstdc++11"
- cmake ..
- cmake --build .
test: test:
......
...@@ -28,6 +28,7 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md) ...@@ -28,6 +28,7 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md)
- [ ] Up-to-date CHANGELOG.md (or not necessary) - [ ] Up-to-date CHANGELOG.md (or not necessary)
- [ ] Up-to-date JSON schema (or not necessary) - [ ] Up-to-date JSON schema (or not necessary)
- [ ] Appropriate user and developer documentation (or not necessary) - [ ] Appropriate user and developer documentation (or not necessary)
- Update / write published documentation (`make doc`).
- How do I use the software? Assume "stupid" users. - How do I use the software? Assume "stupid" users.
- How do I develop or debug the software? Assume novice developers. - How do I develop or debug the software? Assume novice developers.
- [ ] Annotations in code (Gitlab comments) - [ ] Annotations in code (Gitlab comments)
...@@ -41,7 +42,8 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md) ...@@ -41,7 +42,8 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md)
- [ ] I understand the intent of this MR - [ ] I understand the intent of this MR
- [ ] All automated tests pass - [ ] All automated tests pass
- [ ] Up-to-date CHANGELOG.md (or not necessary) - [ ] Up-to-date CHANGELOG.md (or not necessary)
- [ ] Appropriate user and developer documentation (or not necessary) - [ ] Appropriate user and developer documentation (or not necessary), also in published
documentation.
- [ ] The test environment setup works and the intended behavior is reproducible in the test - [ ] The test environment setup works and the intended behavior is reproducible in the test
environment environment
- [ ] In-code documentation and comments are up-to-date. - [ ] In-code documentation and comments are up-to-date.
......
...@@ -19,4 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -19,4 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
* Fixed failing async test.
### Security ### Security
# #
# This file is a part of the CaosDB Project. # This file is a part of the LinkAhead Project.
# #
# Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> # Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> # Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
...@@ -20,28 +20,31 @@ ...@@ -20,28 +20,31 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(libcaosdb_inttests project(liblinkahead_inttests
DESCRIPTION "Integration tests for the C++ client libraries of the CaosDB project which run against the CaosDB server." DESCRIPTION "Integration tests for the C++ client libraries of the LinkAhead project which run against the LinkAhead server."
LANGUAGES CXX) LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# # fix grpc - remove unsecure (no-op ssl implementations)
# TODO: Find out if this is still necessary
# 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}")
# dependency management with conan
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
# fix grpc - remove unsecure (no-op ssl implementations) find_package(linkahead CONFIG REQUIRED)
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC find_package(GTest CONFIG REQUIRED)
"${CONAN_LIBS_GRPC}") find_package(gRPC CONFIG REQUIRED)
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS_GRPC find_package(protobuf CONFIG REQUIRED)
"${CONAN_PKG_LIBS_GRPC}")
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS
"${CONAN_LIBS}")
string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS
"${CONAN_PKG_LIBS}")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
......
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"build/Release/generators/CMakePresets.json"
]
}
\ No newline at end of file
...@@ -35,14 +35,55 @@ CLANG_TIDY_CMD = $(CLANG_TIDY) \ ...@@ -35,14 +35,55 @@ CLANG_TIDY_CMD = $(CLANG_TIDY) \
.PHONY: help .PHONY: help
help: help:
@echo "Targets:" @echo "Targets:"
@echo " conan-install - Install locally with Conan." @echo " conan-install-debug - Install locally with Conan."
@echo " conan-install-release - Install locally with Conan."
@echo " format - auto-format the source files." @echo " format - auto-format the source files."
@echo " build-debug - Build the project in Debug mode."
@echo " build-release - Build the project in Release mode."
@echo " test-debug - Run the tests in Debug mode."
@echo " test-release - Run the tests in Release mode."
@echo " clean - Remove build directories."
conan-install: conan-install-debug:
conan install . -s "compiler.libcxx=libstdc++11" conan install . -s "compiler.libcxx=libstdc++11" -s build_type=Debug --build=missing
.PHONY: conan-install
conan-install-release:
conan install . -s "compiler.libcxx=libstdc++11" -s build_type=Release --build=missing
format: format:
$(CLANG_FORMAT) -i --verbose \ $(CLANG_FORMAT) -i --verbose \
$$(find test/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in") $$(find test/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in")
.PHONY: format .PHONY: format
build-debug: conan-install-debug
# cmake --preset conan-debug && cmake --build build/Debug # for CMake >= 3.23
@command -v iwyu || command include-what-you-use || \
(echo "Could not find 'iwyu', exiting."; exit 1)
@command -v clang-tidy || command -v clang-tidy-16 || \
(echo "Could not find 'clang-tidy'(-16), exiting."; exit 1)
cd build/Debug &&\
cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug &&\
cmake --build .
build-release: conan-install-release
# cmake --preset conan-release # for CMake >= 3.23
@command -v iwyu || command -v include-what-you-use || \
(echo "Could not find 'iwyu', exiting."; exit 1)
@command -v clang-tidy || command -v clang-tidy-16 || \
(echo "Could not find 'clang-tidy'(-16), exiting."; exit 1)
cd build/Release &&\
cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release &&\
cmake --build .
# cmake --build . --verbose
test-debug: build-debug
cd build/Debug && ctest
test-release: build-release
cd build/Release && ctest
clean:
rm -rf build
.PHONY: conan-install-debug conan-install-release build-debug build-release test-debug test-release
# caosdb-cppinttest # linkahead-cppinttest
Integration tests for caosdb-cpplib and the caosdb-server Integration tests for linkahead-cpplib and the linkahead-server
# Dependencies # Dependencies
* clang-tidy * clang-tidy-16
* clang-format * clang-format
* include-what-you-use * iwyu / include-what-you-use
* cmake * cmake
* conan * conan
# Run tests # Run tests
## Prerequisite ## Prerequisites
Create a local conan package from the caosdb-cpplib repository
Create a local conan package from the linkahead-cpplib repository
## Build & Execution ## Build & Execution
1. `mkdir build && cd build/`
2. `conan install .. -s "compiler.libcxx=libstdc++11"` ```
3. `cmake -B . ..` make test-release
```
or manually via
1. `conan install . -s build_type=<Debug/Release> --build=missing`
2. `cmake --preset conan-<debug/release>`
3. `cd build <Debug/Release>`
4. `cmake --build .` 4. `cmake --build .`
5. Provide client configuration at `~/.caosdb-client.json` or via any other method described in the docs. 5. Provide client configuration at `~/.linkahead-client.json` or via any other method described in the docs.
6. There are tests which need access to the server's certificate file. Define 6. There are tests which need access to the server's certificate file. Define
path to the pem file in the `CAOSDB_SERVER_CERT` environment variable. path to the pem file in the `CAOSDB_SERVER_CERT` environment variable.
7. Run with `ctest` in the build directory. 7. Run with `ctest` in the build directory.
### Windows ###
On windows, you still need to build and create a conan package from
linkahead-cpplib using conan-create or the make.ps1 script in the
cpplib repo.
This repo also provides a make script `make.ps1` to run the
integration tests on Windows. You need to create a python virtual
environment and install the requirements from linkahead cpplib or
recycle the one you used to create the package there:
```sh
python -m venv .venv # Choose any path you like for your venv
.venv/Scripts/Actvate.ps1
pip install ../linkahead-cpplib/requirements.txt # You may need to change the pass to cpplib here
```
Then build and run the tests with
```sh
make.ps1 all
```
### Troubleshooting ###
- If you don't have `clang-tidy` installed, you can run the first `cmake` command with
`LINTING=OFF`: `cmake -D LINTING=OFF -B . ..`
## Formatting, style, linting ## ## Formatting, style, linting ##
`make format` `make format`
[requires] [requires]
caosdb/0.2.2 linkahead/[>=0.3.0, include_prerelease=True]
protobuf/3.21.12
grpc/1.48.4
[build_requires] [test_requires]
gtest/1.11.0 gtest/1.11.0
[generators] [generators]
cmake CMakeDeps
CMakeToolchain
[options] [options]
caosdb:build_acm=True linkahead*:build_acm=True
[layout]
cmake_layout
\ No newline at end of file
make.ps1 0 → 100644
param (
[string]$target
)
$buildType = "Release"
$cppStd=17
function Install-Conan {
Write-Output "Installing Release dependencies with Conan..."
# check if conan is available
if (-not (Get-Command conan -ErrorAction SilentlyContinue)) {
Write-Output "Conan is not available. Please install Conan or activate the Conan environment venv"
exit 1
}
conan install . --build=missing -s build_type=$buildType -s compiler.cppstd=$cppStd
cmake --preset conan-default
}
function Invoke-Build {
Write-Output "Building the project..."
# check if msbuild is available
if (-not (Get-Command msbuild -ErrorAction SilentlyContinue)) {
Write-Output "msbuild is not available. Please install Visual Studio or open the Developer PowerShell."
exit 1
}
# check if conan install was run
if (-not (Test-Path .\build\liblinkahead_inttests.sln)) {
Write-Output "Please run conan-install first."
exit 1
}
msbuild .\build\liblinkahead_inttests.sln /property:Configuration=$buildType
}
function Invoke-Tests {
Write-Output "Running tests..."
Set-Location .\build\
ctest
Set-Location ..\
}
function Invoke-Create {
Write-Output "Creating Conan package..."
conan create .
}
# check if vswhere is available
if (-not (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe")) {
Write-Output "vswhere is not available. Please install Visual Studio"
exit 1
}
# locate the latest Visual Studio installation
$currentPath = Get-Location
$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $installPath
Set-Location $currentPath
# Windows is with Release only for now
switch ($target) {
"build" {
Invoke-Build
}
"test" {
Invoke-Tests
}
"conan-install" {
Install-Conan
}
"conan-create" {
Invoke-Create
}
"clean"{
Write-Output "Cleaning the project..."
Remove-Item -Recurse -Force .\build\*
}
"all" {
Install-Conan
Invoke-Build
Invoke-Tests
Invoke-Create
}
default {
Write-Output "Usage: .\make.ps1 [all|conan-install|build|test|clean]"
}
}
# #
# This file is a part of the CaosDB Project. # This file is a part of the LinkAhead Project.
# #
# Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> # Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> # Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
...@@ -27,7 +27,7 @@ set(test_cases ...@@ -27,7 +27,7 @@ set(test_cases
test_list_properties test_list_properties
test_properties test_properties
test_transaction test_transaction
test_ccaosdb test_clinkahead
test_issues test_issues
test_user test_user
test_select test_select
...@@ -35,6 +35,9 @@ set(test_cases ...@@ -35,6 +35,9 @@ set(test_cases
add_compile_definitions(BUILD_ACM) add_compile_definitions(BUILD_ACM)
# copy DLLs from linkahead_LIB_DIRS_RELEASE to the binary directory
file(COPY ${linkahead_LIB_DIRS_RELEASE}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
...@@ -80,16 +83,15 @@ if(LINTING) ...@@ -80,16 +83,15 @@ if(LINTING)
"-Xiwyu" "--cxx17ns") "-Xiwyu" "--cxx17ns")
endif() endif()
find_program(clang_tidy NAMES clang-tidy clang-tidy-11) find_program(clang_tidy NAMES clang-tidy clang-tidy-16)
if(NOT clang_tidy) if(NOT clang_tidy)
message(WARNING "clang-tidy: Not found") message(WARNING "clang-tidy: Not found")
else() else()
message(STATUS "clang-tidy: ${clang_tidy}") message(STATUS "clang-tidy: ${clang_tidy}")
set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}" set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}"
"--header-filter=caosdb/.*[^\(\.pb\.h\)]$" "--header-filter=caosdb/.*[^\(\.pb\.h\)]$")
"--fix")
set(_CMAKE_CXX_CLANG_TIDY_CHECKS set(_CMAKE_CXX_CLANG_TIDY_CHECKS
"--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-altera-*") "--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-altera-*,-misc-include-cleaner,-readability-identifier-length")
endif() endif()
else() else()
message(STATUS "LINTING is OFF") message(STATUS "LINTING is OFF")
...@@ -100,6 +102,7 @@ endif() ...@@ -100,6 +102,7 @@ endif()
### Set up tests using GoogleTest (GTest) ### Set up tests using GoogleTest (GTest)
################################################### ###################################################
# add special cmake functions for gtest # add special cmake functions for gtest
include(GoogleTest REQUIRED) include(GoogleTest REQUIRED)
...@@ -109,16 +112,14 @@ math(EXPR len_test_cases "${len_test_cases} - 1") ...@@ -109,16 +112,14 @@ math(EXPR len_test_cases "${len_test_cases} - 1")
foreach (i RANGE "${len_test_cases}") foreach (i RANGE "${len_test_cases}")
list(GET test_cases ${i} test_case_name) list(GET test_cases ${i} test_case_name)
add_executable(${test_case_name} ${test_case_name}.cpp) add_executable(${test_case_name} ${test_case_name}.cpp)
target_link_libraries(${test_case_name} PRIVATE ${CONAN_LIBS_CAOSDB} target_link_libraries(${test_case_name} PRIVATE
${CONAN_LIBS_GTEST} ${CONAN_LIBS_GRPC} ${CONAN_LIBS_ABSEIL} linkahead::linkahead linkahead clinkahead caosdb_grpc
${CONAN_LIBS_OPENSSL} ${CONAN_LIBS_C-ARES} ${CONAN_LIBS_BZIP2} gtest::gtest grpc::grpc protobuf::protobuf
${CONAN_LIBS_PROTOBUF} ${CONAN_LIBS_ZLIB} ${CONAN_LIBS_RE2} )
${CONAN_LIBS_BOOST})
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
target_link_libraries(${test_case_name} PRIVATE caosdb_grpc)
endif()
target_include_directories(${test_case_name} target_include_directories(${test_case_name}
PUBLIC ${CONAN_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(${test_case_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
if(LINTING) if(LINTING)
set_target_properties(${test_case_name} set_target_properties(${test_case_name}
PROPERTIES PROPERTIES
...@@ -126,6 +127,6 @@ foreach (i RANGE "${len_test_cases}") ...@@ -126,6 +127,6 @@ foreach (i RANGE "${len_test_cases}")
CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}") CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}")
endif() endif()
gtest_discover_tests(${test_case_name} gtest_discover_tests(${test_case_name}
PROPERTIES PROPERTIES
LABELS "caosdb-cpplib-int-tests") LABELS "linkahead-cpplib-int-tests")
endforeach () endforeach ()
/* /*
* *
* This file is a part of the CaosDB Project. * This file is a part of the LinkAhead Project.
* *
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* WARNING: THIS FILE IS MAINTAINED AS PART OF THE caosdb-cpplib. Please commit * WARNING: THIS FILE IS MAINTAINED AS PART OF THE caosdb-cpplib. Please commit
* changes there and keep these files in sync! * changes there and keep these files in sync!
* *
* @file caosdb_test_utility.h * @file linkahead_test_utility.h
* @brief Utility for the unit tests * @brief Utility for the unit tests
* @author Timm Fitschen * @author Timm Fitschen
* @date 2021-07-07 * @date 2021-07-07
......
/* /*
* This file is a part of the CaosDB Project. * This file is a part of the LinkAhead Project.
* *
* Copyright (C) 2022 IndiScale GmbH <info@indiscale.com> * Copyright (C) 2022 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2022 Timm Fitschen <t.fitschen@indiscale.com> * Copyright (C) 2022 Timm Fitschen <t.fitschen@indiscale.com>
...@@ -18,21 +18,21 @@ ...@@ -18,21 +18,21 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
#include "caosdb/entity.h" // for Entity, Property #include "linkahead/entity.h" // for Entity, Property
#include "caosdb/connection.h" // for Connection, Connec... #include "linkahead/connection.h" // for Connection, Connec...
#include "caosdb/message_code.h" // for ENTITY_DOES_NOT_EXIST, Messag... #include "linkahead/message_code.h" // for ENTITY_DOES_NOT_EXIST, Messag...
#include "caosdb/status_code.h" // for StatusCode, SUCCESS #include "linkahead/status_code.h" // for StatusCode, SUCCESS
#include "caosdb/transaction.h" // for Entity, Transaction #include "linkahead/transaction.h" // for Entity, Transaction
#include "caosdb/transaction_status.h" // for TransactionStatus #include "linkahead/transaction_status.h" // for TransactionStatus
#include <chrono> // for operator""ms, chrono_literals #include <chrono> // for operator""ms, chrono_literals
#include <gtest/gtest-message.h> // for Message #include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for TestPartResult #include <gtest/gtest-test-part.h> // for TestPartResult
#include <gtest/gtest_pred_impl.h> // for AssertionResult #include <gtest/gtest_pred_impl.h> // for AssertionResult
#include <memory> // for allocator, unique_ptr, __shar... #include <memory> // for allocator, unique_ptr, __shar...
#include <thread> #include <thread>
namespace caosdb::transaction { namespace linkahead::transaction {
using caosdb::entity::MessageCode; using linkahead::entity::MessageCode;
/* /*
* Test the retrieval of a non-existing entity * Test the retrieval of a non-existing entity
...@@ -42,7 +42,7 @@ using caosdb::entity::MessageCode; ...@@ -42,7 +42,7 @@ using caosdb::entity::MessageCode;
*/ */
TEST(test_async, retrieve_non_existing) { TEST(test_async, retrieve_non_existing) {
using namespace std::chrono_literals; using namespace std::chrono_literals;
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection(); const auto &connection = linkahead::connection::ConnectionManager::GetDefaultConnection();
auto transaction(connection->CreateTransaction()); auto transaction(connection->CreateTransaction());
...@@ -76,4 +76,4 @@ TEST(test_async, retrieve_non_existing) { ...@@ -76,4 +76,4 @@ TEST(test_async, retrieve_non_existing) {
EXPECT_EQ(entity.GetErrors().at(0).GetCode(), MessageCode::ENTITY_DOES_NOT_EXIST); EXPECT_EQ(entity.GetErrors().at(0).GetCode(), MessageCode::ENTITY_DOES_NOT_EXIST);
} }
} // namespace caosdb::transaction } // namespace linkahead::transaction
This diff is collapsed.
This diff is collapsed.
/* /*
* This file is a part of the CaosDB Project. * This file is a part of the LinkAhead Project.
* *
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
...@@ -18,29 +18,29 @@ ...@@ -18,29 +18,29 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
#include "caosdb/authentication.h" // for PlainPasswordAuthenticator #include "linkahead/authentication.h" // for PlainPasswordAuthenticator
#include "caosdb/certificate_provider.h" // for PemFileCertificateProvider #include "linkahead/certificate_provider.h" // for PemFileCertificateProvider
#include "caosdb/configuration.h" // for InsecureConnectionConfigura... #include "linkahead/configuration.h" // for InsecureConnectionConfigura...
#include "caosdb/connection.h" // for Connection, VersionInfo, path #include "linkahead/connection.h" // for Connection, VersionInfo, path
#include "caosdb/constants.h" // for COMPATIBLE_SERVER_VERSION_M... #include "linkahead/constants.h" // for COMPATIBLE_SERVER_VERSION_M...
#include "caosdb/exceptions.h" // for AuthenticationError, Connec... #include "linkahead/exceptions.h" // for AuthenticationError, Connec...
#include "caosdb/info.h" // for VersionInfo #include "linkahead/info.h" // for VersionInfo
#include "caosdb/utility.h" // for get_env_fallback #include "linkahead/utility.h" // for get_env_fallback
#include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE #include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE
#include <filesystem> // for path #include <filesystem> // for path
#include <gtest/gtest_pred_impl.h> // NOLINT TODO how to fix this? for Test, TestInfo, TEST, EXPEC... #include <gtest/gtest_pred_impl.h> // NOLINT TODO how to fix this? for Test, TestInfo, TEST, EXPEC...
#include <gtest/gtest-message.h> // for Message #include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR... #include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR...
#include <memory> // for allocator, unique_ptr, __sh... #include <memory> // for allocator, unique_ptr, __sh...
#include <string> // for stoi, string #include <string> // for stoi, string
namespace caosdb::connection { namespace linkahead::connection {
using caosdb::authentication::PlainPasswordAuthenticator; using linkahead::authentication::PlainPasswordAuthenticator;
using caosdb::configuration::InsecureConnectionConfiguration; using linkahead::configuration::InsecureConnectionConfiguration;
using caosdb::configuration::PemFileCertificateProvider; using linkahead::configuration::PemFileCertificateProvider;
using caosdb::configuration::TlsConnectionConfiguration; using linkahead::configuration::TlsConnectionConfiguration;
using caosdb::exceptions::AuthenticationError; using linkahead::exceptions::AuthenticationError;
using caosdb::exceptions::ConnectionError; using linkahead::exceptions::ConnectionError;
TEST(test_connection, config_somehost_25323) { TEST(test_connection, config_somehost_25323) {
auto port = 25323; auto port = 25323;
...@@ -61,9 +61,10 @@ TEST(test_connection, connect_somehost_42347_fails) { ...@@ -61,9 +61,10 @@ TEST(test_connection, connect_somehost_42347_fails) {
} }
TEST(test_connection, connection_insecure_authentication_error_anonymous) { TEST(test_connection, connection_insecure_authentication_error_anonymous) {
const auto *port_str = caosdb::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTP", "8080"); const auto *port_str =
linkahead::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTP", "8080");
auto port = std::stoi(port_str); auto port = std::stoi(port_str);
const auto *const host = caosdb::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost"); const auto *const host = linkahead::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
auto config = InsecureConnectionConfiguration(host, port); auto config = InsecureConnectionConfiguration(host, port);
auto connection = Connection(config); auto connection = Connection(config);
...@@ -72,10 +73,12 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) { ...@@ -72,10 +73,12 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
} }
TEST(test_connection, connection_ssl_authentication_error_anonymous) { TEST(test_connection, connection_ssl_authentication_error_anonymous) {
const auto *port_str = caosdb::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443"); const auto *port_str =
linkahead::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str); auto port = std::stoi(port_str);
const auto *const host = caosdb::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost"); const auto *const host = linkahead::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = caosdb::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string()); 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 cert = PemFileCertificateProvider(path);
auto config = TlsConnectionConfiguration(host, port, cert); auto config = TlsConnectionConfiguration(host, port, cert);
...@@ -88,10 +91,13 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) { ...@@ -88,10 +91,13 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
} }
TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) { TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
const auto *port_str = caosdb::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443"); const auto *port_str =
linkahead::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str); auto port = std::stoi(port_str);
const auto *const host = caosdb::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost"); const auto *const host = linkahead::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = caosdb::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string()); 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 user = "not-a-user-23461237";
const auto *const password = "very-c-cred"; const auto *const password = "very-c-cred";
...@@ -106,13 +112,63 @@ TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) { ...@@ -106,13 +112,63 @@ TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
"Authentication failed. Username or password wrong."); "Authentication failed. Username or password wrong.");
} }
TEST(test_connection, connection_ssl_authentication_error_wrong_certificate) {
const auto *port_str =
linkahead::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
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";
const auto *const password = "caosdb";
// first test successful connection
auto auth = PlainPasswordAuthenticator(user, password);
auto good_cert = PemFileCertificateProvider(path);
auto good_config = TlsConnectionConfiguration(host, port, good_cert, auth);
auto good_connection = Connection(good_config);
const auto good_status = good_connection.RetrieveVersionInfoNoExceptions();
EXPECT_EQ(good_status.GetCode(), StatusCode::SUCCESS);
// replace certificate with a wrong one
auto bad_cert = configuration::PemCertificateProvider(R"(-----BEGIN CERTIFICATE-----
FOOOOOOOOOOOOOOIBAgIUZ8JU2geskYAjBMaBTxz6cOAm+P0wDQYJKoZIhvcNAQEL
BQAwODEQMA4GA1UECgwHZXhhbXBsZTEQMA4GA1UECwwHZXhhbXBsZTESMBAGA1UE
AwwJbG9jYWxob3N0MB4XDTI0MTAwODE4Mjc1MloXDTI1MTAwODE4Mjc1MlowODEQ
MA4GA1UECgwHZXhhbXBsZTEQMA4GA1UECwwHZXhhbXBsZTESMBAGA1UEAwwJbG9j
YWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyCLNOAEhsB2k
XZ1KS3Ys81Q3YIeLOhT3Es+qE54lIFrKjRngZ6vTyzkuXhOav3ZaOzWWaCxGhgDI
9O7c4BYtrBHr0CyapqVCeyGoBvNXSWWxYl0sEegkuJ3VW7b80F02oLTzxO8CIQHL
4SSEEVrUPpXJgPHi9fUbKQ9dZ4871yVEUvo1rsUNyyXYoYaK+kcE/7qCY1Q9Scmr
ZbM9DqqSQAqbSxIjlgs34XsOhWhpGFrNvJmE/kjtvp9tXzS8y++QgfmMuPU6mfSv
NONSENSE3xxBaO6EgTbMgTeVmR0ygXIer9y3hBDdYwB6LgjZIDin1fZR+8LmewN+
fjaCQjJggwIDAQABo3sweTAdBgNVHQ4EFgQUlBvcjWiNs6MWGkhC46q4Dbg3TPQw
HwYDVR0jBBgwFoAUlBvcjWiNs6MWGkhC46q4Dbg3TPQwDwYDVR0TAQH/BAUwAwEB
/zAUBgNVHREEDTALgglsb2NhbGhvc3QwEAYDVR0gBAkwBzAFBgMqAwQwDQYJKoZI
hvcNAQELBQADggEBALnH5F58Om+AWQ+kkAmsZnc33i+56VfZlRYFr+sEFN8ULDtZ
l6D1+ILqUXGT/GG1cyQhrxn4VA0Ksz6e/7jJySjZ0Ltezs6gnkcV9ksZOOEH4nuA
8r1VA7xQ9iN3gGQduk/gbDKa8r6Ucodz7+tZ+DGY1unJLoUrOLBt0rP9UpdIxk8X
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) { TEST(test_connection, connection_ssl_authentication_success) {
const auto &connection = ConnectionManager::GetDefaultConnection(); const auto &connection = ConnectionManager::GetDefaultConnection();
auto major = caosdb::COMPATIBLE_SERVER_VERSION_MAJOR; auto major = linkahead::COMPATIBLE_SERVER_VERSION_MAJOR;
auto minor = caosdb::COMPATIBLE_SERVER_VERSION_MINOR; auto minor = linkahead::COMPATIBLE_SERVER_VERSION_MINOR;
auto patch = caosdb::COMPATIBLE_SERVER_VERSION_PATCH; auto patch = linkahead::COMPATIBLE_SERVER_VERSION_PATCH;
const auto pre_release = std::string(caosdb::COMPATIBLE_SERVER_VERSION_PRE_RELEASE); const auto pre_release = std::string(linkahead::COMPATIBLE_SERVER_VERSION_PRE_RELEASE);
const auto &v_info = connection->RetrieveVersionInfo(); const auto &v_info = connection->RetrieveVersionInfo();
...@@ -126,4 +182,4 @@ TEST(test_connection, connection_ssl_authentication_success) { ...@@ -126,4 +182,4 @@ TEST(test_connection, connection_ssl_authentication_success) {
} }
} }
} // namespace caosdb::connection } // namespace linkahead::connection
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment