diff --git a/contrib/generic_proxy/filters/network/source/match.cc b/contrib/generic_proxy/filters/network/source/match.cc index d3c8898ab628..8a3caebbdf3c 100644 --- a/contrib/generic_proxy/filters/network/source/match.cc +++ b/contrib/generic_proxy/filters/network/source/match.cc @@ -17,7 +17,7 @@ REGISTER_FACTORY(PropertyMatchDataInputFactory, Matcher::DataInputFactory); -using StringMatcherImpl = Matchers::StringMatcherImplWithContext; +using StringMatcherImpl = Matchers::StringMatcherImpl; RequestMatchInputMatcher::RequestMatchInputMatcher( const RequestMatcherProto& proto_config, Server::Configuration::CommonFactoryContext& context) { diff --git a/contrib/rocketmq_proxy/filters/network/source/router/route_matcher.h b/contrib/rocketmq_proxy/filters/network/source/router/route_matcher.h index bb26e6da57c3..67c02c991463 100644 --- a/contrib/rocketmq_proxy/filters/network/source/router/route_matcher.h +++ b/contrib/rocketmq_proxy/filters/network/source/router/route_matcher.h @@ -44,7 +44,7 @@ class RouteEntryImpl : public RouteEntry, private: bool headersMatch(const Http::HeaderMap& headers) const; - const Matchers::StringMatcherImplWithContext topic_name_; + const Matchers::StringMatcherImpl topic_name_; const std::string cluster_name_; const std::vector config_headers_; Envoy::Router::MetadataMatchCriteriaConstPtr metadata_match_criteria_; diff --git a/source/common/common/matchers.cc b/source/common/common/matchers.cc index eef8c3ce122d..6aa128f478b7 100644 --- a/source/common/common/matchers.cc +++ b/source/common/common/matchers.cc @@ -26,8 +26,7 @@ ValueMatcher::create(const envoy::type::matcher::v3::ValueMatcher& v, case envoy::type::matcher::v3::ValueMatcher::MatchPatternCase::kDoubleMatch: return std::make_shared(v.double_match()); case envoy::type::matcher::v3::ValueMatcher::MatchPatternCase::kStringMatch: - return std::make_shared< - const StringMatcherImplWithContext>>( + return std::make_shared>>( v.string_match(), context); case envoy::type::matcher::v3::ValueMatcher::MatchPatternCase::kBoolMatch: return std::make_shared(v.bool_match()); @@ -128,8 +127,7 @@ StringMatcherPtr valueMatcherFromProto(const envoy::type::matcher::v3::FilterSta Server::Configuration::CommonFactoryContext& context) { switch (matcher.matcher_case()) { case envoy::type::matcher::v3::FilterStateMatcher::MatcherCase::kStringMatch: - return std::make_unique< - const StringMatcherImplWithContext>( + return std::make_unique>( matcher.string_match(), context); break; default: diff --git a/source/common/common/matchers.h b/source/common/common/matchers.h index c8c64f63d69b..33cbbaaeca0e 100644 --- a/source/common/common/matchers.h +++ b/source/common/common/matchers.h @@ -91,10 +91,10 @@ StringMatcherPtr getExtensionStringMatcher(const ::xds::core::v3::TypedExtension Server::Configuration::CommonFactoryContext& context); template -class StringMatcherImplWithContext : public ValueMatcher, public StringMatcher { +class StringMatcherImpl : public ValueMatcher, public StringMatcher { public: - explicit StringMatcherImplWithContext(const StringMatcherType& matcher, - Server::Configuration::CommonFactoryContext& context) + explicit StringMatcherImpl(const StringMatcherType& matcher, + Server::Configuration::CommonFactoryContext& context) : matcher_(matcher) { if (matcher.match_pattern_case() == StringMatcherType::MatchPatternCase::kSafeRegex) { if (matcher.ignore_case()) { @@ -263,12 +263,12 @@ class PathMatcher : public StringMatcher { Server::Configuration::CommonFactoryContext& context); bool match(const absl::string_view path) const override; - const StringMatcherImplWithContext& matcher() const { + const StringMatcherImpl& matcher() const { return matcher_; } private: - const StringMatcherImplWithContext matcher_; + const StringMatcherImpl matcher_; }; } // namespace Matchers diff --git a/source/common/http/header_utility.cc b/source/common/http/header_utility.cc index 82cfc208e486..886511043d55 100644 --- a/source/common/http/header_utility.cc +++ b/source/common/http/header_utility.cc @@ -81,9 +81,9 @@ HeaderUtility::HeaderData::HeaderData(const envoy::config::route::v3::HeaderMatc break; case envoy::config::route::v3::HeaderMatcher::HeaderMatchSpecifierCase::kStringMatch: header_match_type_ = HeaderMatchType::StringMatch; - string_match_ = std::make_unique< - Matchers::StringMatcherImplWithContext>( - config.string_match(), factory_context); + string_match_ = + std::make_unique>( + config.string_match(), factory_context); break; case envoy::config::route::v3::HeaderMatcher::HeaderMatchSpecifierCase:: HEADER_MATCH_SPECIFIER_NOT_SET: diff --git a/source/common/matcher/value_input_matcher.h b/source/common/matcher/value_input_matcher.h index 253483f504e2..f527b2c87364 100644 --- a/source/common/matcher/value_input_matcher.h +++ b/source/common/matcher/value_input_matcher.h @@ -23,7 +23,7 @@ class StringInputMatcher : public InputMatcher, Logger::Loggable matcher_; + const Matchers::StringMatcherImpl matcher_; }; } // namespace Matcher diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index ff551e9b2d60..addaf485458a 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -168,8 +168,7 @@ template class CorsPolicyImplBase : public CorsPolicy { max_age_(config.max_age()) { for (const auto& string_match : config.allow_origin_string_match()) { allow_origins_.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_match, factory_context)); } if (config.has_allow_credentials()) { diff --git a/source/common/router/config_utility.cc b/source/common/router/config_utility.cc index 9e18150c4a93..3281c3ed688b 100644 --- a/source/common/router/config_utility.cc +++ b/source/common/router/config_utility.cc @@ -15,13 +15,13 @@ namespace Envoy { namespace Router { namespace { -absl::optional> +absl::optional> maybeCreateStringMatcher(const envoy::config::route::v3::QueryParameterMatcher& config, Server::Configuration::CommonFactoryContext& context) { switch (config.query_parameter_match_specifier_case()) { case envoy::config::route::v3::QueryParameterMatcher::QueryParameterMatchSpecifierCase:: kStringMatch: - return Matchers::StringMatcherImplWithContext(config.string_match(), context); + return Matchers::StringMatcherImpl(config.string_match(), context); case envoy::config::route::v3::QueryParameterMatcher::QueryParameterMatchSpecifierCase:: kPresentMatch: return absl::nullopt; diff --git a/source/common/router/config_utility.h b/source/common/router/config_utility.h index 5efc6429c9a1..f83f0d417f18 100644 --- a/source/common/router/config_utility.h +++ b/source/common/router/config_utility.h @@ -44,8 +44,7 @@ class ConfigUtility { private: const std::string name_; - const absl::optional< - Matchers::StringMatcherImplWithContext> + const absl::optional> matcher_; }; diff --git a/source/common/stats/histogram_impl.cc b/source/common/stats/histogram_impl.cc index a16c2b2551c9..50d1418198f5 100644 --- a/source/common/stats/histogram_impl.cc +++ b/source/common/stats/histogram_impl.cc @@ -106,10 +106,9 @@ HistogramSettingsImpl::HistogramSettingsImpl(const envoy::config::metrics::v3::S for (const auto& matcher : config.histogram_bucket_settings()) { std::vector buckets{matcher.buckets().begin(), matcher.buckets().end()}; std::sort(buckets.begin(), buckets.end()); - configs.emplace_back( - Matchers::StringMatcherImplWithContext( - matcher.match(), context), - std::move(buckets)); + configs.emplace_back(Matchers::StringMatcherImpl( + matcher.match(), context), + std::move(buckets)); } return configs; diff --git a/source/common/stats/histogram_impl.h b/source/common/stats/histogram_impl.h index 02db150450ea..1f0741219326 100644 --- a/source/common/stats/histogram_impl.h +++ b/source/common/stats/histogram_impl.h @@ -29,9 +29,8 @@ class HistogramSettingsImpl : public HistogramSettings { static ConstSupportedBuckets& defaultBuckets(); private: - using Config = - std::pair, - ConstSupportedBuckets>; + using Config = std::pair, + ConstSupportedBuckets>; const std::vector configs_{}; }; diff --git a/source/common/stats/stats_matcher_impl.cc b/source/common/stats/stats_matcher_impl.cc index f14a6ef4834d..c68e09f7e364 100644 --- a/source/common/stats/stats_matcher_impl.cc +++ b/source/common/stats/stats_matcher_impl.cc @@ -27,7 +27,7 @@ StatsMatcherImpl::StatsMatcherImpl(const envoy::config::metrics::v3::StatsConfig case envoy::config::metrics::v3::StatsMatcher::StatsMatcherCase::kInclusionList: // If we have an inclusion list, we are being default-exclusive. for (const auto& stats_matcher : config.stats_matcher().inclusion_list().patterns()) { - matchers_.push_back(Matchers::StringMatcherImplWithContext(stats_matcher, context)); + matchers_.push_back(Matchers::StringMatcherImpl(stats_matcher, context)); optimizeLastMatcher(); } is_inclusive_ = false; @@ -35,7 +35,7 @@ StatsMatcherImpl::StatsMatcherImpl(const envoy::config::metrics::v3::StatsConfig case envoy::config::metrics::v3::StatsMatcher::StatsMatcherCase::kExclusionList: // If we have an exclusion list, we are being default-inclusive. for (const auto& stats_matcher : config.stats_matcher().exclusion_list().patterns()) { - matchers_.push_back(Matchers::StringMatcherImplWithContext(stats_matcher, context)); + matchers_.push_back(Matchers::StringMatcherImpl(stats_matcher, context)); optimizeLastMatcher(); } FALLTHRU; diff --git a/source/common/stats/stats_matcher_impl.h b/source/common/stats/stats_matcher_impl.h index df28ffe8f9b1..3738bf63e8d2 100644 --- a/source/common/stats/stats_matcher_impl.h +++ b/source/common/stats/stats_matcher_impl.h @@ -52,8 +52,7 @@ class StatsMatcherImpl : public StatsMatcher { OptRef symbol_table_; std::unique_ptr stat_name_pool_; - std::vector> - matchers_; + std::vector> matchers_; std::vector prefixes_; }; diff --git a/source/common/tls/cert_validator/san_matcher.h b/source/common/tls/cert_validator/san_matcher.h index b9409555209e..2a8af500a10b 100644 --- a/source/common/tls/cert_validator/san_matcher.h +++ b/source/common/tls/cert_validator/san_matcher.h @@ -40,7 +40,7 @@ class StringSanMatcher : public SanMatcher { private: const int general_name_type_; - const Matchers::StringMatcherImplWithContext matcher_; + const Matchers::StringMatcherImpl matcher_; }; SanMatcherPtr createStringSanMatcher( diff --git a/source/extensions/common/aws/signer_base_impl.h b/source/extensions/common/aws/signer_base_impl.h index a8bb754facf2..fe58850e60da 100644 --- a/source/extensions/common/aws/signer_base_impl.h +++ b/source/extensions/common/aws/signer_base_impl.h @@ -76,8 +76,7 @@ class SignerBaseImpl : public Signer, public Logger::Loggable { short_date_formatter_(std::string(SignatureConstants::ShortDateFormat)) { for (const auto& matcher : matcher_config) { excluded_header_matchers_.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); } } @@ -139,8 +138,7 @@ class SignerBaseImpl : public Signer, public Logger::Loggable { envoy::type::matcher::v3::StringMatcher m; m.set_exact(header); matcher_ptrs.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( m, context)); } return matcher_ptrs; diff --git a/source/extensions/filters/common/ext_authz/check_request_utils.cc b/source/extensions/filters/common/ext_authz/check_request_utils.cc index 0e24523eccb8..c7984d28cb80 100644 --- a/source/extensions/filters/common/ext_authz/check_request_utils.cc +++ b/source/extensions/filters/common/ext_authz/check_request_utils.cc @@ -260,8 +260,7 @@ CheckRequestUtils::toRequestMatchers(const envoy::type::matcher::v3::ListStringM envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact(key.get()); matchers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); } } @@ -275,8 +274,7 @@ CheckRequestUtils::createStringMatchers(const envoy::type::matcher::v3::ListStri std::vector matchers; for (const auto& matcher : list.patterns()) { matchers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); } return matchers; diff --git a/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc b/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc index 101a991dc100..9f6f5ba33c84 100644 --- a/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc +++ b/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc @@ -152,8 +152,7 @@ ClientConfig::toClientMatchers(const envoy::type::matcher::v3::ListStringMatcher envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact(Http::Headers::get().Host.get()); matchers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); return std::make_shared(std::move(matchers)); @@ -169,8 +168,7 @@ ClientConfig::toClientMatchers(const envoy::type::matcher::v3::ListStringMatcher envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact(key.get()); matchers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); } diff --git a/source/extensions/filters/common/rbac/matchers.h b/source/extensions/filters/common/rbac/matchers.h index e690a4790580..362d2c51c979 100644 --- a/source/extensions/filters/common/rbac/matchers.h +++ b/source/extensions/filters/common/rbac/matchers.h @@ -204,16 +204,16 @@ class AuthenticatedMatcher : public Matcher { AuthenticatedMatcher(const envoy::config::rbac::v3::Principal::Authenticated& auth, Server::Configuration::CommonFactoryContext& context) : matcher_(auth.has_principal_name() - ? absl::make_optional>(auth.principal_name(), context) + ? absl::make_optional< + Matchers::StringMatcherImpl>( + auth.principal_name(), context) : absl::nullopt) {} bool matches(const Network::Connection& connection, const Envoy::Http::RequestHeaderMap& headers, const StreamInfo::StreamInfo&) const override; private: - const absl::optional< - Matchers::StringMatcherImplWithContext> + const absl::optional> matcher_; }; @@ -274,11 +274,11 @@ class FilterStateMatcher : public Matcher { */ class RequestedServerNameMatcher : public Matcher, - Envoy::Matchers::StringMatcherImplWithContext { + Envoy::Matchers::StringMatcherImpl { public: RequestedServerNameMatcher(const envoy::type::matcher::v3::StringMatcher& requested_server_name, Server::Configuration::CommonFactoryContext& context) - : Envoy::Matchers::StringMatcherImplWithContext( + : Envoy::Matchers::StringMatcherImpl( requested_server_name, context) {} bool matches(const Network::Connection& connection, const Envoy::Http::RequestHeaderMap& headers, diff --git a/source/extensions/filters/http/cache/cache_headers_utils.cc b/source/extensions/filters/http/cache/cache_headers_utils.cc index 5c622462c4e7..c6d05aec6d58 100644 --- a/source/extensions/filters/http/cache/cache_headers_utils.cc +++ b/source/extensions/filters/http/cache/cache_headers_utils.cc @@ -289,8 +289,7 @@ VaryAllowList::VaryAllowList( for (const auto& rule : allow_list) { allow_list_.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( rule, context)); } } diff --git a/source/extensions/filters/http/csrf/csrf_filter.h b/source/extensions/filters/http/csrf/csrf_filter.h index fe7bc78a1a29..85eb1c78fed1 100644 --- a/source/extensions/filters/http/csrf/csrf_filter.h +++ b/source/extensions/filters/http/csrf/csrf_filter.h @@ -39,8 +39,7 @@ class CsrfPolicy : public Router::RouteSpecificFilterConfig { : policy_(policy), runtime_(context.runtime()) { for (const auto& additional_origin : policy.additional_origins()) { additional_origins_.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( additional_origin, context)); } } diff --git a/source/extensions/filters/http/ext_proc/matching_utils.cc b/source/extensions/filters/http/ext_proc/matching_utils.cc index e17c600da533..327ccdf2dd3d 100644 --- a/source/extensions/filters/http/ext_proc/matching_utils.cc +++ b/source/extensions/filters/http/ext_proc/matching_utils.cc @@ -91,8 +91,7 @@ initHeaderMatchers(const envoy::type::matcher::v3::ListStringMatcher& header_lis std::vector header_matchers; for (const auto& matcher : header_list.patterns()) { header_matchers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); } return header_matchers; diff --git a/source/extensions/filters/http/jwt_authn/jwks_cache.cc b/source/extensions/filters/http/jwt_authn/jwks_cache.cc index b5109b639ef6..146fc70a08b2 100644 --- a/source/extensions/filters/http/jwt_authn/jwks_cache.cc +++ b/source/extensions/filters/http/jwt_authn/jwks_cache.cc @@ -189,8 +189,7 @@ class JwksDataImpl : public JwksCache::JwksData, public Logger::Loggable tls_; // async fetcher JwksAsyncFetcherPtr async_fetcher_; - absl::optional> - sub_matcher_; + absl::optional> sub_matcher_; absl::optional max_exp_; }; diff --git a/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h b/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h index e8b30c7397bc..9ac09e453dd2 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h @@ -129,8 +129,7 @@ class MethodRouteEntryImpl : public RouteEntryImplBase { uint64_t random_value) const override; private: - const Matchers::StringMatcherImplWithContext - method_name_; + const Matchers::StringMatcherImpl method_name_; std::shared_ptr parameter_route_; }; diff --git a/source/extensions/health_checkers/http/health_checker_impl.h b/source/extensions/health_checkers/http/health_checker_impl.h index 85659473638e..d4a03688c13d 100644 --- a/source/extensions/health_checkers/http/health_checker_impl.h +++ b/source/extensions/health_checkers/http/health_checker_impl.h @@ -176,7 +176,7 @@ class HttpHealthCheckerImpl : public HealthCheckerImplBase { PayloadMatcher::MatchSegments receive_bytes_; const envoy::config::core::v3::RequestMethod method_; uint64_t response_buffer_size_; - absl::optional> + absl::optional> service_name_matcher_; Router::HeaderParserPtr request_headers_parser_; const HttpStatusChecker http_status_checker_; diff --git a/test/common/common/matchers_test.cc b/test/common/common/matchers_test.cc index 7b5d4c41203c..b61689b6b1b2 100644 --- a/test/common/common/matchers_test.cc +++ b/test/common/common/matchers_test.cc @@ -333,77 +333,71 @@ class StringMatcher : public BaseTest {}; TEST_F(StringMatcher, ExactMatchIgnoreCase) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("exact"); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("exact")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("EXACT")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("exacz")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("exact")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("EXACT")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("exacz")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); matcher.set_ignore_case(true); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("exact")); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("EXACT")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("exacz")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("exact")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("EXACT")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("exacz")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); } TEST_F(StringMatcher, PrefixMatchIgnoreCase) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_prefix("prefix"); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("prefix-abc")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("PREFIX-ABC")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("prefiz-abc")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("prefix-abc")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("PREFIX-ABC")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("prefiz-abc")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); matcher.set_ignore_case(true); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("prefix-abc")); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("PREFIX-ABC")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("prefiz-abc")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("prefix-abc")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("PREFIX-ABC")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("prefiz-abc")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); } TEST_F(StringMatcher, SuffixMatchIgnoreCase) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_suffix("suffix"); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-suffix")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("ABC-SUFFIX")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-suffiz")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("abc-suffix")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("ABC-SUFFIX")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("abc-suffiz")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); matcher.set_ignore_case(true); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-suffix")); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("ABC-SUFFIX")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-suffiz")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("abc-suffix")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("ABC-SUFFIX")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("abc-suffiz")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); } TEST_F(StringMatcher, ContainsMatchIgnoreCase) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_contains("contained-str"); - EXPECT_TRUE( - Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-contained-str-def")); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("contained-str")); - EXPECT_FALSE( - Matchers::StringMatcherImplWithContext(matcher, context_).match("ABC-Contained-Str-DEF")); - EXPECT_FALSE( - Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-container-int-def")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("abc-contained-str-def")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("contained-str")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("ABC-Contained-Str-DEF")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("abc-container-int-def")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); matcher.set_ignore_case(true); - EXPECT_TRUE( - Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-contained-str-def")); - EXPECT_TRUE( - Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-cOnTaInEd-str-def")); - EXPECT_FALSE( - Matchers::StringMatcherImplWithContext(matcher, context_).match("abc-ContAineR-str-def")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("other")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("abc-contained-str-def")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("abc-cOnTaInEd-str-def")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("abc-ContAineR-str-def")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("other")); } TEST_F(StringMatcher, SafeRegexValue) { envoy::type::matcher::v3::StringMatcher matcher; matcher.mutable_safe_regex()->mutable_google_re2(); matcher.mutable_safe_regex()->set_regex("foo.*"); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("foo")); - EXPECT_TRUE(Matchers::StringMatcherImplWithContext(matcher, context_).match("foobar")); - EXPECT_FALSE(Matchers::StringMatcherImplWithContext(matcher, context_).match("bar")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("foo")); + EXPECT_TRUE(Matchers::StringMatcherImpl(matcher, context_).match("foobar")); + EXPECT_FALSE(Matchers::StringMatcherImpl(matcher, context_).match("bar")); } TEST_F(StringMatcher, SafeRegexValueIgnoreCase) { @@ -411,7 +405,7 @@ TEST_F(StringMatcher, SafeRegexValueIgnoreCase) { matcher.set_ignore_case(true); matcher.mutable_safe_regex()->mutable_google_re2(); matcher.mutable_safe_regex()->set_regex("foo"); - EXPECT_THROW_WITH_MESSAGE(Matchers::StringMatcherImplWithContext(matcher, context_).match("foo"), + EXPECT_THROW_WITH_MESSAGE(Matchers::StringMatcherImpl(matcher, context_).match("foo"), EnvoyException, "ignore_case has no effect for safe_regex."); } diff --git a/test/extensions/common/aws/utility_test.cc b/test/extensions/common/aws/utility_test.cc index d338bb211230..4554c09b5a23 100644 --- a/test/extensions/common/aws/utility_test.cc +++ b/test/extensions/common/aws/utility_test.cc @@ -169,8 +169,7 @@ TEST(UtilityTest, CanonicalizeHeadersDropExcludedMatchers) { envoy::type::matcher::v3::StringMatcher config; config.set_exact(str); exclusion_list.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( config, context)); } std::vector prefixes = {"x-envoy"}; @@ -178,8 +177,7 @@ TEST(UtilityTest, CanonicalizeHeadersDropExcludedMatchers) { envoy::type::matcher::v3::StringMatcher config; config.set_prefix(match_str); exclusion_list.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( config, context)); } const auto map = Utility::canonicalizeHeaders(headers, exclusion_list); 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 5b0c9cec8e4e..c7d11d2a4130 100644 --- a/test/extensions/filters/http/cache/cache_headers_utils_test.cc +++ b/test/extensions/filters/http/cache/cache_headers_utils_test.cc @@ -497,8 +497,7 @@ TEST(GetAllMatchingHeaderNames, EmptyHeaderMap) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); ruleset.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); @@ -515,8 +514,7 @@ TEST(GetAllMatchingHeaderNames, SingleMatchSingleValue) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); ruleset.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); @@ -534,8 +532,7 @@ TEST(GetAllMatchingHeaderNames, SingleMatchMultiValue) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); ruleset.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); CacheHeadersUtils::getAllMatchingHeaderNames(headers, ruleset, result); @@ -553,13 +550,11 @@ TEST(GetAllMatchingHeaderNames, MultipleMatches) { envoy::type::matcher::v3::StringMatcher matcher; matcher.set_exact("accept"); ruleset.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( matcher, context)); matcher.set_exact("accept-language"); ruleset.emplace_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + 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 2778f8760515..e141c395449c 100644 --- a/test/extensions/filters/http/cors/cors_filter_test.cc +++ b/test/extensions/filters/http/cors/cors_filter_test.cc @@ -27,18 +27,16 @@ 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< - Matchers::StringMatcherImplWithContext>(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< - Matchers::StringMatcherImplWithContext>(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 323946c9b544..4c4dc44bb1b1 100644 --- a/test/extensions/filters/http/ext_proc/mutation_utils_test.cc +++ b/test/extensions/filters/http/ext_proc/mutation_utils_test.cc @@ -342,13 +342,11 @@ TEST(MutationUtils, TestAllowHeadersExactCaseSensitive) { envoy::type::matcher::v3::StringMatcher string_matcher; string_matcher.set_exact(":method"); allow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); string_matcher.set_exact(":Path"); allow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers); @@ -371,14 +369,12 @@ TEST(MutationUtils, TestAllowHeadersExactIgnoreCase) { envoy::type::matcher::v3::StringMatcher string_matcher; string_matcher.set_exact(":method"); allow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); string_matcher.set_exact(":Path"); string_matcher.set_ignore_case(true); allow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + 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"}}; @@ -403,20 +399,17 @@ TEST(MutationUtils, TestBothAllowAndDisallowHeadersSet) { // Set allow_headers. string_matcher.set_exact(":method"); allow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); string_matcher.set_exact(":path"); allow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); // Set disallow_headers string_matcher.set_exact(":method"); disallow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers); @@ -442,13 +435,11 @@ TEST(MutationUtils, TestDisallowHeaderSetNotAllowHeader) { // Set disallow_headers. string_matcher.set_exact(":method"); disallow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); string_matcher.set_exact(":path"); disallow_headers.push_back( - std::make_unique< - Matchers::StringMatcherImplWithContext>( + std::make_unique>( string_matcher, context)); MutationUtils::headersToProto(headers, allow_headers, disallow_headers, proto_headers);