diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 6c4c8e26..80ac8a56 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -14,7 +14,7 @@ jobs: fetch-depth: 2 - name: Configure cmake - run: cmake -B${{github.workspace}}/build -DCOVERAGE_TEST=ON -DCINATRA_ENABLE_SSL=ON -DCMAKE_BUILD_TYPE=Debug + run: cmake -B${{github.workspace}}/build -DCOVERAGE_TEST=ON -DENABLE_SSL=ON -DCINATRA_ENABLE_SSL=ON -DCMAKE_BUILD_TYPE=Debug - name: Build with ${{ matrix.compiler }} run: cmake --build ${{github.workspace}}/build --config Debug diff --git a/cmake/develop.cmake b/cmake/develop.cmake index 51d3174b..1863de94 100644 --- a/cmake/develop.cmake +++ b/cmake/develop.cmake @@ -71,10 +71,6 @@ if (ENABLE_SSL) message(STATUS "Use SSL") endif() -if(ENABLE_GZIP) - add_definitions(-DCINATRA_ENABLE_GZIP) -endif() - if(ENABLE_CLIENT_SSL) add_definitions(-DCINATRA_ENABLE_CLIENT_SSL) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bb321a80..b7a4bb98 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,6 +19,11 @@ if(ENABLE_METRIC_JSON) ) endif() +find_package(ZLIB) +if (ZLIB_FOUND) + add_definitions(-DCINATRA_ENABLE_GZIP) +endif () + option(SKIP_TIME_TEST "skip time tests" OFF) if(SKIP_TIME_TEST) message(STATUS "skip time tests") @@ -27,7 +32,7 @@ endif() add_test(NAME ${project_name} COMMAND test_cinatra) -if (ENABLE_GZIP) +if (ZLIB_FOUND) target_link_libraries(${project_name} ${ZLIB_LIBRARIES}) endif() diff --git a/tests/test_cinatra.cpp b/tests/test_cinatra.cpp index c5aa414d..e184acb5 100644 --- a/tests/test_cinatra.cpp +++ b/tests/test_cinatra.cpp @@ -1484,8 +1484,8 @@ TEST_CASE("test coro_http_client multipart upload") { #ifdef CINATRA_ENABLE_SSL TEST_CASE("test ssl upload") { coro_http_server server(1, 8091); - server.init_ssl("../openssl_files/server.crt", "../openssl_files/server.key", - "test"); + server.init_ssl("../../include/cinatra/server.crt", + "../../include/cinatra/server.key", "test"); server.set_http_handler( "/upload", [](coro_http_request &req, @@ -1556,8 +1556,8 @@ TEST_CASE("test ssl upload") { } cinatra::coro_http_server server1(1, 9002); - server1.init_ssl("../openssl_files/server.crt", "../openssl_files/server.key", - "test"); + server1.init_ssl("../../include/cinatra/server.crt", + "../../include/cinatra/server.key", "test"); server1.set_http_handler( "/chunked", [](coro_http_request &req, diff --git a/tests/test_coro_http_server.cpp b/tests/test_coro_http_server.cpp index d9852153..b6d4f1f9 100644 --- a/tests/test_coro_http_server.cpp +++ b/tests/test_coro_http_server.cpp @@ -1181,8 +1181,8 @@ TEST_CASE("test websocket with different message size") { TEST_CASE("test ssl server") { cinatra::coro_http_server server(1, 9001); std::cout << std::filesystem::current_path() << "\n"; - server.init_ssl("../openssl_files/server.crt", "../openssl_files/server.key", - "test"); + server.init_ssl("../../include/cinatra/server.crt", + "../../include/cinatra/server.key", "test"); server.set_http_handler( "/ssl", [](coro_http_request &req, coro_http_response &resp) { resp.set_status_and_content(status_type::ok, "ssl"); @@ -1541,6 +1541,11 @@ TEST_CASE("test reverse proxy") { } TEST_CASE("test reverse proxy websocket") { + { + coro_http_server proxy_server(1, 9005); + CHECK_THROWS_AS(proxy_server.set_websocket_proxy_handler("/ws_echo", {}), + std::invalid_argument); + } coro_http_server server(1, 9001); server.set_http_handler( "/ws_echo",