Skip to content

Commit

Permalink
Review update
Browse files Browse the repository at this point in the history
  • Loading branch information
lordgamez committed Feb 12, 2025
1 parent 06590a8 commit 6c1f137
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
3 changes: 3 additions & 0 deletions cmake/CivetWeb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestServer> server_;
Expand Down Expand Up @@ -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]") {
Expand Down Expand Up @@ -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]") {
Expand All @@ -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]") {
Expand Down Expand Up @@ -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]") {
Expand Down
8 changes: 3 additions & 5 deletions libminifi/test/libtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6c1f137

Please sign in to comment.