diff --git a/cmake/CivetWeb.cmake b/cmake/CivetWeb.cmake index 612b27c737..d2622de1cd 100644 --- a/cmake/CivetWeb.cmake +++ b/cmake/CivetWeb.cmake @@ -14,6 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(TARGET civetweb::civetweb-cpp) + return() +endif() include(FetchContent) diff --git a/extensions/standard-processors/tests/integration/InvokeHTTPTests.cpp b/extensions/standard-processors/tests/integration/InvokeHTTPTests.cpp index 2d884565ca..5ff6a576e8 100644 --- a/extensions/standard-processors/tests/integration/InvokeHTTPTests.cpp +++ b/extensions/standard-processors/tests/integration/InvokeHTTPTests.cpp @@ -84,6 +84,13 @@ class TestHTTPServer { return keys; } + [[nodiscard]] bool noInvalidHeaderPresent() const { + auto header_keys = getHeaderKeys(); + return std::none_of(header_keys.begin(), header_keys.end(), [] (const auto& key) { + return minifi::utils::string::startsWith(key, "invalid"); + }); + } + private: TestHandler handler_; std::unique_ptr server_; @@ -161,10 +168,7 @@ TEST_CASE("InvokeHTTP succeeds when the flow file contains an attribute that wou const auto& success_contents = result.at(InvokeHTTP::Success); REQUIRE(success_contents.size() == 1); REQUIRE(http_server.getHeaders().at("valid-header") == "value2"); - auto header_keys = http_server.getHeaderKeys(); - REQUIRE(std::find_if(header_keys.begin(), header_keys.end(), [] (const auto& key) { - return minifi::utils::string::startsWith(key, "invalid"); - }) == header_keys.end()); + REQUIRE(http_server.noInvalidHeaderPresent()); } TEST_CASE("InvokeHTTP replaces invalid characters of attributes", "[httptest1]") { @@ -207,10 +211,7 @@ TEST_CASE("InvokeHTTP drops invalid attributes from HTTP headers", "[httptest1]" REQUIRE(file_contents.size() == 1); REQUIRE(test_controller.plan->getContent(file_contents[0]) == "data"); REQUIRE(http_server.getHeaders().at("legit-header") == "value1"); - auto header_keys = http_server.getHeaderKeys(); - REQUIRE(std::find_if(header_keys.begin(), header_keys.end(), [] (const auto& key) { - return minifi::utils::string::startsWith(key, "invalid"); - }) == header_keys.end()); + REQUIRE(http_server.noInvalidHeaderPresent()); } TEST_CASE("InvokeHTTP empty Attributes to Send means no attributes are sent", "[httptest1]") { @@ -233,9 +234,7 @@ TEST_CASE("InvokeHTTP empty Attributes to Send means no attributes are sent", "[ REQUIRE(test_controller.plan->getContent(file_contents[0]) == "data"); auto header_keys = http_server.getHeaderKeys(); REQUIRE_FALSE(http_server.getHeaders().contains("legit-header")); - REQUIRE(std::find_if(header_keys.begin(), header_keys.end(), [] (const auto& key) { - return minifi::utils::string::startsWith(key, "invalid"); - }) == header_keys.end()); + REQUIRE(http_server.noInvalidHeaderPresent()); } TEST_CASE("InvokeHTTP DateHeader", "[InvokeHTTP]") { @@ -292,10 +291,7 @@ TEST_CASE("InvokeHTTP Attributes to Send uses full string matching, not substrin REQUIRE(test_controller.plan->getContent(file_contents[0]) == "data"); REQUIRE(http_server.getHeaders().at("header") == "value2"); REQUIRE_FALSE(http_server.getHeaders().contains("header1")); - auto header_keys = http_server.getHeaderKeys(); - REQUIRE(std::find_if(header_keys.begin(), header_keys.end(), [] (const auto& key) { - return minifi::utils::string::startsWith(key, "invalid"); - }) == header_keys.end()); + REQUIRE(http_server.noInvalidHeaderPresent()); } TEST_CASE("HTTPTestsResponseBodyinAttribute", "[InvokeHTTP]") { diff --git a/libminifi/test/libtest/CMakeLists.txt b/libminifi/test/libtest/CMakeLists.txt index a186b9c697..7d5bc957b1 100644 --- a/libminifi/test/libtest/CMakeLists.txt +++ b/libminifi/test/libtest/CMakeLists.txt @@ -16,11 +16,9 @@ # specific language governing permissions and limitations # under the License. # -if (NOT ENABLE_ALL AND NOT ENABLE_PROMETHEUS AND NOT ENABLE_GRAFANA_LOKI AND NOT ENABLE_CIVET) - message("CivetWeb was disabled for MiNiFi, but will be enabled for tests") - include(GetCivetWeb) - get_civetweb() -endif() + +include(GetCivetWeb) +get_civetweb() add_subdirectory(unit) add_subdirectory(integration)