diff --git a/envoy/matcher/matcher.h b/envoy/matcher/matcher.h index 1e3993aeabacc..9606d841c1fa9 100644 --- a/envoy/matcher/matcher.h +++ b/envoy/matcher/matcher.h @@ -76,12 +76,11 @@ class Action { using ActionPtr = std::unique_ptr; using ActionFactoryCb = std::function; -template class ActionFactory : public Config::TypedFactory { +class ActionFactory : public Config::TypedFactory { public: virtual ActionFactoryCb - createActionFactoryCb(const Protobuf::Message& config, - ActionFactoryContext& action_factory_context, - ProtobufMessage::ValidationVisitor& validation_visitor) PURE; + createActionFactoryCb(const Protobuf::Message& config, const std::string& stats_prefix, + Server::Configuration::FactoryContext& context) PURE; std::string category() const override { return "envoy.matching.action"; } }; @@ -156,7 +155,7 @@ class InputMatcherFactory : public Config::TypedFactory { public: virtual InputMatcherFactoryCb createInputMatcherFactoryCb(const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) PURE; + Server::Configuration::FactoryContext& factory_context) PURE; std::string category() const override { return "envoy.matching.input_matchers"; } }; @@ -227,7 +226,7 @@ template class DataInputFactory : public Config::TypedFactory { */ virtual DataInputFactoryCb createDataInputFactoryCb(const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) PURE; + Server::Configuration::FactoryContext& factory_context) PURE; /** * The category of this factory depends on the DataType, so we require a name() function to exist @@ -263,7 +262,7 @@ class CommonProtocolInputFactory : public Config::TypedFactory { */ virtual CommonProtocolInputFactoryCb createCommonProtocolInputFactoryCb(const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) PURE; + Server::Configuration::FactoryContext& factory_context) PURE; std::string category() const override { return "envoy.matching.common_inputs"; } }; diff --git a/source/common/http/filter_manager.cc b/source/common/http/filter_manager.cc index 187647125234a..8f855eba2495d 100644 --- a/source/common/http/filter_manager.cc +++ b/source/common/http/filter_manager.cc @@ -13,13 +13,11 @@ #include "source/common/http/header_utility.h" #include "source/common/http/utility.h" -#include "matching/data_impl.h" - namespace Envoy { namespace Http { namespace { -REGISTER_FACTORY(SkipActionFactory, Matcher::ActionFactory); +REGISTER_FACTORY(SkipActionFactory, Matcher::ActionFactory); template using FilterList = std::list>; diff --git a/source/common/http/filter_manager.h b/source/common/http/filter_manager.h index f847e71051c37..1e826f1df5d1c 100644 --- a/source/common/http/filter_manager.h +++ b/source/common/http/filter_manager.h @@ -68,12 +68,11 @@ class FilterMatchState { using FilterMatchStateSharedPtr = std::shared_ptr; -class SkipActionFactory : public Matcher::ActionFactory { +class SkipActionFactory : public Matcher::ActionFactory { public: std::string name() const override { return "skip"; } - Matcher::ActionFactoryCb createActionFactoryCb(const Protobuf::Message&, - Matching::HttpFilterActionContext&, - ProtobufMessage::ValidationVisitor&) override { + Matcher::ActionFactoryCb createActionFactoryCb(const Protobuf::Message&, const std::string&, + Server::Configuration::FactoryContext&) override { return []() { return std::make_unique(); }; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { diff --git a/source/common/http/match_wrapper/BUILD b/source/common/http/match_wrapper/BUILD index 43de46e486ba1..6515bcffe786e 100644 --- a/source/common/http/match_wrapper/BUILD +++ b/source/common/http/match_wrapper/BUILD @@ -15,7 +15,6 @@ envoy_cc_library( deps = [ "//envoy/registry", "//envoy/server:filter_config_interface", - "//source/common/http/matching:data_impl_lib", "//source/common/matcher:matcher_lib", "//source/extensions/filters/http/common:factory_base_lib", "@envoy_api//envoy/extensions/common/matching/v3:pkg_cc_proto", diff --git a/source/common/http/match_wrapper/config.cc b/source/common/http/match_wrapper/config.cc index 68da3b37fd307..5d9ecd2f1685a 100644 --- a/source/common/http/match_wrapper/config.cc +++ b/source/common/http/match_wrapper/config.cc @@ -5,7 +5,6 @@ #include "envoy/registry/registry.h" #include "source/common/config/utility.h" -#include "source/common/http/matching/data_impl.h" #include "source/common/matcher/matcher.h" #include "absl/status/status.h" @@ -104,11 +103,9 @@ Envoy::Http::FilterFactoryCb MatchWrapperConfig::createFilterFactoryFromProtoTyp MatchTreeValidationVisitor validation_visitor(*factory.matchingRequirements()); - Envoy::Http::Matching::HttpFilterActionContext action_context{prefix, context}; - auto match_tree = Matcher::MatchTreeFactory( - action_context, context.messageValidationVisitor(), validation_visitor) - .create(proto_config.matcher()); + auto match_tree = + Matcher::MatchTreeFactory(prefix, context, validation_visitor) + .create(proto_config.matcher()); if (!validation_visitor.errors().empty()) { // TODO(snowp): Output all violations. diff --git a/source/common/http/matching/data_impl.h b/source/common/http/matching/data_impl.h index 5a5042e698b36..136ded3126100 100644 --- a/source/common/http/matching/data_impl.h +++ b/source/common/http/matching/data_impl.h @@ -55,10 +55,6 @@ class HttpMatchingDataImpl : public HttpMatchingData { using HttpMatchingDataImplSharedPtr = std::shared_ptr; -struct HttpFilterActionContext { - const std::string& stat_prefix_; - Server::Configuration::FactoryContext& factory_context_; -}; } // namespace Matching } // namespace Http } // namespace Envoy diff --git a/source/common/http/matching/inputs.h b/source/common/http/matching/inputs.h index 551cab256fb75..052308c5c547d 100644 --- a/source/common/http/matching/inputs.h +++ b/source/common/http/matching/inputs.h @@ -55,9 +55,9 @@ class HttpHeadersDataInputFactoryBase : public Matcher::DataInputFactory createDataInputFactoryCb(const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) override { - const auto& typed_config = - MessageUtil::downcastAndValidate(config, validation_visitor); + Server::Configuration::FactoryContext& factory_context) override { + const auto& typed_config = MessageUtil::downcastAndValidate( + config, factory_context.messageValidationVisitor()); return [header_name = typed_config.header_name()] { return std::make_unique(header_name); diff --git a/source/common/matcher/matcher.h b/source/common/matcher/matcher.h index ee0dfdc346419..376e486060577 100644 --- a/source/common/matcher/matcher.h +++ b/source/common/matcher/matcher.h @@ -66,15 +66,13 @@ template using DataInputFactoryCb = std::function class MatchTreeFactory { +template class MatchTreeFactory { public: - MatchTreeFactory(ActionFactoryContext& context, - ProtobufMessage::ValidationVisitor& proto_validation_visitor, + MatchTreeFactory(const std::string& stats_prefix, + Server::Configuration::FactoryContext& factory_context, MatchTreeValidationVisitor& validation_visitor) - : action_factory_context_(context), proto_validation_visitor_(proto_validation_visitor), + : stats_prefix_(stats_prefix), factory_context_(factory_context), validation_visitor_(validation_visitor) {} MatchTreeFactoryCb create(const envoy::config::common::matcher::v3::Matcher& config) { @@ -202,13 +200,12 @@ template class MatchTreeFactory { return OnMatch{{}, matcher_factory()}; }; } else if (on_match.has_action()) { - auto& factory = Config::Utility::getAndCheckFactory>( - on_match.action()); + auto& factory = Config::Utility::getAndCheckFactory(on_match.action()); ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - on_match.action().typed_config(), proto_validation_visitor_, factory); + on_match.action().typed_config(), factory_context_.messageValidationVisitor(), factory); - auto action_factory = factory.createActionFactoryCb(*message, action_factory_context_, - proto_validation_visitor_); + auto action_factory = + factory.createActionFactoryCb(*message, stats_prefix_, factory_context_); return [action_factory] { return OnMatch{action_factory, {}}; }; } @@ -237,8 +234,8 @@ template class MatchTreeFactory { validation_visitor_.validateDataInput(*factory, config.typed_config().type_url()); ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - config.typed_config(), proto_validation_visitor_, *factory); - auto data_input = factory->createDataInputFactoryCb(*message, proto_validation_visitor_); + config.typed_config(), factory_context_.messageValidationVisitor(), *factory); + auto data_input = factory->createDataInputFactoryCb(*message, factory_context_); return data_input; } @@ -247,9 +244,9 @@ template class MatchTreeFactory { auto& common_input_factory = Config::Utility::getAndCheckFactory(config); ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - config.typed_config(), proto_validation_visitor_, common_input_factory); - auto common_input = common_input_factory.createCommonProtocolInputFactoryCb( - *message, proto_validation_visitor_); + config.typed_config(), factory_context_.messageValidationVisitor(), common_input_factory); + auto common_input = + common_input_factory.createCommonProtocolInputFactoryCb(*message, factory_context_); return [common_input]() { return std::make_unique(common_input()); }; } @@ -268,8 +265,9 @@ template class MatchTreeFactory { auto& factory = Config::Utility::getAndCheckFactory(predicate.custom_match()); ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - predicate.custom_match().typed_config(), proto_validation_visitor_, factory); - return factory.createInputMatcherFactoryCb(*message, proto_validation_visitor_); + predicate.custom_match().typed_config(), factory_context_.messageValidationVisitor(), + factory); + return factory.createInputMatcherFactoryCb(*message, factory_context_); } default: NOT_REACHED_GCOVR_EXCL_LINE; @@ -277,8 +275,7 @@ template class MatchTreeFactory { } const std::string stats_prefix_; - ActionFactoryContext& action_factory_context_; - ProtobufMessage::ValidationVisitor& proto_validation_visitor_; + Server::Configuration::FactoryContext& factory_context_; MatchTreeValidationVisitor& validation_visitor_; }; } // namespace Matcher diff --git a/source/extensions/filters/http/composite/BUILD b/source/extensions/filters/http/composite/BUILD index 512c9b0549139..e2f0946aa6aaa 100644 --- a/source/extensions/filters/http/composite/BUILD +++ b/source/extensions/filters/http/composite/BUILD @@ -16,7 +16,6 @@ envoy_cc_library( srcs = ["action.cc"], hdrs = ["action.h"], deps = [ - "//source/common/http/matching:data_impl_lib", "//source/common/matcher:matcher_lib", "@envoy_api//envoy/extensions/filters/http/composite/v3:pkg_cc_proto", ], diff --git a/source/extensions/filters/http/composite/action.cc b/source/extensions/filters/http/composite/action.cc index 743430b5fad30..14935fa819dbc 100644 --- a/source/extensions/filters/http/composite/action.cc +++ b/source/extensions/filters/http/composite/action.cc @@ -7,8 +7,7 @@ namespace Composite { void ExecuteFilterAction::createFilters(Http::FilterChainFactoryCallbacks& callbacks) const { cb_(callbacks); } -REGISTER_FACTORY(ExecuteFilterActionFactory, - Matcher::ActionFactory); +REGISTER_FACTORY(ExecuteFilterActionFactory, Matcher::ActionFactory); } // namespace Composite } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/composite/action.h b/source/extensions/filters/http/composite/action.h index f6c69321a1bad..1d2b822e79949 100644 --- a/source/extensions/filters/http/composite/action.h +++ b/source/extensions/filters/http/composite/action.h @@ -2,7 +2,6 @@ #include "envoy/extensions/filters/http/composite/v3/composite.pb.validate.h" -#include "source/common/http/matching/data_impl.h" #include "source/common/matcher/matcher.h" namespace Envoy { @@ -22,25 +21,23 @@ class ExecuteFilterAction Http::FilterFactoryCb cb_; }; -class ExecuteFilterActionFactory - : public Matcher::ActionFactory { +class ExecuteFilterActionFactory : public Matcher::ActionFactory { public: std::string name() const override { return "composite-action"; } Matcher::ActionFactoryCb - createActionFactoryCb(const Protobuf::Message& config, - Http::Matching::HttpFilterActionContext& context, - ProtobufMessage::ValidationVisitor& validation_visitor) override { + createActionFactoryCb(const Protobuf::Message& config, const std::string& stat_prefix, + Server::Configuration::FactoryContext& factory_context) override { const auto& composite_action = MessageUtil::downcastAndValidate< const envoy::extensions::filters::http::composite::v3::ExecuteFilterAction&>( - config, validation_visitor); + config, factory_context.messageValidationVisitor()); auto& factory = Config::Utility::getAndCheckFactory( composite_action.typed_config()); ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - composite_action.typed_config().typed_config(), validation_visitor, factory); - auto callback = factory.createFilterFactoryFromProto(*message, context.stat_prefix_, - context.factory_context_); + composite_action.typed_config().typed_config(), factory_context.messageValidationVisitor(), + factory); + auto callback = factory.createFilterFactoryFromProto(*message, stat_prefix, factory_context); return [cb = std::move(callback)]() -> Matcher::ActionPtr { return std::make_unique(cb); }; diff --git a/source/extensions/matching/common_inputs/environment_variable/config.cc b/source/extensions/matching/common_inputs/environment_variable/config.cc index be8235c2c5a3f..bebbe41a7fd91 100644 --- a/source/extensions/matching/common_inputs/environment_variable/config.cc +++ b/source/extensions/matching/common_inputs/environment_variable/config.cc @@ -12,10 +12,10 @@ namespace EnvironmentVariable { Envoy::Matcher::CommonProtocolInputFactoryCb Config::createCommonProtocolInputFactoryCb(const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) { + Server::Configuration::FactoryContext& factory_context) { const auto& environment_config = MessageUtil::downcastAndValidate< const envoy::extensions::matching::common_inputs::environment_variable::v3::Config&>( - config, validation_visitor); + config, factory_context.messageValidationVisitor()); // We read the env variable at construction time to avoid repeat lookups. // This assumes that the environment remains stable during the process lifetime. diff --git a/source/extensions/matching/common_inputs/environment_variable/config.h b/source/extensions/matching/common_inputs/environment_variable/config.h index 9db12bdcaf215..842e7c4bb23f4 100644 --- a/source/extensions/matching/common_inputs/environment_variable/config.h +++ b/source/extensions/matching/common_inputs/environment_variable/config.h @@ -18,7 +18,7 @@ class Config : public Envoy::Matcher::CommonProtocolInputFactory { public: Envoy::Matcher::CommonProtocolInputFactoryCb createCommonProtocolInputFactoryCb( const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) override; + Server::Configuration::FactoryContext& factory_context) override; std::string name() const override { return "envoy.matching.common_inputs.environment_variable"; } diff --git a/source/extensions/matching/input_matchers/consistent_hashing/config.cc b/source/extensions/matching/input_matchers/consistent_hashing/config.cc index 692026a20f320..cfcac842d3667 100644 --- a/source/extensions/matching/input_matchers/consistent_hashing/config.cc +++ b/source/extensions/matching/input_matchers/consistent_hashing/config.cc @@ -7,11 +7,11 @@ namespace InputMatchers { namespace ConsistentHashing { Envoy::Matcher::InputMatcherFactoryCb ConsistentHashingConfig::createInputMatcherFactoryCb( - const Protobuf::Message& config, ProtobufMessage::ValidationVisitor& validation_visitor) { + const Protobuf::Message& config, Server::Configuration::FactoryContext& factory_context) { const auto& consistent_hashing_config = MessageUtil::downcastAndValidate( - config, validation_visitor); + config, factory_context.messageValidationVisitor()); if (consistent_hashing_config.threshold() > consistent_hashing_config.modulo()) { throw EnvoyException(fmt::format("threshold cannot be greater than modulo: {} > {}", diff --git a/source/extensions/matching/input_matchers/consistent_hashing/config.h b/source/extensions/matching/input_matchers/consistent_hashing/config.h index fa73fb2f683e6..1ce2dd6289863 100644 --- a/source/extensions/matching/input_matchers/consistent_hashing/config.h +++ b/source/extensions/matching/input_matchers/consistent_hashing/config.h @@ -18,7 +18,7 @@ class ConsistentHashingConfig : public Envoy::Matcher::InputMatcherFactory { public: Envoy::Matcher::InputMatcherFactoryCb createInputMatcherFactoryCb(const Protobuf::Message& config, - ProtobufMessage::ValidationVisitor& validation_visitor) override; + Server::Configuration::FactoryContext& factory_context) override; std::string name() const override { return "envoy.matching.matchers.consistent_hashing"; } diff --git a/test/common/matcher/matcher_test.cc b/test/common/matcher/matcher_test.cc index ce768a1e216bb..99558fc1af9ed 100644 --- a/test/common/matcher/matcher_test.cc +++ b/test/common/matcher/matcher_test.cc @@ -22,16 +22,12 @@ namespace Envoy { namespace Matcher { class MatcherTest : public ::testing::Test { public: - MatcherTest() - : inject_action_(action_factory_), - factory_(context_, ProtobufMessage::getStrictValidationVisitor(), validation_visitor_) {} + MatcherTest() : inject_action_(action_factory_) {} StringActionFactory action_factory_; - Registry::InjectFactory> inject_action_; + Registry::InjectFactory inject_action_; + NiceMock factory_context_; MockMatchTreeValidationVisitor validation_visitor_; - - absl::string_view context_ = ""; - MatchTreeFactory factory_; }; TEST_F(MatcherTest, TestMatcher) { @@ -68,13 +64,15 @@ TEST_F(MatcherTest, TestMatcher) { TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); + auto outer_factory = TestDataInputFactory("outer_input", "value"); auto inner_factory = TestDataInputFactory("inner_input", "foo"); EXPECT_CALL(validation_visitor_, performDataInputValidation(_, "type.googleapis.com/google.protobuf.StringValue")) .Times(2); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); @@ -106,9 +104,10 @@ TEST_F(MatcherTest, CustomGenericInput) { MessageUtil::loadFromYaml(yaml, matcher, ProtobufMessage::getStrictValidationVisitor()); TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); auto common_input_factory = TestCommonProtocolInputFactory("generic", "foo"); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); @@ -142,12 +141,14 @@ TEST_F(MatcherTest, CustomMatcher) { TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); + auto inner_factory = TestDataInputFactory("inner_input", "foo"); NeverMatchFactory match_factory; EXPECT_CALL(validation_visitor_, performDataInputValidation(_, "type.googleapis.com/google.protobuf.StringValue")); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); @@ -197,13 +198,15 @@ TEST_F(MatcherTest, TestAndMatcher) { TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); + auto outer_factory = TestDataInputFactory("outer_input", "value"); auto inner_factory = TestDataInputFactory("inner_input", "foo"); EXPECT_CALL(validation_visitor_, performDataInputValidation(_, "type.googleapis.com/google.protobuf.StringValue")) .Times(3); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); @@ -254,13 +257,15 @@ TEST_F(MatcherTest, TestOrMatcher) { TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); + auto outer_factory = TestDataInputFactory("outer_input", "value"); auto inner_factory = TestDataInputFactory("inner_input", "foo"); EXPECT_CALL(validation_visitor_, performDataInputValidation(_, "type.googleapis.com/google.protobuf.StringValue")) .Times(3); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); @@ -294,12 +299,14 @@ TEST_F(MatcherTest, TestNotMatcher) { TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); + auto inner_factory = TestDataInputFactory("inner_input", "foo"); NeverMatchFactory match_factory; EXPECT_CALL(validation_visitor_, performDataInputValidation(_, "type.googleapis.com/google.protobuf.StringValue")); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); @@ -343,13 +350,15 @@ TEST_F(MatcherTest, TestRecursiveMatcher) { TestUtility::validate(matcher); + MatchTreeFactory factory("", factory_context_, validation_visitor_); + auto outer_factory = TestDataInputFactory("outer_input", "value"); auto inner_factory = TestDataInputFactory("inner_input", "foo"); EXPECT_CALL(validation_visitor_, performDataInputValidation(_, "type.googleapis.com/google.protobuf.StringValue")) .Times(2); - auto match_tree = factory_.create(matcher); + auto match_tree = factory.create(matcher); const auto result = match_tree()->match(TestData()); EXPECT_EQ(result.match_state_, MatchState::MatchComplete); diff --git a/test/common/matcher/test_utility.h b/test/common/matcher/test_utility.h index e8ab24fde0706..08d1debbf0e6d 100644 --- a/test/common/matcher/test_utility.h +++ b/test/common/matcher/test_utility.h @@ -30,7 +30,7 @@ class TestCommonProtocolInputFactory : public CommonProtocolInputFactory { CommonProtocolInputFactoryCb createCommonProtocolInputFactoryCb(const Protobuf::Message&, - ProtobufMessage::ValidationVisitor&) override { + Server::Configuration::FactoryContext&) override { return [&]() { return std::make_unique(value_); }; } @@ -60,7 +60,8 @@ class TestDataInputFactory : public DataInputFactory { : factory_name_(std::string(factory_name)), value_(std::string(data)), injection_(*this) {} DataInputFactoryCb - createDataInputFactoryCb(const Protobuf::Message&, ProtobufMessage::ValidationVisitor&) override { + createDataInputFactoryCb(const Protobuf::Message&, + Server::Configuration::FactoryContext&) override { return [&]() { return std::make_unique( DataInputGetResult{DataInputGetResult::DataAvailability::AllDataAvailable, value_}); @@ -107,10 +108,10 @@ struct StringAction : public ActionBase { }; // Factory for StringAction. -class StringActionFactory : public ActionFactory { +class StringActionFactory : public ActionFactory { public: - ActionFactoryCb createActionFactoryCb(const Protobuf::Message& config, absl::string_view&, - ProtobufMessage::ValidationVisitor&) override { + ActionFactoryCb createActionFactoryCb(const Protobuf::Message& config, const std::string&, + Server::Configuration::FactoryContext&) override { const auto& string = dynamic_cast(config); return [string]() { return std::make_unique(string.value()); }; } @@ -134,8 +135,9 @@ class NeverMatchFactory : public InputMatcherFactory { public: NeverMatchFactory() : inject_factory_(*this) {} - InputMatcherFactoryCb createInputMatcherFactoryCb(const Protobuf::Message&, - ProtobufMessage::ValidationVisitor&) override { + InputMatcherFactoryCb + createInputMatcherFactoryCb(const Protobuf::Message&, + Server::Configuration::FactoryContext&) override { return []() { return std::make_unique(); }; } diff --git a/test/extensions/matching/common_inputs/environment_variable/config_test.cc b/test/extensions/matching/common_inputs/environment_variable/config_test.cc index 94dd3d0bea242..86c66037780d2 100644 --- a/test/extensions/matching/common_inputs/environment_variable/config_test.cc +++ b/test/extensions/matching/common_inputs/environment_variable/config_test.cc @@ -13,6 +13,8 @@ namespace CommonInputs { namespace EnvironmentVariable { TEST(ConfigTest, TestConfig) { + NiceMock context; + const std::string yaml_string = R"EOF( name: hashing typed_config: @@ -28,16 +30,14 @@ TEST(ConfigTest, TestConfig) { config.typed_config(), ProtobufMessage::getStrictValidationVisitor(), factory); { - auto input_factory = factory.createCommonProtocolInputFactoryCb( - *message, ProtobufMessage::getStrictValidationVisitor()); + auto input_factory = factory.createCommonProtocolInputFactoryCb(*message, context); EXPECT_NE(nullptr, input_factory); EXPECT_EQ(input_factory()->get(), absl::nullopt); } TestEnvironment::setEnvVar("foo", "bar", 1); { - auto input_factory = factory.createCommonProtocolInputFactoryCb( - *message, ProtobufMessage::getStrictValidationVisitor()); + auto input_factory = factory.createCommonProtocolInputFactoryCb(*message, context); EXPECT_NE(nullptr, input_factory); EXPECT_EQ(input_factory()->get(), absl::make_optional("bar")); } diff --git a/test/extensions/matching/input_matchers/consistent_hashing/config_test.cc b/test/extensions/matching/input_matchers/consistent_hashing/config_test.cc index 3d0fcd28ff46c..f70eb2825b9d0 100644 --- a/test/extensions/matching/input_matchers/consistent_hashing/config_test.cc +++ b/test/extensions/matching/input_matchers/consistent_hashing/config_test.cc @@ -11,6 +11,8 @@ namespace InputMatchers { namespace ConsistentHashing { TEST(ConfigTest, TestConfig) { + NiceMock context; + const std::string yaml_string = R"EOF( name: hashing typed_config: @@ -25,13 +27,14 @@ TEST(ConfigTest, TestConfig) { ConsistentHashingConfig factory; auto message = Config::Utility::translateAnyToFactoryConfig( config.typed_config(), ProtobufMessage::getStrictValidationVisitor(), factory); - auto matcher = - factory.createInputMatcherFactoryCb(*message, ProtobufMessage::getStrictValidationVisitor()); + auto matcher = factory.createInputMatcherFactoryCb(*message, context); ASSERT_NE(nullptr, matcher); matcher(); } TEST(ConfigTest, InvalidConfig) { + NiceMock context; + const std::string yaml_string = R"EOF( name: hashing typed_config: @@ -46,9 +49,8 @@ TEST(ConfigTest, InvalidConfig) { ConsistentHashingConfig factory; auto message = Config::Utility::translateAnyToFactoryConfig( config.typed_config(), ProtobufMessage::getStrictValidationVisitor(), factory); - EXPECT_THROW_WITH_MESSAGE( - factory.createInputMatcherFactoryCb(*message, ProtobufMessage::getStrictValidationVisitor()), - EnvoyException, "threshold cannot be greater than modulo: 200 > 100"); + EXPECT_THROW_WITH_MESSAGE(factory.createInputMatcherFactoryCb(*message, context), EnvoyException, + "threshold cannot be greater than modulo: 200 > 100"); } } // namespace ConsistentHashing } // namespace InputMatchers