From 14320a56f2d1f372afa61f6bf79f47cd8132a76f Mon Sep 17 00:00:00 2001 From: Adi Suissa-Peleg Date: Fri, 20 Dec 2024 21:22:10 +0000 Subject: [PATCH] tests Signed-off-by: Adi Suissa-Peleg --- .../matching/input_matchers/source/matcher.h | 2 ++ test/extensions/common/aws/utility_test.cc | 8 ++--- .../http/cache/cache_headers_utils_test.cc | 20 +++-------- .../filters/http/cors/cors_filter_test.cc | 6 ++-- .../http/ext_proc/mutation_utils_test.cc | 33 +++++-------------- 5 files changed, 20 insertions(+), 49 deletions(-) diff --git a/contrib/hyperscan/matching/input_matchers/source/matcher.h b/contrib/hyperscan/matching/input_matchers/source/matcher.h index d49743ae0c5d..7aac429c122a 100644 --- a/contrib/hyperscan/matching/input_matchers/source/matcher.h +++ b/contrib/hyperscan/matching/input_matchers/source/matcher.h @@ -44,6 +44,8 @@ class Matcher : public Envoy::Regex::CompiledMatcher, public Envoy::Matcher::Inp // Envoy::Matcher::InputMatcher bool match(const ::Envoy::Matcher::MatchingDataType& input) override; + const std::string& stringRepresentation() const override { return EMPTY_STRING; } + private: hs_database_t* database_{}; hs_database_t* start_of_match_database_{}; diff --git a/test/extensions/common/aws/utility_test.cc b/test/extensions/common/aws/utility_test.cc index 6cabe0ebd79e..3358454a64fb 100644 --- a/test/extensions/common/aws/utility_test.cc +++ b/test/extensions/common/aws/utility_test.cc @@ -165,17 +165,13 @@ TEST(UtilityTest, CanonicalizeHeadersDropExcludedMatchers) { for (auto& str : exact_matches) { envoy::type::matcher::v3::StringMatcher config; config.set_exact(str); - exclusion_list.emplace_back( - std::make_unique>( - config, context)); + exclusion_list.emplace_back(std::make_unique(config, context)); } std::vector prefixes = {"x-envoy"}; for (auto& match_str : prefixes) { envoy::type::matcher::v3::StringMatcher config; config.set_prefix(match_str); - exclusion_list.emplace_back( - std::make_unique>( - config, context)); + exclusion_list.emplace_back(std::make_unique(config, context)); } const auto map = Utility::canonicalizeHeaders(headers, exclusion_list); EXPECT_THAT(map, diff --git a/test/extensions/filters/http/cache/cache_headers_utils_test.cc b/test/extensions/filters/http/cache/cache_headers_utils_test.cc index f794ad5f16b9..c6dfe1e8bd7d 100644 --- a/test/extensions/filters/http/cache/cache_headers_utils_test.cc +++ b/test/extensions/filters/http/cache/cache_headers_utils_test.cc @@ -496,9 +496,7 @@ TEST(GetAllMatchingHeaderNames, EmptyHeaderMap) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); - ruleset.emplace_back( - std::make_unique>( - matcher, context)); + ruleset.emplace_back(std::make_unique(matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); @@ -513,9 +511,7 @@ TEST(GetAllMatchingHeaderNames, SingleMatchSingleValue) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); - ruleset.emplace_back( - std::make_unique>( - matcher, context)); + ruleset.emplace_back(std::make_unique(matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); @@ -531,9 +527,7 @@ TEST(GetAllMatchingHeaderNames, SingleMatchMultiValue) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); - ruleset.emplace_back( - std::make_unique>( - matcher, context)); + ruleset.emplace_back(std::make_unique(matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); @@ -549,13 +543,9 @@ TEST(GetAllMatchingHeaderNames, MultipleMatches) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); - ruleset.emplace_back( - std::make_unique>( - matcher, context)); + ruleset.emplace_back(std::make_unique(matcher, context)); matcher.set_exact("accept-language"); - ruleset.emplace_back( - std::make_unique>( - matcher, context)); + ruleset.emplace_back(std::make_unique(matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); diff --git a/test/extensions/filters/http/cors/cors_filter_test.cc b/test/extensions/filters/http/cors/cors_filter_test.cc index 5d960f6f6fd6..66a00e86f2c8 100644 --- a/test/extensions/filters/http/cors/cors_filter_test.cc +++ b/test/extensions/filters/http/cors/cors_filter_test.cc @@ -27,16 +27,14 @@ Matchers::StringMatcherPtr makeExactStringMatcher(const std::string& exact_match NiceMock context; envoy::type::matcher::v3::StringMatcher config; config.set_exact(exact_match); - return std::make_unique>( - config, context); + return std::make_unique(config, context); } Matchers::StringMatcherPtr makeStdRegexStringMatcher(const std::string& regex) { NiceMock context; envoy::type::matcher::v3::StringMatcher config; config.MergeFrom(TestUtility::createRegexMatcher(regex)); - return std::make_unique>( - config, context); + return std::make_unique(config, context); } } // namespace diff --git a/test/extensions/filters/http/ext_proc/mutation_utils_test.cc b/test/extensions/filters/http/ext_proc/mutation_utils_test.cc index ea0efe3b6cf2..210836d0288b 100644 --- a/test/extensions/filters/http/ext_proc/mutation_utils_test.cc +++ b/test/extensions/filters/http/ext_proc/mutation_utils_test.cc @@ -337,13 +337,9 @@ TEST_F(MutationUtilsTest, TestAllowHeadersExactCaseSensitive) { std::vector disallow_headers; envoy::type::matcher::v3::StringMatcher string_matcher; string_matcher.set_exact(":method"); - allow_headers.push_back( - std::make_unique>( - string_matcher, context)); + allow_headers.push_back(std::make_unique(string_matcher, context)); string_matcher.set_exact(":Path"); - allow_headers.push_back( - std::make_unique>( - string_matcher, context)); + allow_headers.push_back(std::make_unique(string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers); Http::TestRequestHeaderMapImpl expected{{":method", "GET"}}; @@ -364,14 +360,10 @@ TEST_F(MutationUtilsTest, TestAllowHeadersExactIgnoreCase) { std::vector disallow_headers; envoy::type::matcher::v3::StringMatcher string_matcher; string_matcher.set_exact(":method"); - allow_headers.push_back( - std::make_unique>( - string_matcher, context)); + allow_headers.push_back(std::make_unique(string_matcher, context)); string_matcher.set_exact(":Path"); string_matcher.set_ignore_case(true); - allow_headers.push_back( - std::make_unique>( - string_matcher, context)); + allow_headers.push_back(std::make_unique(string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers); Http::TestRequestHeaderMapImpl expected{{":method", "GET"}, {":path", "/foo/the/bar?size=123"}}; EXPECT_THAT(proto_headers, HeaderProtosEqual(expected)); @@ -394,19 +386,14 @@ TEST_F(MutationUtilsTest, TestBothAllowAndDisallowHeadersSet) { // Set allow_headers. string_matcher.set_exact(":method"); - allow_headers.push_back( - std::make_unique>( - string_matcher, context)); + allow_headers.push_back(std::make_unique(string_matcher, context)); string_matcher.set_exact(":path"); - allow_headers.push_back( - std::make_unique>( - string_matcher, context)); + allow_headers.push_back(std::make_unique(string_matcher, context)); // Set disallow_headers string_matcher.set_exact(":method"); disallow_headers.push_back( - std::make_unique>( - string_matcher, context)); + std::make_unique(string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers); Http::TestRequestHeaderMapImpl expected{{":path", "/foo/the/bar?size=123"}}; @@ -431,12 +418,10 @@ TEST_F(MutationUtilsTest, TestDisallowHeaderSetNotAllowHeader) { // Set disallow_headers. string_matcher.set_exact(":method"); disallow_headers.push_back( - std::make_unique>( - string_matcher, context)); + std::make_unique(string_matcher, context)); string_matcher.set_exact(":path"); disallow_headers.push_back( - std::make_unique>( - string_matcher, context)); + std::make_unique(string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers); Http::TestRequestHeaderMapImpl expected{{"content-type", "text/plain; encoding=UTF8"},