Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ envoy_cc_library(
"//source/common/protobuf:utility_lib",
"//source/common/router:rds_lib",
"//source/common/router:scoped_rds_lib",
"//source/extensions/filters/http:well_known_names",
"//source/extensions/filters/network:well_known_names",
"//source/extensions/filters/network/common:factory_base_lib",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "common/router/rds_impl.h"
#include "common/router/scoped_rds.h"

#include "extensions/filters/http/well_known_names.h"

namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
Expand Down Expand Up @@ -306,6 +308,10 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig(

const auto& filters = config.http_filters();
for (int32_t i = 0; i < filters.size(); i++) {
if (filters[i].name() == HttpFilters::HttpFilterNames::get().Router &&
i != filters.size() - 1) {
throw EnvoyException(fmt::format("Error: envoy.router must be terminal filter."));
}
processFilter(filters[i], i, "http", filter_factories_);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ stat_prefix: router
EnvoyException, "Didn't find a registered implementation for name: 'foo'");
}

TEST_F(HttpConnectionManagerConfigTest, RouterInverted) {
const std::string yaml_string = R"EOF(
codec_type: http1
server_name: foo
stat_prefix: router
route_config:
virtual_hosts:
- name: service
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: cluster
http_filters:
- name: envoy.router
config: {}
- name: envoy.health_check
config:
pass_through_mode: false
)EOF";

EXPECT_THROW_WITH_MESSAGE(
HttpConnectionManagerConfig(parseHttpConnectionManagerFromV2Yaml(yaml_string), context_,
date_provider_, route_config_provider_manager_,
scoped_routes_config_provider_manager_),
EnvoyException, "Error: envoy.router must be terminal filter.");
}

TEST_F(HttpConnectionManagerConfigTest, MiscConfig) {
const std::string yaml_string = R"EOF(
codec_type: http1
Expand All @@ -166,6 +196,9 @@ stat_prefix: router
request_headers_for_tags:
- foo
http_filters:
- name: envoy.health_check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed - I just wanted the comparable test to have 2 filters in the right order to verify that worked.
Can revert if you'd prefer - obviously we have enough integration tests of multiple filters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way. I guess I have a mild preference to revert but I don't feel strongly about it.

config:
pass_through_mode: false
- name: envoy.router
config: {}
)EOF";
Expand Down