diff --git a/ci/build_setup.sh b/ci/build_setup.sh index ec5b4579799e7..dba93c0dd78d3 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -87,7 +87,7 @@ if [ "$1" != "-nofetch" ]; then fi # This is the hash on https://github.com/envoyproxy/envoy-filter-example.git we pin to. - (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f 92307d723a1ead25c39f025a734fa091443efdbc) + (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f 3e5b73305b961526ffcee7584251692a9a3ce4b3) cp -f "${ENVOY_SRCDIR}"/ci/WORKSPACE.filter.example "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/WORKSPACE fi diff --git a/source/common/common/assert.h b/source/common/common/assert.h index 52e587d817f67..9d4f4c5275215 100644 --- a/source/common/common/assert.h +++ b/source/common/common/assert.h @@ -53,9 +53,6 @@ namespace Envoy { // reports. #define NOT_IMPLEMENTED_GCOVR_EXCL_LINE PANIC("not implemented") -// Deprecated: use NOT_IMPLEMENTED_GCOVR_EXCL_LINE instead. -#define NOT_IMPLEMENTED NOT_IMPLEMENTED_GCOVR_EXCL_LINE - // NOT_REACHED_GCOVR_EXCL_LINE is for spots the compiler insists on having a return, but where we // know that it shouldn't be possible to arrive there, assuming no horrendous bugs. For example, // after a switch (some_enum) with all enum values included in the cases. The macro name includes diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index 5596dc2553199..e8d82f40e0aa2 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -4434,7 +4434,9 @@ name: NoIdleTimeout class PerFilterConfigsTest : public testing::Test { public: - PerFilterConfigsTest() : factory_(), registered_factory_(factory_) {} + PerFilterConfigsTest() + : factory_(), registered_factory_(factory_), default_factory_(), + registered_default_factory_(default_factory_) {} struct DerivedFilterConfig : public RouteSpecificFilterConfig { ProtobufWkt::Timestamp config_; @@ -4458,6 +4460,15 @@ class PerFilterConfigsTest : public testing::Test { return obj; } }; + class DefaultTestFilterConfig : public Extensions::HttpFilters::Common::EmptyHttpFilterConfig { + public: + DefaultTestFilterConfig() : EmptyHttpFilterConfig("test.default.filter") {} + + Http::FilterFactoryCb createFilter(const std::string&, + Server::Configuration::FactoryContext&) override { + NOT_IMPLEMENTED_GCOVR_EXCL_LINE; + } + }; void checkEach(const std::string& yaml, uint32_t expected_entry, uint32_t expected_route, uint32_t expected_vhost) { @@ -4481,8 +4492,24 @@ class PerFilterConfigsTest : public testing::Test { << "config value does not match expected for source: " << source; } + void checkNoPerFilterConfig(const std::string& yaml) { + const ConfigImpl config(parseRouteConfigurationFromV2Yaml(yaml), factory_context_, true); + + const auto route = config.route(genHeaders("www.foo.com", "/", "GET"), 0); + const auto* route_entry = route->routeEntry(); + const auto& vhost = route_entry->virtualHost(); + + EXPECT_EQ(nullptr, + route_entry->perFilterConfigTyped(default_factory_.name())); + EXPECT_EQ(nullptr, route->perFilterConfigTyped(default_factory_.name())); + EXPECT_EQ(nullptr, vhost.perFilterConfigTyped(default_factory_.name())); + } + TestFilterConfig factory_; Registry::InjectFactory registered_factory_; + DefaultTestFilterConfig default_factory_; + Registry::InjectFactory + registered_default_factory_; NiceMock factory_context_; }; @@ -4503,6 +4530,23 @@ name: foo "Didn't find a registered implementation for name: 'unknown.filter'"); } +// Test that a trivially specified NamedHttpFilterConfigFactory ignores per_filter_config without +// error. +TEST_F(PerFilterConfigsTest, DefaultFilterImplementation) { + std::string yaml = R"EOF( +name: foo +virtual_hosts: + - name: bar + domains: ["*"] + routes: + - match: { prefix: "/" } + route: { cluster: baz } + per_filter_config: { test.default.filter: { unknown_key: 123} } +)EOF"; + + checkNoPerFilterConfig(yaml); +} + TEST_F(PerFilterConfigsTest, RouteLocalConfig) { std::string yaml = R"EOF( name: foo