mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch '177_backend_coverage' into login_coverage
This commit is contained in:
commit
5f6070e7bd
31
.github/workflows/test.yml
vendored
31
.github/workflows/test.yml
vendored
@ -215,6 +215,37 @@ jobs:
|
|||||||
min_coverage: 19
|
min_coverage: 19
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# JOB: UNIT TEST LOGIN-SERVER ###############################################
|
||||||
|
##############################################################################
|
||||||
|
unit_test_login_server:
|
||||||
|
name: Unit tests - Login-Server
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build_test_login_server]
|
||||||
|
steps:
|
||||||
|
##########################################################################
|
||||||
|
# CHECKOUT CODE ##########################################################
|
||||||
|
##########################################################################
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
##########################################################################
|
||||||
|
# DOWNLOAD DOCKER IMAGE ##################################################
|
||||||
|
##########################################################################
|
||||||
|
- name: Download Docker Image (Login-Server)
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: docker-loginserver-test
|
||||||
|
path: /tmp
|
||||||
|
- name: Load Docker Image
|
||||||
|
run: docker load < /tmp/loginserver.tar
|
||||||
|
##########################################################################
|
||||||
|
# UNIT TESTS FRONTEND ####################################################
|
||||||
|
##########################################################################
|
||||||
|
- name: Login-Server | Unit tests
|
||||||
|
run: |
|
||||||
|
docker run -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test
|
||||||
|
cp -r ~/coverage ./coverage
|
||||||
|
|
||||||
#test:
|
#test:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# steps:
|
# steps:
|
||||||
|
|||||||
@ -318,6 +318,15 @@ endif(UNIX)
|
|||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
include(cmake/CodeCoverage.cmake)
|
||||||
|
append_coverage_compiler_flags()
|
||||||
|
setup_target_for_coverage_gcovr_html(
|
||||||
|
NAME coverage
|
||||||
|
EXECUTABLE Gradido_LoginServer_Test
|
||||||
|
DEPENDENCIES lib/libmariadb.so.3
|
||||||
|
)
|
||||||
|
endif()
|
||||||
# ---------------------- Test -----------------------------------------
|
# ---------------------- Test -----------------------------------------
|
||||||
#project(Gradido_LoginServer_Test C CXX)
|
#project(Gradido_LoginServer_Test C CXX)
|
||||||
#_TEST_BUILD
|
#_TEST_BUILD
|
||||||
|
|||||||
@ -41,12 +41,6 @@ RUN ./unix_parse_proto.sh
|
|||||||
FROM debug as login_server_debug
|
FROM debug as login_server_debug
|
||||||
|
|
||||||
ENV DOCKER_WORKDIR="/code"
|
ENV DOCKER_WORKDIR="/code"
|
||||||
#RUN apt-get update && \
|
|
||||||
# apt-get install -y --no-install-recommends gdb && \
|
|
||||||
# apt-get autoclean && \
|
|
||||||
# apt-get autoremove && \
|
|
||||||
# apt-get clean && \
|
|
||||||
# rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
VOLUME /var/log/grd_login
|
VOLUME /var/log/grd_login
|
||||||
VOLUME /code/src
|
VOLUME /code/src
|
||||||
|
|||||||
@ -23,6 +23,7 @@ ENV DOCKER_WORKDIR="/code"
|
|||||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||||
WORKDIR ${DOCKER_WORKDIR}
|
WORKDIR ${DOCKER_WORKDIR}
|
||||||
|
|
||||||
|
COPY ./cmake ./cmake
|
||||||
|
|
||||||
RUN git clone https://github.com/Kitware/CMake.git --branch=v3.19.8 && \
|
RUN git clone https://github.com/Kitware/CMake.git --branch=v3.19.8 && \
|
||||||
cd CMake && \
|
cd CMake && \
|
||||||
|
|||||||
682
login_server/cmake/CodeCoverage.cmake
Normal file
682
login_server/cmake/CodeCoverage.cmake
Normal file
@ -0,0 +1,682 @@
|
|||||||
|
# Copyright (c) 2012 - 2017, Lars Bilke
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without
|
||||||
|
# specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# CHANGES:
|
||||||
|
#
|
||||||
|
# 2012-01-31, Lars Bilke
|
||||||
|
# - Enable Code Coverage
|
||||||
|
#
|
||||||
|
# 2013-09-17, Joakim Söderberg
|
||||||
|
# - Added support for Clang.
|
||||||
|
# - Some additional usage instructions.
|
||||||
|
#
|
||||||
|
# 2016-02-03, Lars Bilke
|
||||||
|
# - Refactored functions to use named parameters
|
||||||
|
#
|
||||||
|
# 2017-06-02, Lars Bilke
|
||||||
|
# - Merged with modified version from github.com/ufz/ogs
|
||||||
|
#
|
||||||
|
# 2019-05-06, Anatolii Kurotych
|
||||||
|
# - Remove unnecessary --coverage flag
|
||||||
|
#
|
||||||
|
# 2019-12-13, FeRD (Frank Dana)
|
||||||
|
# - Deprecate COVERAGE_LCOVR_EXCLUDES and COVERAGE_GCOVR_EXCLUDES lists in favor
|
||||||
|
# of tool-agnostic COVERAGE_EXCLUDES variable, or EXCLUDE setup arguments.
|
||||||
|
# - CMake 3.4+: All excludes can be specified relative to BASE_DIRECTORY
|
||||||
|
# - All setup functions: accept BASE_DIRECTORY, EXCLUDE list
|
||||||
|
# - Set lcov basedir with -b argument
|
||||||
|
# - Add automatic --demangle-cpp in lcovr, if 'c++filt' is available (can be
|
||||||
|
# overridden with NO_DEMANGLE option in setup_target_for_coverage_lcovr().)
|
||||||
|
# - Delete output dir, .info file on 'make clean'
|
||||||
|
# - Remove Python detection, since version mismatches will break gcovr
|
||||||
|
# - Minor cleanup (lowercase function names, update examples...)
|
||||||
|
#
|
||||||
|
# 2019-12-19, FeRD (Frank Dana)
|
||||||
|
# - Rename Lcov outputs, make filtered file canonical, fix cleanup for targets
|
||||||
|
#
|
||||||
|
# 2020-01-19, Bob Apthorpe
|
||||||
|
# - Added gfortran support
|
||||||
|
#
|
||||||
|
# 2020-02-17, FeRD (Frank Dana)
|
||||||
|
# - Make all add_custom_target()s VERBATIM to auto-escape wildcard characters
|
||||||
|
# in EXCLUDEs, and remove manual escaping from gcovr targets
|
||||||
|
#
|
||||||
|
# 2021-01-19, Robin Mueller
|
||||||
|
# - Add CODE_COVERAGE_VERBOSE option which will allow to print out commands which are run
|
||||||
|
# - Added the option for users to set the GCOVR_ADDITIONAL_ARGS variable to supply additional
|
||||||
|
# flags to the gcovr command
|
||||||
|
#
|
||||||
|
# 2020-05-04, Mihchael Davis
|
||||||
|
# - Add -fprofile-abs-path to make gcno files contain absolute paths
|
||||||
|
# - Fix BASE_DIRECTORY not working when defined
|
||||||
|
# - Change BYPRODUCT from folder to index.html to stop ninja from complaining about double defines
|
||||||
|
# USAGE:
|
||||||
|
#
|
||||||
|
# 1. Copy this file into your cmake modules path.
|
||||||
|
#
|
||||||
|
# 2. Add the following line to your CMakeLists.txt (best inside an if-condition
|
||||||
|
# using a CMake option() to enable it just optionally):
|
||||||
|
# include(CodeCoverage)
|
||||||
|
#
|
||||||
|
# 3. Append necessary compiler flags:
|
||||||
|
# append_coverage_compiler_flags()
|
||||||
|
#
|
||||||
|
# 3.a (OPTIONAL) Set appropriate optimization flags, e.g. -O0, -O1 or -Og
|
||||||
|
#
|
||||||
|
# 4. If you need to exclude additional directories from the report, specify them
|
||||||
|
# using full paths in the COVERAGE_EXCLUDES variable before calling
|
||||||
|
# setup_target_for_coverage_*().
|
||||||
|
# Example:
|
||||||
|
# set(COVERAGE_EXCLUDES
|
||||||
|
# '${PROJECT_SOURCE_DIR}/src/dir1/*'
|
||||||
|
# '/path/to/my/src/dir2/*')
|
||||||
|
# Or, use the EXCLUDE argument to setup_target_for_coverage_*().
|
||||||
|
# Example:
|
||||||
|
# setup_target_for_coverage_lcov(
|
||||||
|
# NAME coverage
|
||||||
|
# EXECUTABLE testrunner
|
||||||
|
# EXCLUDE "${PROJECT_SOURCE_DIR}/src/dir1/*" "/path/to/my/src/dir2/*")
|
||||||
|
#
|
||||||
|
# 4.a NOTE: With CMake 3.4+, COVERAGE_EXCLUDES or EXCLUDE can also be set
|
||||||
|
# relative to the BASE_DIRECTORY (default: PROJECT_SOURCE_DIR)
|
||||||
|
# Example:
|
||||||
|
# set(COVERAGE_EXCLUDES "dir1/*")
|
||||||
|
# setup_target_for_coverage_gcovr_html(
|
||||||
|
# NAME coverage
|
||||||
|
# EXECUTABLE testrunner
|
||||||
|
# BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/src"
|
||||||
|
# EXCLUDE "dir2/*")
|
||||||
|
#
|
||||||
|
# 5. Use the functions described below to create a custom make target which
|
||||||
|
# runs your test executable and produces a code coverage report.
|
||||||
|
#
|
||||||
|
# 6. Build a Debug build:
|
||||||
|
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
|
# make
|
||||||
|
# make my_coverage_target
|
||||||
|
#
|
||||||
|
|
||||||
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
|
option(CODE_COVERAGE_VERBOSE "Verbose information" FALSE)
|
||||||
|
|
||||||
|
# Check prereqs
|
||||||
|
find_program( GCOV_PATH gcov )
|
||||||
|
find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl)
|
||||||
|
find_program( FASTCOV_PATH NAMES fastcov fastcov.py )
|
||||||
|
find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat )
|
||||||
|
find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
|
||||||
|
find_program( CPPFILT_PATH NAMES c++filt )
|
||||||
|
|
||||||
|
if(NOT GCOV_PATH)
|
||||||
|
message(FATAL_ERROR "gcov not found! Aborting...")
|
||||||
|
endif() # NOT GCOV_PATH
|
||||||
|
|
||||||
|
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||||
|
list(GET LANGUAGES 0 LANG)
|
||||||
|
|
||||||
|
if("${CMAKE_${LANG}_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
|
||||||
|
if("${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS 3)
|
||||||
|
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
|
||||||
|
endif()
|
||||||
|
elseif(NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "[Ff]lang")
|
||||||
|
# Do nothing; exit conditional without error if true
|
||||||
|
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
# Do nothing; exit conditional without error if true
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(COVERAGE_COMPILER_FLAGS "-g -fprofile-arcs -ftest-coverage"
|
||||||
|
CACHE INTERNAL "")
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag(-fprofile-abs-path HAVE_fprofile_abs_path)
|
||||||
|
if(HAVE_fprofile_abs_path)
|
||||||
|
set(COVERAGE_COMPILER_FLAGS "${COVERAGE_COMPILER_FLAGS} -fprofile-abs-path")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_Fortran_FLAGS_COVERAGE
|
||||||
|
${COVERAGE_COMPILER_FLAGS}
|
||||||
|
CACHE STRING "Flags used by the Fortran compiler during coverage builds."
|
||||||
|
FORCE )
|
||||||
|
set(CMAKE_CXX_FLAGS_COVERAGE
|
||||||
|
${COVERAGE_COMPILER_FLAGS}
|
||||||
|
CACHE STRING "Flags used by the C++ compiler during coverage builds."
|
||||||
|
FORCE )
|
||||||
|
set(CMAKE_C_FLAGS_COVERAGE
|
||||||
|
${COVERAGE_COMPILER_FLAGS}
|
||||||
|
CACHE STRING "Flags used by the C compiler during coverage builds."
|
||||||
|
FORCE )
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||||
|
""
|
||||||
|
CACHE STRING "Flags used for linking binaries during coverage builds."
|
||||||
|
FORCE )
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
|
||||||
|
""
|
||||||
|
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
|
||||||
|
FORCE )
|
||||||
|
mark_as_advanced(
|
||||||
|
CMAKE_Fortran_FLAGS_COVERAGE
|
||||||
|
CMAKE_CXX_FLAGS_COVERAGE
|
||||||
|
CMAKE_C_FLAGS_COVERAGE
|
||||||
|
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||||
|
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
|
||||||
|
endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||||
|
link_libraries(gcov)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Defines a target for running and collection code coverage information
|
||||||
|
# Builds dependencies, runs the given executable and outputs reports.
|
||||||
|
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||||
|
# the coverage generation will not complete.
|
||||||
|
#
|
||||||
|
# setup_target_for_coverage_lcov(
|
||||||
|
# NAME testrunner_coverage # New target name
|
||||||
|
# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||||
|
# DEPENDENCIES testrunner # Dependencies to build first
|
||||||
|
# BASE_DIRECTORY "../" # Base directory for report
|
||||||
|
# # (defaults to PROJECT_SOURCE_DIR)
|
||||||
|
# EXCLUDE "src/dir1/*" "src/dir2/*" # Patterns to exclude (can be relative
|
||||||
|
# # to BASE_DIRECTORY, with CMake 3.4+)
|
||||||
|
# NO_DEMANGLE # Don't demangle C++ symbols
|
||||||
|
# # even if c++filt is found
|
||||||
|
# )
|
||||||
|
function(setup_target_for_coverage_lcov)
|
||||||
|
|
||||||
|
set(options NO_DEMANGLE)
|
||||||
|
set(oneValueArgs BASE_DIRECTORY NAME)
|
||||||
|
set(multiValueArgs EXCLUDE EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES LCOV_ARGS GENHTML_ARGS)
|
||||||
|
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT LCOV_PATH)
|
||||||
|
message(FATAL_ERROR "lcov not found! Aborting...")
|
||||||
|
endif() # NOT LCOV_PATH
|
||||||
|
|
||||||
|
if(NOT GENHTML_PATH)
|
||||||
|
message(FATAL_ERROR "genhtml not found! Aborting...")
|
||||||
|
endif() # NOT GENHTML_PATH
|
||||||
|
|
||||||
|
# Set base directory (as absolute path), or default to PROJECT_SOURCE_DIR
|
||||||
|
if(DEFINED Coverage_BASE_DIRECTORY)
|
||||||
|
get_filename_component(BASEDIR ${Coverage_BASE_DIRECTORY} ABSOLUTE)
|
||||||
|
else()
|
||||||
|
set(BASEDIR ${PROJECT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Collect excludes (CMake 3.4+: Also compute absolute paths)
|
||||||
|
set(LCOV_EXCLUDES "")
|
||||||
|
foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_LCOV_EXCLUDES})
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.4)
|
||||||
|
get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR})
|
||||||
|
endif()
|
||||||
|
list(APPEND LCOV_EXCLUDES "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES LCOV_EXCLUDES)
|
||||||
|
|
||||||
|
# Conditional arguments
|
||||||
|
if(CPPFILT_PATH AND NOT ${Coverage_NO_DEMANGLE})
|
||||||
|
set(GENHTML_EXTRA_ARGS "--demangle-cpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Setting up commands which will be run to generate coverage data.
|
||||||
|
# Cleanup lcov
|
||||||
|
set(LCOV_CLEAN_CMD
|
||||||
|
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -directory .
|
||||||
|
-b ${BASEDIR} --zerocounters
|
||||||
|
)
|
||||||
|
# Create baseline to make sure untouched files show up in the report
|
||||||
|
set(LCOV_BASELINE_CMD
|
||||||
|
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -c -i -d . -b
|
||||||
|
${BASEDIR} -o ${Coverage_NAME}.base
|
||||||
|
)
|
||||||
|
# Run tests
|
||||||
|
set(LCOV_EXEC_TESTS_CMD
|
||||||
|
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||||
|
)
|
||||||
|
# Capturing lcov counters and generating report
|
||||||
|
set(LCOV_CAPTURE_CMD
|
||||||
|
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --directory . -b
|
||||||
|
${BASEDIR} --capture --output-file ${Coverage_NAME}.capture
|
||||||
|
)
|
||||||
|
# add baseline counters
|
||||||
|
set(LCOV_BASELINE_COUNT_CMD
|
||||||
|
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -a ${Coverage_NAME}.base
|
||||||
|
-a ${Coverage_NAME}.capture --output-file ${Coverage_NAME}.total
|
||||||
|
)
|
||||||
|
# filter collected data to final coverage report
|
||||||
|
set(LCOV_FILTER_CMD
|
||||||
|
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --remove
|
||||||
|
${Coverage_NAME}.total ${LCOV_EXCLUDES} --output-file ${Coverage_NAME}.info
|
||||||
|
)
|
||||||
|
# Generate HTML output
|
||||||
|
set(LCOV_GEN_HTML_CMD
|
||||||
|
${GENHTML_PATH} ${GENHTML_EXTRA_ARGS} ${Coverage_GENHTML_ARGS} -o
|
||||||
|
${Coverage_NAME} ${Coverage_NAME}.info
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(CODE_COVERAGE_VERBOSE)
|
||||||
|
message(STATUS "Executed command report")
|
||||||
|
message(STATUS "Command to clean up lcov: ")
|
||||||
|
string(REPLACE ";" " " LCOV_CLEAN_CMD_SPACED "${LCOV_CLEAN_CMD}")
|
||||||
|
message(STATUS "${LCOV_CLEAN_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to create baseline: ")
|
||||||
|
string(REPLACE ";" " " LCOV_BASELINE_CMD_SPACED "${LCOV_BASELINE_CMD}")
|
||||||
|
message(STATUS "${LCOV_BASELINE_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to run the tests: ")
|
||||||
|
string(REPLACE ";" " " LCOV_EXEC_TESTS_CMD_SPACED "${LCOV_EXEC_TESTS_CMD}")
|
||||||
|
message(STATUS "${LCOV_EXEC_TESTS_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to capture counters and generate report: ")
|
||||||
|
string(REPLACE ";" " " LCOV_CAPTURE_CMD_SPACED "${LCOV_CAPTURE_CMD}")
|
||||||
|
message(STATUS "${LCOV_CAPTURE_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to add baseline counters: ")
|
||||||
|
string(REPLACE ";" " " LCOV_BASELINE_COUNT_CMD_SPACED "${LCOV_BASELINE_COUNT_CMD}")
|
||||||
|
message(STATUS "${LCOV_BASELINE_COUNT_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to filter collected data: ")
|
||||||
|
string(REPLACE ";" " " LCOV_FILTER_CMD_SPACED "${LCOV_FILTER_CMD}")
|
||||||
|
message(STATUS "${LCOV_FILTER_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to generate lcov HTML output: ")
|
||||||
|
string(REPLACE ";" " " LCOV_GEN_HTML_CMD_SPACED "${LCOV_GEN_HTML_CMD}")
|
||||||
|
message(STATUS "${LCOV_GEN_HTML_CMD_SPACED}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Setup target
|
||||||
|
add_custom_target(${Coverage_NAME}
|
||||||
|
COMMAND ${LCOV_CLEAN_CMD}
|
||||||
|
COMMAND ${LCOV_BASELINE_CMD}
|
||||||
|
COMMAND ${LCOV_EXEC_TESTS_CMD}
|
||||||
|
COMMAND ${LCOV_CAPTURE_CMD}
|
||||||
|
COMMAND ${LCOV_BASELINE_COUNT_CMD}
|
||||||
|
COMMAND ${LCOV_FILTER_CMD}
|
||||||
|
COMMAND ${LCOV_GEN_HTML_CMD}
|
||||||
|
|
||||||
|
# Set output files as GENERATED (will be removed on 'make clean')
|
||||||
|
BYPRODUCTS
|
||||||
|
${Coverage_NAME}.base
|
||||||
|
${Coverage_NAME}.capture
|
||||||
|
${Coverage_NAME}.total
|
||||||
|
${Coverage_NAME}.info
|
||||||
|
${Coverage_NAME}/index.html
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
DEPENDS ${Coverage_DEPENDENCIES}
|
||||||
|
VERBATIM # Protect arguments to commands
|
||||||
|
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Show where to find the lcov info report
|
||||||
|
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||||
|
COMMAND ;
|
||||||
|
COMMENT "Lcov code coverage info report saved in ${Coverage_NAME}.info."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Show info where to find the report
|
||||||
|
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||||
|
COMMAND ;
|
||||||
|
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
|
||||||
|
)
|
||||||
|
|
||||||
|
endfunction() # setup_target_for_coverage_lcov
|
||||||
|
|
||||||
|
# Defines a target for running and collection code coverage information
|
||||||
|
# Builds dependencies, runs the given executable and outputs reports.
|
||||||
|
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||||
|
# the coverage generation will not complete.
|
||||||
|
#
|
||||||
|
# setup_target_for_coverage_gcovr_xml(
|
||||||
|
# NAME ctest_coverage # New target name
|
||||||
|
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||||
|
# DEPENDENCIES executable_target # Dependencies to build first
|
||||||
|
# BASE_DIRECTORY "../" # Base directory for report
|
||||||
|
# # (defaults to PROJECT_SOURCE_DIR)
|
||||||
|
# EXCLUDE "src/dir1/*" "src/dir2/*" # Patterns to exclude (can be relative
|
||||||
|
# # to BASE_DIRECTORY, with CMake 3.4+)
|
||||||
|
# )
|
||||||
|
# The user can set the variable GCOVR_ADDITIONAL_ARGS to supply additional flags to the
|
||||||
|
# GCVOR command.
|
||||||
|
function(setup_target_for_coverage_gcovr_xml)
|
||||||
|
|
||||||
|
set(options NONE)
|
||||||
|
set(oneValueArgs BASE_DIRECTORY NAME)
|
||||||
|
set(multiValueArgs EXCLUDE EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
|
||||||
|
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT GCOVR_PATH)
|
||||||
|
message(FATAL_ERROR "gcovr not found! Aborting...")
|
||||||
|
endif() # NOT GCOVR_PATH
|
||||||
|
|
||||||
|
# Set base directory (as absolute path), or default to PROJECT_SOURCE_DIR
|
||||||
|
if(DEFINED Coverage_BASE_DIRECTORY)
|
||||||
|
get_filename_component(BASEDIR ${Coverage_BASE_DIRECTORY} ABSOLUTE)
|
||||||
|
else()
|
||||||
|
set(BASEDIR ${PROJECT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Collect excludes (CMake 3.4+: Also compute absolute paths)
|
||||||
|
set(GCOVR_EXCLUDES "")
|
||||||
|
foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_GCOVR_EXCLUDES})
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.4)
|
||||||
|
get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR})
|
||||||
|
endif()
|
||||||
|
list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES GCOVR_EXCLUDES)
|
||||||
|
|
||||||
|
# Combine excludes to several -e arguments
|
||||||
|
set(GCOVR_EXCLUDE_ARGS "")
|
||||||
|
foreach(EXCLUDE ${GCOVR_EXCLUDES})
|
||||||
|
list(APPEND GCOVR_EXCLUDE_ARGS "-e")
|
||||||
|
list(APPEND GCOVR_EXCLUDE_ARGS "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Set up commands which will be run to generate coverage data
|
||||||
|
# Run tests
|
||||||
|
set(GCOVR_XML_EXEC_TESTS_CMD
|
||||||
|
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||||
|
)
|
||||||
|
# Running gcovr
|
||||||
|
set(GCOVR_XML_CMD
|
||||||
|
${GCOVR_PATH} --xml -r ${BASEDIR} ${GCOVR_ADDITIONAL_ARGS} ${GCOVR_EXCLUDE_ARGS}
|
||||||
|
--object-directory=${PROJECT_BINARY_DIR} -o ${Coverage_NAME}.xml
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CODE_COVERAGE_VERBOSE)
|
||||||
|
message(STATUS "Executed command report")
|
||||||
|
|
||||||
|
message(STATUS "Command to run tests: ")
|
||||||
|
string(REPLACE ";" " " GCOVR_XML_EXEC_TESTS_CMD_SPACED "${GCOVR_XML_EXEC_TESTS_CMD}")
|
||||||
|
message(STATUS "${GCOVR_XML_EXEC_TESTS_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to generate gcovr XML coverage data: ")
|
||||||
|
string(REPLACE ";" " " GCOVR_XML_CMD_SPACED "${GCOVR_XML_CMD}")
|
||||||
|
message(STATUS "${GCOVR_XML_CMD_SPACED}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(${Coverage_NAME}
|
||||||
|
COMMAND ${GCOVR_XML_EXEC_TESTS_CMD}
|
||||||
|
COMMAND ${GCOVR_XML_CMD}
|
||||||
|
|
||||||
|
BYPRODUCTS ${Coverage_NAME}.xml
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
DEPENDS ${Coverage_DEPENDENCIES}
|
||||||
|
VERBATIM # Protect arguments to commands
|
||||||
|
COMMENT "Running gcovr to produce Cobertura code coverage report."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Show info where to find the report
|
||||||
|
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||||
|
COMMAND ;
|
||||||
|
COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml."
|
||||||
|
)
|
||||||
|
endfunction() # setup_target_for_coverage_gcovr_xml
|
||||||
|
|
||||||
|
# Defines a target for running and collection code coverage information
|
||||||
|
# Builds dependencies, runs the given executable and outputs reports.
|
||||||
|
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||||
|
# the coverage generation will not complete.
|
||||||
|
#
|
||||||
|
# setup_target_for_coverage_gcovr_html(
|
||||||
|
# NAME ctest_coverage # New target name
|
||||||
|
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||||
|
# DEPENDENCIES executable_target # Dependencies to build first
|
||||||
|
# BASE_DIRECTORY "../" # Base directory for report
|
||||||
|
# # (defaults to PROJECT_SOURCE_DIR)
|
||||||
|
# EXCLUDE "src/dir1/*" "src/dir2/*" # Patterns to exclude (can be relative
|
||||||
|
# # to BASE_DIRECTORY, with CMake 3.4+)
|
||||||
|
# )
|
||||||
|
# The user can set the variable GCOVR_ADDITIONAL_ARGS to supply additional flags to the
|
||||||
|
# GCVOR command.
|
||||||
|
function(setup_target_for_coverage_gcovr_html)
|
||||||
|
|
||||||
|
set(options NONE)
|
||||||
|
set(oneValueArgs BASE_DIRECTORY NAME)
|
||||||
|
set(multiValueArgs EXCLUDE EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
|
||||||
|
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT GCOVR_PATH)
|
||||||
|
message(FATAL_ERROR "gcovr not found! Aborting...")
|
||||||
|
endif() # NOT GCOVR_PATH
|
||||||
|
|
||||||
|
# Set base directory (as absolute path), or default to PROJECT_SOURCE_DIR
|
||||||
|
if(DEFINED Coverage_BASE_DIRECTORY)
|
||||||
|
get_filename_component(BASEDIR ${Coverage_BASE_DIRECTORY} ABSOLUTE)
|
||||||
|
else()
|
||||||
|
set(BASEDIR ${PROJECT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Collect excludes (CMake 3.4+: Also compute absolute paths)
|
||||||
|
set(GCOVR_EXCLUDES "")
|
||||||
|
foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_GCOVR_EXCLUDES})
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.4)
|
||||||
|
get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR})
|
||||||
|
endif()
|
||||||
|
list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES GCOVR_EXCLUDES)
|
||||||
|
|
||||||
|
# Combine excludes to several -e arguments
|
||||||
|
set(GCOVR_EXCLUDE_ARGS "")
|
||||||
|
foreach(EXCLUDE ${GCOVR_EXCLUDES})
|
||||||
|
list(APPEND GCOVR_EXCLUDE_ARGS "-e")
|
||||||
|
list(APPEND GCOVR_EXCLUDE_ARGS "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Set up commands which will be run to generate coverage data
|
||||||
|
# Run tests
|
||||||
|
set(GCOVR_HTML_EXEC_TESTS_CMD
|
||||||
|
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||||
|
)
|
||||||
|
# Create folder
|
||||||
|
set(GCOVR_HTML_FOLDER_CMD
|
||||||
|
${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/${Coverage_NAME}
|
||||||
|
)
|
||||||
|
# Running gcovr
|
||||||
|
set(GCOVR_HTML_CMD
|
||||||
|
${GCOVR_PATH} --html --html-details -r ${BASEDIR} ${GCOVR_ADDITIONAL_ARGS}
|
||||||
|
${GCOVR_EXCLUDE_ARGS} --object-directory=${PROJECT_BINARY_DIR}
|
||||||
|
-o ${Coverage_NAME}/index.html
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CODE_COVERAGE_VERBOSE)
|
||||||
|
message(STATUS "Executed command report")
|
||||||
|
|
||||||
|
message(STATUS "Command to run tests: ")
|
||||||
|
string(REPLACE ";" " " GCOVR_HTML_EXEC_TESTS_CMD_SPACED "${GCOVR_HTML_EXEC_TESTS_CMD}")
|
||||||
|
message(STATUS "${GCOVR_HTML_EXEC_TESTS_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to create a folder: ")
|
||||||
|
string(REPLACE ";" " " GCOVR_HTML_FOLDER_CMD_SPACED "${GCOVR_HTML_FOLDER_CMD}")
|
||||||
|
message(STATUS "${GCOVR_HTML_FOLDER_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(STATUS "Command to generate gcovr HTML coverage data: ")
|
||||||
|
string(REPLACE ";" " " GCOVR_HTML_CMD_SPACED "${GCOVR_HTML_CMD}")
|
||||||
|
message(STATUS "${GCOVR_HTML_CMD_SPACED}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(${Coverage_NAME}
|
||||||
|
COMMAND ${GCOVR_HTML_EXEC_TESTS_CMD}
|
||||||
|
COMMAND ${GCOVR_HTML_FOLDER_CMD}
|
||||||
|
COMMAND ${GCOVR_HTML_CMD}
|
||||||
|
|
||||||
|
BYPRODUCTS ${PROJECT_BINARY_DIR}/${Coverage_NAME}/index.html # report directory
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
DEPENDS ${Coverage_DEPENDENCIES}
|
||||||
|
VERBATIM # Protect arguments to commands
|
||||||
|
COMMENT "Running gcovr to produce HTML code coverage report."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Show info where to find the report
|
||||||
|
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||||
|
COMMAND ;
|
||||||
|
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
|
||||||
|
)
|
||||||
|
|
||||||
|
endfunction() # setup_target_for_coverage_gcovr_html
|
||||||
|
|
||||||
|
# Defines a target for running and collection code coverage information
|
||||||
|
# Builds dependencies, runs the given executable and outputs reports.
|
||||||
|
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||||
|
# the coverage generation will not complete.
|
||||||
|
#
|
||||||
|
# setup_target_for_coverage_fastcov(
|
||||||
|
# NAME testrunner_coverage # New target name
|
||||||
|
# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||||
|
# DEPENDENCIES testrunner # Dependencies to build first
|
||||||
|
# BASE_DIRECTORY "../" # Base directory for report
|
||||||
|
# # (defaults to PROJECT_SOURCE_DIR)
|
||||||
|
# EXCLUDE "src/dir1/" "src/dir2/" # Patterns to exclude.
|
||||||
|
# NO_DEMANGLE # Don't demangle C++ symbols
|
||||||
|
# # even if c++filt is found
|
||||||
|
# SKIP_HTML # Don't create html report
|
||||||
|
# )
|
||||||
|
function(setup_target_for_coverage_fastcov)
|
||||||
|
|
||||||
|
set(options NO_DEMANGLE SKIP_HTML)
|
||||||
|
set(oneValueArgs BASE_DIRECTORY NAME)
|
||||||
|
set(multiValueArgs EXCLUDE EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES FASTCOV_ARGS GENHTML_ARGS)
|
||||||
|
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT FASTCOV_PATH)
|
||||||
|
message(FATAL_ERROR "fastcov not found! Aborting...")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT GENHTML_PATH)
|
||||||
|
message(FATAL_ERROR "genhtml not found! Aborting...")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set base directory (as absolute path), or default to PROJECT_SOURCE_DIR
|
||||||
|
if(Coverage_BASE_DIRECTORY)
|
||||||
|
get_filename_component(BASEDIR ${Coverage_BASE_DIRECTORY} ABSOLUTE)
|
||||||
|
else()
|
||||||
|
set(BASEDIR ${PROJECT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Collect excludes (Patterns, not paths, for fastcov)
|
||||||
|
set(FASTCOV_EXCLUDES "")
|
||||||
|
foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_FASTCOV_EXCLUDES})
|
||||||
|
list(APPEND FASTCOV_EXCLUDES "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES FASTCOV_EXCLUDES)
|
||||||
|
|
||||||
|
# Conditional arguments
|
||||||
|
if(CPPFILT_PATH AND NOT ${Coverage_NO_DEMANGLE})
|
||||||
|
set(GENHTML_EXTRA_ARGS "--demangle-cpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set up commands which will be run to generate coverage data
|
||||||
|
set(FASTCOV_EXEC_TESTS_CMD ${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS})
|
||||||
|
|
||||||
|
set(FASTCOV_CAPTURE_CMD ${FASTCOV_PATH} ${Coverage_FASTCOV_ARGS} --gcov ${GCOV_PATH}
|
||||||
|
--search-directory ${BASEDIR}
|
||||||
|
--process-gcno
|
||||||
|
--lcov
|
||||||
|
--output ${Coverage_NAME}.info
|
||||||
|
--exclude ${FASTCOV_EXCLUDES}
|
||||||
|
--exclude ${FASTCOV_EXCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(Coverage_SKIP_HTML)
|
||||||
|
set(FASTCOV_HTML_CMD ";")
|
||||||
|
else()
|
||||||
|
set(FASTCOV_HTML_CMD ${GENHTML_PATH} ${GENHTML_EXTRA_ARGS} ${Coverage_GENHTML_ARGS}
|
||||||
|
-o ${Coverage_NAME} ${Coverage_NAME}.info
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CODE_COVERAGE_VERBOSE)
|
||||||
|
message(STATUS "Code coverage commands for target ${Coverage_NAME} (fastcov):")
|
||||||
|
|
||||||
|
message(" Running tests:")
|
||||||
|
string(REPLACE ";" " " FASTCOV_EXEC_TESTS_CMD_SPACED "${FASTCOV_EXEC_TESTS_CMD}")
|
||||||
|
message(" ${FASTCOV_EXEC_TESTS_CMD_SPACED}")
|
||||||
|
|
||||||
|
message(" Capturing fastcov counters and generating report:")
|
||||||
|
string(REPLACE ";" " " FASTCOV_CAPTURE_CMD_SPACED "${FASTCOV_CAPTURE_CMD}")
|
||||||
|
message(" ${FASTCOV_CAPTURE_CMD_SPACED}")
|
||||||
|
|
||||||
|
if(NOT Coverage_SKIP_HTML)
|
||||||
|
message(" Generating HTML report: ")
|
||||||
|
string(REPLACE ";" " " FASTCOV_HTML_CMD_SPACED "${FASTCOV_HTML_CMD}")
|
||||||
|
message(" ${FASTCOV_HTML_CMD_SPACED}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Setup target
|
||||||
|
add_custom_target(${Coverage_NAME}
|
||||||
|
|
||||||
|
# Cleanup fastcov
|
||||||
|
COMMAND ${FASTCOV_PATH} ${Coverage_FASTCOV_ARGS} --gcov ${GCOV_PATH}
|
||||||
|
--search-directory ${BASEDIR}
|
||||||
|
--zerocounters
|
||||||
|
|
||||||
|
COMMAND ${FASTCOV_EXEC_TESTS_CMD}
|
||||||
|
COMMAND ${FASTCOV_CAPTURE_CMD}
|
||||||
|
COMMAND ${FASTCOV_HTML_CMD}
|
||||||
|
|
||||||
|
# Set output files as GENERATED (will be removed on 'make clean')
|
||||||
|
BYPRODUCTS
|
||||||
|
${Coverage_NAME}.info
|
||||||
|
${Coverage_NAME}/index.html # report directory
|
||||||
|
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
DEPENDS ${Coverage_DEPENDENCIES}
|
||||||
|
VERBATIM # Protect arguments to commands
|
||||||
|
COMMENT "Resetting code coverage counters to zero. Processing code coverage counters and generating report."
|
||||||
|
)
|
||||||
|
|
||||||
|
set(INFO_MSG "fastcov code coverage info report saved in ${Coverage_NAME}.info.")
|
||||||
|
if(NOT Coverage_SKIP_HTML)
|
||||||
|
string(APPEND INFO_MSG " Open ${PROJECT_BINARY_DIR}/${Coverage_NAME}/index.html in your browser to view the coverage report.")
|
||||||
|
endif()
|
||||||
|
# Show where to find the fastcov info report
|
||||||
|
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo ${INFO_MSG}
|
||||||
|
)
|
||||||
|
|
||||||
|
endfunction() # setup_target_for_coverage_fastcov
|
||||||
|
|
||||||
|
function(append_coverage_compiler_flags)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||||
|
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||||
|
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
|
||||||
|
endfunction() # append_coverage_compiler_flags
|
||||||
141
login_server/cmake/GetGitRevisionDescription.cmake
Normal file
141
login_server/cmake/GetGitRevisionDescription.cmake
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
# - Returns a version string from Git
|
||||||
|
#
|
||||||
|
# These functions force a re-configure on each git commit so that you can
|
||||||
|
# trust the values of the variables in your build system.
|
||||||
|
#
|
||||||
|
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||||
|
#
|
||||||
|
# Returns the refspec and sha hash of the current head revision
|
||||||
|
#
|
||||||
|
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||||
|
#
|
||||||
|
# Returns the results of git describe on the source tree, and adjusting
|
||||||
|
# the output so that it tests false if an error occurs.
|
||||||
|
#
|
||||||
|
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||||
|
#
|
||||||
|
# Returns the results of git describe --exact-match on the source tree,
|
||||||
|
# and adjusting the output so that it tests false if there was no exact
|
||||||
|
# matching tag.
|
||||||
|
#
|
||||||
|
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2009-2010.
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
if(__get_git_revision_description)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(__get_git_revision_description YES)
|
||||||
|
|
||||||
|
# We must run the following at "include" time, not at function call time,
|
||||||
|
# to find the path to this module rather than the path to a calling list file
|
||||||
|
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||||
|
|
||||||
|
function(get_git_head_revision _refspecvar _hashvar)
|
||||||
|
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||||
|
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||||
|
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||||
|
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||||
|
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||||
|
# We have reached the root directory, we are not in git
|
||||||
|
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||||
|
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||||
|
endwhile()
|
||||||
|
# check if this is a submodule
|
||||||
|
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||||
|
file(READ ${GIT_DIR} submodule)
|
||||||
|
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||||
|
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||||
|
|
||||||
|
if (IS_ABSOLUTE ${GIT_DIR_RELATIVE})
|
||||||
|
set(GIT_DIR ${GIT_DIR_RELATIVE})
|
||||||
|
else()
|
||||||
|
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||||
|
if(NOT EXISTS "${GIT_DATA}")
|
||||||
|
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||||
|
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||||
|
|
||||||
|
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||||
|
"${GIT_DATA}/grabRef.cmake"
|
||||||
|
@ONLY)
|
||||||
|
include("${GIT_DATA}/grabRef.cmake")
|
||||||
|
|
||||||
|
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||||
|
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_describe _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
get_git_head_revision(refspec hash)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT hash)
|
||||||
|
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO sanitize
|
||||||
|
#if((${ARGN}" MATCHES "&&") OR
|
||||||
|
# (ARGN MATCHES "||") OR
|
||||||
|
# (ARGN MATCHES "\\;"))
|
||||||
|
# message("Please report the following error to the project!")
|
||||||
|
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||||
|
|
||||||
|
execute_process(COMMAND
|
||||||
|
${GIT_EXECUTABLE}
|
||||||
|
describe
|
||||||
|
${hash}
|
||||||
|
${ARGN}
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
"${CMAKE_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE
|
||||||
|
res
|
||||||
|
OUTPUT_VARIABLE
|
||||||
|
out
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "${out}-${res}-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_var} "${out}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_get_exact_tag _var)
|
||||||
|
git_describe(out --exact-match ${ARGN})
|
||||||
|
set(${_var} "${out}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_get_tag _var)
|
||||||
|
git_describe(out --tags ${ARGN})
|
||||||
|
set(${_var} "${out}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
23
login_server/cmake/LICENSE_1_0.txt
Normal file
23
login_server/cmake/LICENSE_1_0.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
72
login_server/cmake/README.md
Normal file
72
login_server/cmake/README.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
Additional CMake Modules
|
||||||
|
========================
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
|
||||||
|
This is a collection of additional CMake modules.
|
||||||
|
Most of them are from Ryan Pavlik (<http://academic.cleardefinition.com>).
|
||||||
|
|
||||||
|
How to Integrate
|
||||||
|
----------------
|
||||||
|
|
||||||
|
These modules are probably best placed wholesale into a "cmake" subdirectory
|
||||||
|
of your project source.
|
||||||
|
|
||||||
|
If you use Git, try installing [git-subtree][1],
|
||||||
|
so you can easily use this repository for subtree merges, updating simply.
|
||||||
|
|
||||||
|
For the initial checkout:
|
||||||
|
|
||||||
|
cd projectdir
|
||||||
|
|
||||||
|
git subtree add --squash --prefix=cmake git@github.com:bilke/cmake-modules.git master
|
||||||
|
|
||||||
|
For updates:
|
||||||
|
|
||||||
|
cd projectdir
|
||||||
|
|
||||||
|
git subtree pull --squash --prefix=cmake git@github.com:bilke/cmake-modules.git master
|
||||||
|
|
||||||
|
For pushing to upstream:
|
||||||
|
|
||||||
|
cd projectdir
|
||||||
|
|
||||||
|
git subtree push --prefix=cmake git@github.com:bilke/cmake-modules.git master
|
||||||
|
|
||||||
|
|
||||||
|
How to Use
|
||||||
|
----------
|
||||||
|
|
||||||
|
At the minimum, all you have to do is add a line like this near the top
|
||||||
|
of your root CMakeLists.txt file (but not before your project() call):
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
|
||||||
|
Licenses
|
||||||
|
--------
|
||||||
|
|
||||||
|
The modules that are written by Ryan Pavlik are all subject to this license:
|
||||||
|
|
||||||
|
> Copyright Iowa State University 2009-2011
|
||||||
|
>
|
||||||
|
> Distributed under the Boost Software License, Version 1.0.
|
||||||
|
>
|
||||||
|
> (See accompanying file `LICENSE_1_0.txt` or copy at
|
||||||
|
> <http://www.boost.org/LICENSE_1_0.txt>)
|
||||||
|
|
||||||
|
Modules based on those included with CMake as well as modules added by me (Lars
|
||||||
|
Bilke) are under the OSI-approved **BSD** license, which is included in each of
|
||||||
|
those modules. A few other modules are modified from other sources - when in
|
||||||
|
doubt, look at the .cmake.
|
||||||
|
|
||||||
|
Important License Note!
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
If you find this file inside of another project, rather at the top-level
|
||||||
|
directory, you're in a separate project that is making use of these modules.
|
||||||
|
That separate project can (and probably does) have its own license specifics.
|
||||||
|
|
||||||
|
|
||||||
|
[1]: http://github.com/apenwarr/git-subtree "Git Subtree master"
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit b95393dcc3640807838e8323b4e600e54d2e8116
|
Subproject commit 3fc3e5f5b8462f7666952b43381383a79b8b5d92
|
||||||
@ -352,9 +352,9 @@ const Mnemonic* Passphrase::detectMnemonic(const std::string& passphrase, const
|
|||||||
|
|
||||||
if (keyPair) {
|
if (keyPair) {
|
||||||
user_public_key_hex = DataTypeConverter::pubkeyToHex(keyPair->getPublicKey());
|
user_public_key_hex = DataTypeConverter::pubkeyToHex(keyPair->getPublicKey());
|
||||||
printf("user public key hex: %s\n", user_public_key_hex.data());
|
//printf("user public key hex: %s\n", user_public_key_hex.data());
|
||||||
}
|
}
|
||||||
|
std::string last_words_not_found[ServerConfig::Mnemonic_Types::MNEMONIC_MAX];
|
||||||
for (int i = 0; i < ServerConfig::Mnemonic_Types::MNEMONIC_MAX; i++) {
|
for (int i = 0; i < ServerConfig::Mnemonic_Types::MNEMONIC_MAX; i++) {
|
||||||
Mnemonic& m = ServerConfig::g_Mnemonic_WordLists[i];
|
Mnemonic& m = ServerConfig::g_Mnemonic_WordLists[i];
|
||||||
bool existAll = true;
|
bool existAll = true;
|
||||||
@ -362,6 +362,8 @@ const Mnemonic* Passphrase::detectMnemonic(const std::string& passphrase, const
|
|||||||
if (*it == "\0" || *it == "" || it->size() < 3) continue;
|
if (*it == "\0" || *it == "" || it->size() < 3) continue;
|
||||||
if (!m.isWordExist(*it)) {
|
if (!m.isWordExist(*it)) {
|
||||||
existAll = false;
|
existAll = false;
|
||||||
|
//printf("couldn't find word: %s\n", (*it).data());
|
||||||
|
last_words_not_found[i] = (*it);
|
||||||
// leave inner for-loop
|
// leave inner for-loop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -372,10 +374,14 @@ const Mnemonic* Passphrase::detectMnemonic(const std::string& passphrase, const
|
|||||||
test_passphrase->createWordIndices();
|
test_passphrase->createWordIndices();
|
||||||
auto key_pair = KeyPairEd25519::create(test_passphrase);
|
auto key_pair = KeyPairEd25519::create(test_passphrase);
|
||||||
if (key_pair) {
|
if (key_pair) {
|
||||||
std::string current_key_pair = DataTypeConverter::pubkeyToHex(key_pair->getPublicKey());
|
|
||||||
printf("public key hex to compare: %s\n", current_key_pair.data());
|
|
||||||
|
|
||||||
if (*key_pair != *keyPair) {
|
if (*key_pair != *keyPair) {
|
||||||
|
#ifdef _TEST_BUILD // additional infos for debugging if error occure in test
|
||||||
|
printf("public key mismatch\n");
|
||||||
|
std::string generated_key_pair_hex = DataTypeConverter::pubkeyToHex(key_pair->getPublicKey());
|
||||||
|
std::string parameter_key_pair_hex = DataTypeConverter::pubkeyToHex(keyPair->getPublicKey());
|
||||||
|
printf("parameter: %s, generated: %s\n", parameter_key_pair_hex.data(), generated_key_pair_hex.data());
|
||||||
|
#endif
|
||||||
delete key_pair;
|
delete key_pair;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -386,6 +392,8 @@ const Mnemonic* Passphrase::detectMnemonic(const std::string& passphrase, const
|
|||||||
}
|
}
|
||||||
return &ServerConfig::g_Mnemonic_WordLists[i];
|
return &ServerConfig::g_Mnemonic_WordLists[i];
|
||||||
}
|
}
|
||||||
|
//printf("last word not found: %s in %s\n", last_words_not_found[i].data(), ServerConfig::mnemonicTypeToString((ServerConfig::Mnemonic_Types)i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -34,10 +34,12 @@ SecretKeyCryptography::ResultType SecretKeyCryptography::createKey(const std::st
|
|||||||
assert(app_secret);
|
assert(app_secret);
|
||||||
Profiler timeUsed;
|
Profiler timeUsed;
|
||||||
std::unique_lock<std::shared_mutex> _lock(mWorkingMutex);
|
std::unique_lock<std::shared_mutex> _lock(mWorkingMutex);
|
||||||
|
#ifndef _TEST_BUILD
|
||||||
if (timeUsed.millis() > 10) {
|
if (timeUsed.millis() > 10) {
|
||||||
printf("[AuthenticatedEncryption::createKey] wait %s on getting lock\n", timeUsed.string().data());
|
printf("[SecretKeyCryptography::createKey] wait %s on getting lock\n", timeUsed.string().data());
|
||||||
timeUsed.reset();
|
timeUsed.reset();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// use hash512 because existing data where calculated with that, but could be also changed to hash256
|
// use hash512 because existing data where calculated with that, but could be also changed to hash256
|
||||||
auto hash512_salt = mm->getFreeMemory(crypto_hash_sha512_BYTES); // need at least crypto_pwhash_SALTBYTES 16U
|
auto hash512_salt = mm->getFreeMemory(crypto_hash_sha512_BYTES); // need at least crypto_pwhash_SALTBYTES 16U
|
||||||
@ -49,10 +51,12 @@ SecretKeyCryptography::ResultType SecretKeyCryptography::createKey(const std::st
|
|||||||
crypto_hash_sha512_update(&state, *app_secret, app_secret->size());
|
crypto_hash_sha512_update(&state, *app_secret, app_secret->size());
|
||||||
crypto_hash_sha512_final(&state, *hash512_salt);
|
crypto_hash_sha512_final(&state, *hash512_salt);
|
||||||
|
|
||||||
|
#ifndef _TEST_BUILD
|
||||||
if (timeUsed.millis() > 200) {
|
if (timeUsed.millis() > 200) {
|
||||||
printf("[AuthenticatedEncryption::createKey] %s calculating sha512\n", timeUsed.string().data());
|
printf("[SecretKeyCryptography::createKey] %s calculating sha512\n", timeUsed.string().data());
|
||||||
timeUsed.reset();
|
timeUsed.reset();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//unsigned char* key = (unsigned char *)malloc(crypto_box_SEEDBYTES); // 32U
|
//unsigned char* key = (unsigned char *)malloc(crypto_box_SEEDBYTES); // 32U
|
||||||
//ObfusArray* key = new ObfusArray(crypto_box_SEEDBYTES);
|
//ObfusArray* key = new ObfusArray(crypto_box_SEEDBYTES);
|
||||||
@ -68,9 +72,11 @@ SecretKeyCryptography::ResultType SecretKeyCryptography::createKey(const std::st
|
|||||||
|
|
||||||
return AUTH_CREATE_ENCRYPTION_KEY_FAILED;
|
return AUTH_CREATE_ENCRYPTION_KEY_FAILED;
|
||||||
}
|
}
|
||||||
|
#ifndef _TEST_BUILD
|
||||||
if (timeUsed.millis() > 400) {
|
if (timeUsed.millis() > 400) {
|
||||||
printf("[AuthenticatedEncryption::createKey] %s calculating pwd hash\n", timeUsed.string().data());
|
printf("[SecretKeyCryptography::createKey] %s calculating pwd hash\n", timeUsed.string().data());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// generate hash from key for compare
|
// generate hash from key for compare
|
||||||
assert(sizeof(KeyHashed) >= crypto_shorthash_BYTES);
|
assert(sizeof(KeyHashed) >= crypto_shorthash_BYTES);
|
||||||
assert(ServerConfig::g_ServerCryptoKey);
|
assert(ServerConfig::g_ServerCryptoKey);
|
||||||
|
|||||||
@ -171,6 +171,20 @@ namespace ServerConfig {
|
|||||||
return HEDERA_CONSENSUS_FORMAT_BINARY;
|
return HEDERA_CONSENSUS_FORMAT_BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* mnemonicTypeToString(Mnemonic_Types type)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER,
|
||||||
|
MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES,
|
||||||
|
MNEMONIC_BIP0039_SORTED_ORDER
|
||||||
|
*/
|
||||||
|
switch(type) {
|
||||||
|
case MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER: return "german random order";
|
||||||
|
case MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES: return "german random order fixed cases";
|
||||||
|
case MNEMONIC_BIP0039_SORTED_ORDER: return "BIP 0039 sorted";
|
||||||
|
}
|
||||||
|
return "<unknown>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -102,6 +102,7 @@ namespace ServerConfig {
|
|||||||
bool initEMailAccount(const Poco::Util::LayeredConfiguration& cfg);
|
bool initEMailAccount(const Poco::Util::LayeredConfiguration& cfg);
|
||||||
bool initSSLClientContext();
|
bool initSSLClientContext();
|
||||||
|
|
||||||
|
const char* mnemonicTypeToString(Mnemonic_Types type);
|
||||||
|
|
||||||
void writeToFile(std::istream& datas, std::string fileName);
|
void writeToFile(std::istream& datas, std::string fileName);
|
||||||
|
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
#include "TestHash.h"
|
|
||||||
#include "../lib/DRHash.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
TestHash::TestHash()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
TestHash::~TestHash()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int TestHash::init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int TestHash::test()
|
|
||||||
{
|
|
||||||
std::string testEmails[] = {
|
|
||||||
"a","b", "c", "d", "aa", "ab",
|
|
||||||
"@", ".d", "gmx", "@gmx", "@gmx.de",
|
|
||||||
"***REMOVED***",
|
|
||||||
"***REMOVED***",
|
|
||||||
"coin-info5@gradido.net",
|
|
||||||
"coin-info6@gradido.net",
|
|
||||||
"coin-info8@gradido.net",
|
|
||||||
"coin-info9@gradido.net",
|
|
||||||
"coin-info10@gradido.net",
|
|
||||||
"coin-info11@gradido.net",
|
|
||||||
"coin-info12@gradido.net"
|
|
||||||
};
|
|
||||||
printf("hashes: \n");
|
|
||||||
for (int i = 0; i < 20; i++) {
|
|
||||||
DHASH id = DRMakeStringHash(testEmails[i].data(), testEmails[i].size());
|
|
||||||
//printf("%s: %lu\n", testEmails[i].data(), id);
|
|
||||||
//"***REMOVED***" => 1211212
|
|
||||||
printf("\"%s\" => %lu,\n", testEmails[i].data(), id);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
#ifndef __GRADIDO_LOGIN_SERVER_TEST_HASH_
|
|
||||||
#define __GRADIDO_LOGIN_SERVER_TEST_HASH_
|
|
||||||
|
|
||||||
#include "Test.h"
|
|
||||||
|
|
||||||
class TestHash : public Test
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TestHash();
|
|
||||||
~TestHash();
|
|
||||||
//! \return 0 if init okay, else return != 0
|
|
||||||
int init();
|
|
||||||
|
|
||||||
//! \return 0 if okay, else return != 0
|
|
||||||
int test();
|
|
||||||
const char* getName() { return "TestHash"; };
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__GRADIDO_LOGIN_SERVER_TEST_HASH_
|
|
||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "../../Crypto/SecretKeyCryptography.h"
|
#include "../../Crypto/SecretKeyCryptography.h"
|
||||||
|
|
||||||
#include "../../lib/Profiler.h"
|
|
||||||
#include "../../lib/DataTypeConverter.h"
|
#include "../../lib/DataTypeConverter.h"
|
||||||
|
|
||||||
#include "../../ServerConfig.h"
|
#include "../../ServerConfig.h"
|
||||||
@ -16,9 +15,8 @@ TEST_F(TestAuthenticatedEncryption, encryptDecryptTest) {
|
|||||||
EXPECT_FALSE(authenticated_encryption.hasKey());
|
EXPECT_FALSE(authenticated_encryption.hasKey());
|
||||||
EXPECT_EQ(authenticated_encryption.getKeyHashed(), 0);
|
EXPECT_EQ(authenticated_encryption.getKeyHashed(), 0);
|
||||||
|
|
||||||
Profiler time_used;
|
EXPECT_EQ(authenticated_encryption.createKey("max.musterman@gmail.com", "r3an7d_spassw"), SecretKeyCryptography::AUTH_CREATE_ENCRYPTION_KEY_SUCCEED);
|
||||||
EXPECT_EQ(authenticated_encryption.createKey("dariofrodo@gmx.de", "r3an7d_spassw"), SecretKeyCryptography::AUTH_ENCRYPT_OK);
|
//printf("create key duration: %s\n", time_used.string().data());
|
||||||
printf("create key duration: %s\n", time_used.string().data());
|
|
||||||
|
|
||||||
EXPECT_TRUE(authenticated_encryption.hasKey());
|
EXPECT_TRUE(authenticated_encryption.hasKey());
|
||||||
|
|
||||||
@ -28,15 +26,14 @@ TEST_F(TestAuthenticatedEncryption, encryptDecryptTest) {
|
|||||||
MemoryBin* encrypted_message = nullptr;
|
MemoryBin* encrypted_message = nullptr;
|
||||||
memcpy(*test_message_bin, test_message.data(), test_message.size());
|
memcpy(*test_message_bin, test_message.data(), test_message.size());
|
||||||
|
|
||||||
time_used.reset();
|
|
||||||
EXPECT_EQ(authenticated_encryption.encrypt(test_message_bin, &encrypted_message), SecretKeyCryptography::AUTH_ENCRYPT_OK);
|
EXPECT_EQ(authenticated_encryption.encrypt(test_message_bin, &encrypted_message), SecretKeyCryptography::AUTH_ENCRYPT_OK);
|
||||||
printf("encrypt message duration: %s\n", time_used.string().data());
|
//printf("encrypt message duration: %s\n", time_used.string().data());
|
||||||
|
|
||||||
MemoryBin* decrypted_message = nullptr;
|
MemoryBin* decrypted_message = nullptr;
|
||||||
time_used.reset();
|
|
||||||
EXPECT_EQ(authenticated_encryption.decrypt(encrypted_message, &decrypted_message), SecretKeyCryptography::AUTH_DECRYPT_OK);
|
EXPECT_EQ(authenticated_encryption.decrypt(encrypted_message, &decrypted_message), SecretKeyCryptography::AUTH_DECRYPT_OK);
|
||||||
printf("decrypt message duration: %s\n", time_used.string().data());
|
//printf("decrypt message duration: %s\n", time_used.string().data());
|
||||||
|
|
||||||
EXPECT_EQ(std::string((const char*)*decrypted_message, decrypted_message->size()), test_message);
|
EXPECT_EQ(std::string((const char*)*decrypted_message, decrypted_message->size()), test_message);
|
||||||
|
mm->releaseMemory(decrypted_message);
|
||||||
// */
|
// */
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ void PassphraseTest::SetUp()
|
|||||||
};
|
};
|
||||||
std::string passphrases1[] = {
|
std::string passphrases1[] = {
|
||||||
"Fichte Heuschrecke Botschafter Göttingen Leasing losfliegen simpel enorm erkämpft Werk Wolke vorhanden jene Slums stagnieren Verifizieren insgesamt Hanau simpel Inspiration delegieren umtauschen ablegen suggerieren ",
|
"Fichte Heuschrecke Botschafter Göttingen Leasing losfliegen simpel enorm erkämpft Werk Wolke vorhanden jene Slums stagnieren Verifizieren insgesamt Hanau simpel Inspiration delegieren umtauschen ablegen suggerieren ",
|
||||||
"ankommt gesamt gestorben müde Argument stolz diskutiert Kette Leonardo riesig Igor berauben prüfen bislang Villa Fortschritt moralisch unfähig diskutiert erwidern Hanau Plage Fossilien ethnisch ",
|
"ankommt gesamt gestorben müde sind stolz Enkel geklappt Leonardo riesig Bezugsquelle berauben prüfen bislang Villa Fortschritt moralisch unfähig Enkel erwidern Hanau Plage Fossilien ethnisch ",
|
||||||
"beauty slight skill maze wrap neither table term pizza journey unusual fence mind buzz scrap height critic service table knock fury shrimp curious fog "
|
"beauty slight skill maze wrap neither table term pizza journey unusual fence mind buzz scrap height critic service table knock fury shrimp curious fog "
|
||||||
};
|
};
|
||||||
mPassphrasesForTesting.push_back(PassphraseDataSet(
|
mPassphrasesForTesting.push_back(PassphraseDataSet(
|
||||||
@ -57,7 +57,7 @@ void PassphraseTest::SetUp()
|
|||||||
};
|
};
|
||||||
std::string passphrases2[] = {
|
std::string passphrases2[] = {
|
||||||
"oftmals bist bietet spalten Datenbank Masse sträflich hervor Derartig Hallo christlich Brief iPhone einpendeln telefonieren musizieren gigantisch Orchester zirkulieren essen gilt Erich Dollar money ",
|
"oftmals bist bietet spalten Datenbank Masse sträflich hervor Derartig Hallo christlich Brief iPhone einpendeln telefonieren musizieren gigantisch Orchester zirkulieren essen gilt Erich Dollar money ",
|
||||||
"Angst ausbeuten besser bekannt Bedürfnisse Neidisch virtuell Pension geprägt inmitten Abfall Absatzmarkt Umkehrschluss Fidel jeder Heinrich Engagement leihen gezogen Disziplin zufolge raffen Iris Jäger ",
|
"Angst ausbeuten besser bekannt Bedürfnisse Neidisch virtuell Pension geprägt inmitten Abfall Absatzmarkt Wettbewerb Fidel jeder Heinrich Engagement leihen viertel Disziplin zufolge erwarten Iris Jäger ",
|
||||||
"fresh hamster canvas lyrics chat mutual pair color airport estate fly assault suspect deliver similar fancy grass cliff tenant apple divert timber analyst seed "
|
"fresh hamster canvas lyrics chat mutual pair color airport estate fly assault suspect deliver similar fancy grass cliff tenant apple divert timber analyst seed "
|
||||||
};
|
};
|
||||||
mPassphrasesForTesting.push_back(PassphraseDataSet(
|
mPassphrasesForTesting.push_back(PassphraseDataSet(
|
||||||
@ -73,7 +73,7 @@ void PassphraseTest::SetUp()
|
|||||||
};
|
};
|
||||||
std::string passphrases3[] = {
|
std::string passphrases3[] = {
|
||||||
"tief Acker Abgaben jenseits Revolution verdeckt Entdeckung Sanktion sammeln Umdrehung regulieren murmeln Erkenntnis hart zwar zuspitzen indem fegen bomber zwölf Mobbing divers Inspiration Krieg ",
|
"tief Acker Abgaben jenseits Revolution verdeckt Entdeckung Sanktion sammeln Umdrehung regulieren murmeln Erkenntnis hart zwar zuspitzen indem fegen bomber zwölf Mobbing divers Inspiration Krieg ",
|
||||||
"aushalten absolut signifikant Bezahlung zukunftsfähig Wurzel spalten unausweichlich dunkel halb Nagel nehmen Begabung bezwingen wehren Fohlen keiner Krankheit leiblich Rücken Finnland sehen erwidern Absätze ",
|
"aushalten absolut signifikant Bezahlung zukunftsfähig Wurzel ergründen unausweichlich dunkel halb Nagel nehmen Begabung bezwingen wehren Fohlen keiner Krankheit leiblich Äste Finnland sehen erwidern Absätze ",
|
||||||
"rack gentle paddle illness feature fatigue teach ball dust decade dish kick skate income small pill collect often man trap doctor coffee knock excuse "
|
"rack gentle paddle illness feature fatigue teach ball dust decade dish kick skate income small pill collect often man trap doctor coffee knock excuse "
|
||||||
};
|
};
|
||||||
mPassphrasesForTesting.push_back(PassphraseDataSet(
|
mPassphrasesForTesting.push_back(PassphraseDataSet(
|
||||||
|
|||||||
@ -16,7 +16,6 @@ std::list<Test*> gTests;
|
|||||||
void fillTests()
|
void fillTests()
|
||||||
{
|
{
|
||||||
gTests.push_back(new TestTasks());
|
gTests.push_back(new TestTasks());
|
||||||
gTests.push_back(new TestHash());
|
|
||||||
gTests.push_back(new TestRegExp());
|
gTests.push_back(new TestRegExp());
|
||||||
gTests.push_back(new TestPassphrase());
|
gTests.push_back(new TestPassphrase());
|
||||||
// gTests.push_back(new LoginTest());
|
// gTests.push_back(new LoginTest());
|
||||||
@ -41,8 +40,14 @@ int load() {
|
|||||||
// init server config, init seed array
|
// init server config, init seed array
|
||||||
|
|
||||||
Poco::AutoPtr<Poco::Util::LayeredConfiguration> test_config(new Poco::Util::LayeredConfiguration);
|
Poco::AutoPtr<Poco::Util::LayeredConfiguration> test_config(new Poco::Util::LayeredConfiguration);
|
||||||
auto cfg = new Poco::Util::PropertyFileConfiguration("Gradido_LoginServer_Test.properties");
|
try {
|
||||||
test_config->add(cfg);
|
auto cfg = new Poco::Util::PropertyFileConfiguration("Gradido_LoginServer_Test.properties");
|
||||||
|
test_config->add(cfg);
|
||||||
|
}
|
||||||
|
catch (Poco::Exception& ex) {
|
||||||
|
printf("[load] error loading Gradido_LoginServer_Test.properties, make sure this file exist! (%s)\n", ex.displayText().data());
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ServerConfig::initServerCrypto(*test_config)) {
|
if (!ServerConfig::initServerCrypto(*test_config)) {
|
||||||
//printf("[Gradido_LoginServer::%s] error init server crypto\n", __FUNCTION__);
|
//printf("[Gradido_LoginServer::%s] error init server crypto\n", __FUNCTION__);
|
||||||
@ -67,9 +72,13 @@ int load() {
|
|||||||
auto conn = ConnectionManager::getInstance();
|
auto conn = ConnectionManager::getInstance();
|
||||||
//conn->setConnection()
|
//conn->setConnection()
|
||||||
//printf("try connect login server mysql db\n");
|
//printf("try connect login server mysql db\n");
|
||||||
conn->setConnectionsFromConfig(*test_config, CONNECTION_MYSQL_LOGIN_SERVER);
|
try {
|
||||||
|
conn->setConnectionsFromConfig(*test_config, CONNECTION_MYSQL_LOGIN_SERVER);
|
||||||
|
} catch(Poco::Exception& ex) {
|
||||||
|
printf("Poco Exception by connecting to db: %s\n", ex.displayText().data());
|
||||||
|
}
|
||||||
//printf("try connect php server mysql \n");
|
//printf("try connect php server mysql \n");
|
||||||
conn->setConnectionsFromConfig(*test_config, CONNECTION_MYSQL_PHP_SERVER);
|
//conn->setConnectionsFromConfig(*test_config, CONNECTION_MYSQL_PHP_SERVER);
|
||||||
|
|
||||||
Profiler timeUsed;
|
Profiler timeUsed;
|
||||||
|
|
||||||
@ -89,168 +98,30 @@ int load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "INSERT INTO `users` (`id`, `email`, `first_name`, `last_name`, `password`, `pubkey`, `privkey`, `created`, `email_checked`, `passphrase_shown`, `language`, `disabled`) VALUES "
|
|
||||||
<< "(1, 'einhorn_silas@ist-allein.info', 'DDD', 'Schultz', 13134558453895551556, 0x146d3fb9e88abc0fca0b0091c1ab1b32b399be037436f340befa8bf004461889, 0x0dcc08960f45f631fe23bc7ddee0724cedc9ec0c861ce30f5091d20ffd96062d08ca215726fb9bd64860c754772e945eea4cc872ed0a36c7b640e8b0bf7a873ec6765fa510711622341347ce2307b5ce, '2020-02-20 16:05:44', 1, 0, 'de', 0), "
|
|
||||||
<< "(2, 'Dario.Rekowski@buerotiger.de', 'Darios', 'Bruder', 12910944485867375321, 0x952e215a21d4376b4ac252c4bf41e156e1498e1b6b8ccf2a6826d96712f4f461, 0x4d40bf0860655f728312140dc3741e897bc2d13d00ea80a63e2961046a5a7bd8315397dfb488b89377087bc1a5f4f3af8ffdcf203329ae23ba04be7d38ad3852699d90ff1fc00e5b1ca92b64cc59c01f, '2020-02-20 16:05:44', 1, 0, 'de', 0), "
|
|
||||||
<< "(3, 'morgenstern175@es-ist-liebe.de', 'Dieter', 'Schultz', 13528673707291575501, 0xb539944bf6444a2bfc988244f0c0c9dc326452be9b8a2a43fcd90663719f4f6d, 0x5461fda60b719b65ba00bd6298e48410c4cbf0e89deb13cc784ba8978cf047454e8556ee3eddc8487ee835c33a83163bc8d8babbf2a5c431876bc0a0c114ff0a0d6b57baa12cf8f23c64fb642c862db5, '2020-02-20 16:05:45', 1, 0, 'de', 0), "
|
|
||||||
<< "(4, 'spaceteam@gmx.de', 'Bernd', 'Hückstädt', 15522411320147607375, 0x476b059744f08b0995522b484c90f8d2f47d9b59f4b3c96d9dc0ae6ab7b84979, 0x5277bf044cba4fec64e6f4d38da132755b029161231daefc9a7b4692ad37e05cdd88e0a2c2215baf854dd3a813578c214167af1113607e9f999ca848a7598ba5068e38f2a1afb097e4752a88024d79c8, '2020-02-20 16:05:46', 1, 0, 'de', 0), "
|
|
||||||
<< "(5, 'em741@gmx.de', 'Thomas', 'Markuk', 7022671043835614958, 0xb1584e169d60a7e771d3a348235dfd7b5f9e8235fcc26090761a0264b0daa6ff, 0xb46fb7110bf91e28f367aa80f84d1bbd639b6f689f4b0aa28c0f71529232df9bf9ee0fb02fa4c1b9f5a6799c82d119e5646f7231d011517379faaacf6513d973ac3043d4c786490ba62d56d75b86164d, '2020-02-20 16:05:46', 1, 0, 'de', 0), "
|
|
||||||
<< "(6, 'coin-info12@gradido.net', 'coin-info12', 'Test', 1548398919826089202, 0x4046ae49c1b620f2a321aba0c874fa2bc7ba844ab808bb0eeb18a908d468db14, 0x9522657ecd7456eedf86d065aa087ba7a94a8961a8e4950d044136155d38fe0840f2c0a2876ce055b3eaa6e9ab95c5feba89e535e0434fb2648d94d6e6ec68211aa2ea9e42d1ccd40b6b3c31e41f848e, '2020-02-20 16:05:47', 1, 0, 'de', 0), "
|
|
||||||
<< "(7, 'info@einhornimmond.de', 'Alex', 'Wesper', 5822761891727948301, 0xb13ede3402abb8f29722b14fec0a2006ae7a3a51fb677cd6a2bbd797ac6905a5, 0x6aa39d7670c64a31639c7d89b874ad929b2eaeb2e5992dbad71b6cea700bf9e3c6cf866d0f0fdc22b44a0ebf51a860799e880ef86266199931dd0a301e5552db44b9b7fa99ed5945652bc7b31eff767c, '2020-02-20 16:05:47', 1, 0, 'de', 0); ";
|
|
||||||
runMysql(ss.str());
|
|
||||||
ss.str(std::string());
|
|
||||||
|
|
||||||
ss << "INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `description`) VALUES "
|
|
||||||
<< "(1, 'gdd1', 'Gradido1', 'gdd1.gradido.com', 'Der erste offizielle Gradido Server (zum Testen)'); ";
|
|
||||||
runMysql(ss.str());
|
|
||||||
ss.str(std::string());
|
|
||||||
|
|
||||||
ss << "INSERT INTO `hedera_accounts` (`id`, `user_id`, `account_hedera_id`, `account_key_id`, `balance`, `network_type`, `updated`) VALUES "
|
|
||||||
<< "(1, 2, 15, 1, 1000000000000, 1, '2020-09-03 11:13:52'), "
|
|
||||||
<< "(2, 2, 17, 2, 22787166159, 0, '2020-09-03 11:13:56'); ";
|
|
||||||
runMysql(ss.str());
|
|
||||||
ss.str(std::string());
|
|
||||||
|
|
||||||
ss << "INSERT INTO `hedera_ids` (`id`, `shardNum`, `realmNum`, `num`) VALUES "
|
ss << "INSERT INTO `hedera_ids` (`id`, `shardNum`, `realmNum`, `num`) VALUES "
|
||||||
<< "(1, 0, 0, 3), "
|
<< "(1, 0, 0, 37281), "
|
||||||
<< "(2, 0, 0, 4),"
|
<< "(2, 0, 0, 21212), "
|
||||||
<< "(3, 0, 0, 5),"
|
<< "(3, 0, 0, 212);";
|
||||||
<< "(4, 0, 0, 6),"
|
|
||||||
<< "(6, 0, 0, 3),"
|
|
||||||
<< "(10, 0, 0, 7),"
|
|
||||||
<< "(11, 0, 0, 8),"
|
|
||||||
<< "(12, 0, 0, 9),"
|
|
||||||
<< "(13, 0, 0, 10),"
|
|
||||||
<< "(14, 0, 0, 12),"
|
|
||||||
<< "(15, 0, 0, 3327),"
|
|
||||||
<< "(16, 0, 0, 3323),"
|
|
||||||
<< "(17, 0, 0, 8707),"
|
|
||||||
<< "(18, 0, 0, 39446);";
|
|
||||||
runMysql(ss.str());
|
runMysql(ss.str());
|
||||||
ss.str(std::string());
|
ss.str(std::string());
|
||||||
|
|
||||||
ss << "INSERT INTO `crypto_keys` (`id`, `private_key`, `public_key`, `crypto_key_type_id`) VALUES "
|
ss << "INSERT INTO `crypto_keys` (`id`, `private_key`, `public_key`, `crypto_key_type_id`) VALUES "
|
||||||
<< "(1, 0xd2d4735174e6d2577573a0ec2767fba6511b1e37cd1cd98674912797fd37e12373d6b4d771034cc114f80b2afb2956b6b3e020ddea2db1142c61f3fa87c72a6c, 0x73d6b4d771034cc114f80b2afb2956b6b3e020ddea2db1142c61f3fa87c72a6c, 3), "
|
<< "(1, 0x263f1da712c3b47286b463c2de3784f364f2534d2c34722a3b483c3f3e36476857564f564d476c32d3e342f5ef2763cd23e23a2b429bab62e352f46ba273e2f2, 0xfe5237c2d1ab1361b33163f15634e261c1d217ae32b327cbd88db8ebffedb271, 3), "
|
||||||
<< "(2, 0xf1c3285be6ef869a2a8deef6caee56a5a7c2660e2bce24f39e420dd8d42fe8894bd027b2799e46dc7111a4fdd0eac3848054331f844a358de15c5b0ed3eb1740fab13ecb5a271d480e040c9266bcd584, 0xd6f6d29fb277f86ac7c3098dc799028974223e8dce6b1dd57b03940bf35fae7f, 1); ";
|
<< "(2, 0x721f3e73e3263f1da712c3b47286b463c2de3784f364f2534d2c34722a3b483c3f3e36476857564f564d476c32d3e342f5ef2763cd23e23a2b429bab62e352f46ba273e2f2ef3264fe2452da62bc2739, 0xe3f253d1a2deb25362d2e374baf37bc1d3ef3781cfe1e127f3cd0abcdf372ea6, 1); ";
|
||||||
|
runMysql(ss.str());
|
||||||
|
ss.str(std::string());
|
||||||
|
|
||||||
|
ss << "INSERT INTO `hedera_accounts` (`id`, `user_id`, `account_hedera_id`, `account_key_id`, `balance`, `network_type`, `updated`) VALUES "
|
||||||
|
<< "(1, 1, 1, 1, 1000000000000, 1, '2019-09-03 11:13:52'), "
|
||||||
|
<< "(2, 1, 2, 2, 4312881211, 0, '2019-09-03 11:13:56'); ";
|
||||||
runMysql(ss.str());
|
runMysql(ss.str());
|
||||||
ss.str(std::string());
|
ss.str(std::string());
|
||||||
|
|
||||||
ss << "INSERT INTO `hedera_topics` (`id`, `topic_hedera_id`, `name`, `auto_renew_account_hedera_id`, `auto_renew_period`, `group_id`, `admin_key_id`, `submit_key_id`, `current_timeout`, `sequence_number`, `updated`) VALUES "
|
ss << "INSERT INTO `hedera_topics` (`id`, `topic_hedera_id`, `name`, `auto_renew_account_hedera_id`, `auto_renew_period`, `group_id`, `admin_key_id`, `submit_key_id`, `current_timeout`, `sequence_number`, `updated`) VALUES "
|
||||||
<< "(1, 18, 'from Pauls created with his python script', 1, 0, 1, NULL, NULL, '1999-12-31 23:00:00', 0, '2020-09-14 18:29:04'); ";
|
<< "(1, 3, 'gdd_test_topic', 1, 0, 1, NULL, NULL, '1999-12-31 23:00:00', 0, '2020-09-14 18:29:04'); ";
|
||||||
runMysql(ss.str());
|
runMysql(ss.str());
|
||||||
ss.str(std::string());
|
ss.str(std::string());
|
||||||
|
|
||||||
ss << "INSERT INTO `node_servers` (`id`, `url`, `port`, `group_id`, `server_type`, `node_hedera_id`, `last_live_sign`) VALUES "
|
|
||||||
<< "(1, 'http://0.testnet.hedera.com', 50211, 0, 4, 1, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(2, 'http://1.testnet.hedera.com', 50211, 0, 4, 2, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(3, 'http://2.testnet.hedera.com', 50211, 0, 4, 3, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(4, 'http://3.testnet.hedera.com', 50211, 0, 4, 4, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(5, 'http://35.237.200.180', 50211, 0, 3, 6, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(6, 'http://35.186.191.247', 50211, 0, 3, 2, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(7, 'http://35.192.2.25', 50211, 0, 3, 3, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(8, 'http://35.199.161.108', 50211, 0, 3, 4, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(9, 'http://35.203.82.240', 50211, 0, 3, 10, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(10, 'http://35.236.5.219', 50211, 0, 3, 11, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(11, 'http://35.197.192.225', 50211, 0, 3, 12, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(12, 'http://35.242.233.154', 50211, 0, 3, 13, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(13, 'http://35.240.118.96', 50211, 0, 3, 12, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(14, 'http://35.204.86.32', 50211, 0, 3, 14, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(15, 'https://gradido.dario-rekowski.de/', 443, 1, 2, 0, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(16, 'http://192.168.178.232', 8340, 1, 1, 0, '2000-01-01 00:00:00'); ";
|
|
||||||
runMysql(ss.str());
|
|
||||||
|
|
||||||
printf("init db in : %s\n", timeUsed.string().data());
|
|
||||||
|
|
||||||
/*mysqlStatement
|
|
||||||
<< "TRUNCATE hedera_accounts; "
|
|
||||||
<< "ALTER TABLE hedera_accounts AUTO_INCREMENT = 1; "
|
|
||||||
<< "TRUNCATE hedera_ids; "
|
|
||||||
<< "ALTER TABLE hedera_ids AUTO_INCREMENT = 1; "
|
|
||||||
<< "TRUNCATE crypto_keys; "
|
|
||||||
<< "ALTER TABLE crypto_keys AUTO_INCREMENT = 1; "
|
|
||||||
<< "TRUNCATE hedera_topics; "
|
|
||||||
<< "ALTER TABLE hedera_topics AUTO_INCREMENT = 1; "
|
|
||||||
<< "TRUNCATE groups; "
|
|
||||||
<< "ALTER TABLE groups AUTO_INCREMENT = 1; "
|
|
||||||
<< "TRUNCATE node_servers; "
|
|
||||||
<< "ALTER TABLE node_servers AUTO_INCREMENT = 1; "
|
|
||||||
<< "TRUNCATE users; "
|
|
||||||
<< "ALTER TABLE users AUTO_INCREMENT = 1; "
|
|
||||||
;
|
|
||||||
|
|
||||||
try {
|
|
||||||
mysqlStatement.execute(true);
|
|
||||||
}
|
|
||||||
catch (Poco::Exception& ex) {
|
|
||||||
printf("exception by cleaning up db: %s\n", ex.displayText().data());
|
|
||||||
}
|
|
||||||
mysqlStatement.reset(session);
|
|
||||||
mysqlStatement
|
|
||||||
<< "INSERT INTO `users` (`id`, `email`, `first_name`, `last_name`, `password`, `pubkey`, `privkey`, `created`, `email_checked`, `passphrase_shown`, `language`, `disabled`) VALUES "
|
|
||||||
<< "(1, 'einhorn_silas@ist-allein.info', 'DDD', 'Schultz', 13134558453895551556, 0x146d3fb9e88abc0fca0b0091c1ab1b32b399be037436f340befa8bf004461889, 0x0dcc08960f45f631fe23bc7ddee0724cedc9ec0c861ce30f5091d20ffd96062d08ca215726fb9bd64860c754772e945eea4cc872ed0a36c7b640e8b0bf7a873ec6765fa510711622341347ce2307b5ce, '2020-02-20 16:05:44', 1, 0, 'de', 0), "
|
|
||||||
<< "(2, 'Dario.Rekowski@buerotiger.de', 'Darios', 'Bruder', 12910944485867375321, 0x952e215a21d4376b4ac252c4bf41e156e1498e1b6b8ccf2a6826d96712f4f461, 0x4d40bf0860655f728312140dc3741e897bc2d13d00ea80a63e2961046a5a7bd8315397dfb488b89377087bc1a5f4f3af8ffdcf203329ae23ba04be7d38ad3852699d90ff1fc00e5b1ca92b64cc59c01f, '2020-02-20 16:05:44', 1, 0, 'de', 0), "
|
|
||||||
<< "(3, 'morgenstern175@es-ist-liebe.de', 'Dieter', 'Schultz', 13528673707291575501, 0xb539944bf6444a2bfc988244f0c0c9dc326452be9b8a2a43fcd90663719f4f6d, 0x5461fda60b719b65ba00bd6298e48410c4cbf0e89deb13cc784ba8978cf047454e8556ee3eddc8487ee835c33a83163bc8d8babbf2a5c431876bc0a0c114ff0a0d6b57baa12cf8f23c64fb642c862db5, '2020-02-20 16:05:45', 1, 0, 'de', 0), "
|
|
||||||
<< "(4, 'spaceteam@gmx.de', 'Bernd', 'Hückstädt', 15522411320147607375, 0x476b059744f08b0995522b484c90f8d2f47d9b59f4b3c96d9dc0ae6ab7b84979, 0x5277bf044cba4fec64e6f4d38da132755b029161231daefc9a7b4692ad37e05cdd88e0a2c2215baf854dd3a813578c214167af1113607e9f999ca848a7598ba5068e38f2a1afb097e4752a88024d79c8, '2020-02-20 16:05:46', 1, 0, 'de', 0), "
|
|
||||||
<< "(5, 'em741@gmx.de', 'Thomas', 'Markuk', 7022671043835614958, 0xb1584e169d60a7e771d3a348235dfd7b5f9e8235fcc26090761a0264b0daa6ff, 0xb46fb7110bf91e28f367aa80f84d1bbd639b6f689f4b0aa28c0f71529232df9bf9ee0fb02fa4c1b9f5a6799c82d119e5646f7231d011517379faaacf6513d973ac3043d4c786490ba62d56d75b86164d, '2020-02-20 16:05:46', 1, 0, 'de', 0), "
|
|
||||||
<< "(6, 'coin-info12@gradido.net', 'coin-info12', 'Test', 1548398919826089202, 0x4046ae49c1b620f2a321aba0c874fa2bc7ba844ab808bb0eeb18a908d468db14, 0x9522657ecd7456eedf86d065aa087ba7a94a8961a8e4950d044136155d38fe0840f2c0a2876ce055b3eaa6e9ab95c5feba89e535e0434fb2648d94d6e6ec68211aa2ea9e42d1ccd40b6b3c31e41f848e, '2020-02-20 16:05:47', 1, 0, 'de', 0), "
|
|
||||||
<< "(7, 'info@einhornimmond.de', 'Alex', 'Wesper', 5822761891727948301, 0xb13ede3402abb8f29722b14fec0a2006ae7a3a51fb677cd6a2bbd797ac6905a5, 0x6aa39d7670c64a31639c7d89b874ad929b2eaeb2e5992dbad71b6cea700bf9e3c6cf866d0f0fdc22b44a0ebf51a860799e880ef86266199931dd0a301e5552db44b9b7fa99ed5945652bc7b31eff767c, '2020-02-20 16:05:47', 1, 0, 'de', 0); "
|
|
||||||
|
|
||||||
<< "INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `description`) VALUES "
|
|
||||||
<< "(1, 'gdd1', 'Gradido1', 'gdd1.gradido.com', 'Der erste offizielle Gradido Server (zum Testen)'); "
|
|
||||||
|
|
||||||
<< "INSERT INTO `hedera_accounts` (`id`, `user_id`, `account_hedera_id`, `account_key_id`, `balance`, `network_type`, `updated`) VALUES "
|
|
||||||
<< "(1, 2, 15, 1, 1000000000000, 1, '2020-09-03 11:13:52'), "
|
|
||||||
<< "(2, 2, 17, 2, 22787166159, 0, '2020-09-03 11:13:56'); "
|
|
||||||
|
|
||||||
<< "INSERT INTO `hedera_ids` (`id`, `shardNum`, `realmNum`, `num`) VALUES "
|
|
||||||
<< "(1, 0, 0, 3), "
|
|
||||||
<< "(2, 0, 0, 4),"
|
|
||||||
<< "(3, 0, 0, 5),"
|
|
||||||
<< "(4, 0, 0, 6),"
|
|
||||||
<< "(6, 0, 0, 3),"
|
|
||||||
<< "(10, 0, 0, 7),"
|
|
||||||
<< "(11, 0, 0, 8),"
|
|
||||||
<< "(12, 0, 0, 9),"
|
|
||||||
<< "(13, 0, 0, 10),"
|
|
||||||
<< "(14, 0, 0, 12),"
|
|
||||||
<< "(15, 0, 0, 3327),"
|
|
||||||
<< "(16, 0, 0, 3323),"
|
|
||||||
<< "(17, 0, 0, 8707),"
|
|
||||||
<< "(18, 0, 0, 39446);"
|
|
||||||
|
|
||||||
<< "INSERT INTO `crypto_keys` (`id`, `private_key`, `public_key`, `crypto_key_type_id`) VALUES "
|
|
||||||
<< "(1, 0xd2d4735174e6d2577573a0ec2767fba6511b1e37cd1cd98674912797fd37e12373d6b4d771034cc114f80b2afb2956b6b3e020ddea2db1142c61f3fa87c72a6c, 0x73d6b4d771034cc114f80b2afb2956b6b3e020ddea2db1142c61f3fa87c72a6c, 3), "
|
|
||||||
<< "(2, 0xf1c3285be6ef869a2a8deef6caee56a5a7c2660e2bce24f39e420dd8d42fe8894bd027b2799e46dc7111a4fdd0eac3848054331f844a358de15c5b0ed3eb1740fab13ecb5a271d480e040c9266bcd584, 0xd6f6d29fb277f86ac7c3098dc799028974223e8dce6b1dd57b03940bf35fae7f, 1); "
|
|
||||||
|
|
||||||
<< "INSERT INTO `hedera_topics` (`id`, `topic_hedera_id`, `name`, `auto_renew_account_hedera_id`, `auto_renew_period`, `group_id`, `admin_key_id`, `submit_key_id`, `current_timeout`, `sequence_number`, `updated`) VALUES "
|
|
||||||
<< "(1, 18, 'from Pauls created with his python script', 1, 0, 1, NULL, NULL, '1999-12-31 23:00:00', 0, '2020-09-14 18:29:04'); "
|
|
||||||
|
|
||||||
<< "INSERT INTO `node_servers` (`id`, `url`, `port`, `group_id`, `server_type`, `node_hedera_id`, `last_live_sign`) VALUES "
|
|
||||||
<< "(1, 'http://0.testnet.hedera.com', 50211, 0, 4, 1, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(2, 'http://1.testnet.hedera.com', 50211, 0, 4, 2, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(3, 'http://2.testnet.hedera.com', 50211, 0, 4, 3, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(4, 'http://3.testnet.hedera.com', 50211, 0, 4, 4, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(5, 'http://35.237.200.180', 50211, 0, 3, 6, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(6, 'http://35.186.191.247', 50211, 0, 3, 2, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(7, 'http://35.192.2.25', 50211, 0, 3, 3, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(8, 'http://35.199.161.108', 50211, 0, 3, 4, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(9, 'http://35.203.82.240', 50211, 0, 3, 10, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(10, 'http://35.236.5.219', 50211, 0, 3, 11, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(11, 'http://35.197.192.225', 50211, 0, 3, 12, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(12, 'http://35.242.233.154', 50211, 0, 3, 13, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(13, 'http://35.240.118.96', 50211, 0, 3, 12, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(14, 'http://35.204.86.32', 50211, 0, 3, 14, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(15, 'https://gradido.dario-rekowski.de/', 443, 1, 2, 0, '2000-01-01 00:00:00'), "
|
|
||||||
<< "(16, 'http://192.168.178.232', 8340, 1, 1, 0, '2000-01-01 00:00:00'); "
|
|
||||||
;
|
|
||||||
|
|
||||||
try {
|
|
||||||
mysqlStatement.execute();
|
|
||||||
}
|
|
||||||
catch (Poco::Exception& ex) {
|
|
||||||
printf("exception by init db with data: %s\n", ex.displayText().data());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
fillTests();
|
fillTests();
|
||||||
for (std::list<Test*>::iterator it = gTests.begin(); it != gTests.end(); it++)
|
for (std::list<Test*>::iterator it = gTests.begin(); it != gTests.end(); it++)
|
||||||
{
|
{
|
||||||
@ -287,7 +158,10 @@ void ende()
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
load();
|
if (load() < 0) {
|
||||||
|
printf("early exit\n");
|
||||||
|
return -42;
|
||||||
|
}
|
||||||
run();
|
run();
|
||||||
ende();
|
ende();
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
#include "TestTasks.h"
|
#include "TestTasks.h"
|
||||||
#include "TestHash.h"
|
|
||||||
#include "TestRegExp.h"
|
#include "TestRegExp.h"
|
||||||
#include "crypto/TestPassphrase.h"
|
#include "crypto/TestPassphrase.h"
|
||||||
|
|||||||
@ -58,18 +58,21 @@ struct SListEntry
|
|||||||
auto passphrase_object = Passphrase::create(passphrase, wordSource);
|
auto passphrase_object = Passphrase::create(passphrase, wordSource);
|
||||||
auto key_pair_from_passhrase = KeyPairEd25519::create(passphrase_object);
|
auto key_pair_from_passhrase = KeyPairEd25519::create(passphrase_object);
|
||||||
bool matching = false;
|
bool matching = false;
|
||||||
if(key_pair_from_passhrase->isTheSame(key_pair)) {
|
if(key_pair_from_passhrase)
|
||||||
matching = true;
|
{
|
||||||
}
|
if(key_pair_from_passhrase->isTheSame(key_pair)) {
|
||||||
delete key_pair_from_passhrase;
|
matching = true;
|
||||||
if(user_id != last_user_id) {
|
}
|
||||||
last_user_id = user_id;
|
delete key_pair_from_passhrase;
|
||||||
if(matching) continue;
|
if(user_id != last_user_id) {
|
||||||
} else {
|
last_user_id = user_id;
|
||||||
auto lastEntry = notMatchingEntrys.back();
|
if(matching) continue;
|
||||||
if(lastEntry.user->getModel()->getID() == user_id && matching == true) {
|
} else {
|
||||||
notMatchingEntrys.pop_back();
|
auto lastEntry = notMatchingEntrys.back();
|
||||||
continue;
|
if(lastEntry.user->getModel()->getID() == user_id && matching == true) {
|
||||||
|
notMatchingEntrys.pop_back();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#########################################################################################################
|
#########################################################################################################
|
||||||
# mariadb server
|
# mariadb server
|
||||||
#########################################################################################################
|
#########################################################################################################
|
||||||
From mariadb/server:10.5 as mariadb_server
|
FROM mariadb/server:10.5 as mariadb_server
|
||||||
|
|
||||||
ENV DOCKER_WORKDIR="/docker-entrypoint-initdb.d"
|
ENV DOCKER_WORKDIR="/docker-entrypoint-initdb.d"
|
||||||
|
|
||||||
@ -21,3 +21,19 @@ RUN cd ./gradido_community/ && for f in *.sql; do cp -- "$f" "../d_$f"; sed -i
|
|||||||
COPY ./community_server/db/setup_db_tables ./gradido_community/insert
|
COPY ./community_server/db/setup_db_tables ./gradido_community/insert
|
||||||
RUN cd ./gradido_community/insert && for f in *.sql; do cp -- "$f" "../../e_$f"; sed -i '1i use gradido_community;' "../../e_$f"; done
|
RUN cd ./gradido_community/insert && for f in *.sql; do cp -- "$f" "../../e_$f"; sed -i '1i use gradido_community;' "../../e_$f"; done
|
||||||
|
|
||||||
|
#########################################################################################################
|
||||||
|
# mariadb server with test dbs
|
||||||
|
#########################################################################################################
|
||||||
|
FROM mariadb_server as mariadb_server_test
|
||||||
|
|
||||||
|
# create test databases
|
||||||
|
COPY ./mariadb/setup_test_dbs.sql a2_setup_dbs.sql
|
||||||
|
|
||||||
|
# login server test db
|
||||||
|
COPY ./login_server/skeema/ .
|
||||||
|
RUN cd ./gradido_login/ && for f in *.sql; do cp -- "$f" "../b_$f"; sed -i '1i use gradido_login_test;' "../b_$f"; done
|
||||||
|
RUN cd ./gradido_login/insert && for f in *.sql; do cp -- "$f" "../../c_$f"; sed -i '1i use gradido_login_test;' "../../c_$f"; done
|
||||||
|
# community server test db
|
||||||
|
COPY ./community_server/skeema/ .
|
||||||
|
RUN cd ./gradido_community/ && for f in *.sql; do cp -- "$f" "../d_$f"; sed -i '1i use gradido_community_test;' "../d_$f"; done
|
||||||
|
RUN cd ./gradido_community/insert && for f in *.sql; do cp -- "$f" "../../e_$f"; sed -i '1i use gradido_community_test;' "../../e_$f"; done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user