Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -82,7 +82,7 @@ class SquashFilterIntegrationTest : public testing::TestWithParam<Network::Addre

autonomous_upstream_ = true;

config_helper_.addFilter(ConfigHelper::defaultSquashFilter());
config_helper_.prependFilter(ConfigHelper::defaultSquashFilter());

config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) {
auto* squash_cluster = bootstrap.mutable_static_resources()->add_clusters();
Expand Down
4 changes: 3 additions & 1 deletion test/config/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,9 @@ void ConfigHelper::addVirtualHost(const envoy::config::route::v3::VirtualHost& v
storeHttpConnectionManager(hcm_config);
}

void ConfigHelper::addFilter(const std::string& config) {
void ConfigHelper::addFilter(const std::string& config) { prependFilter(config); }

void ConfigHelper::prependFilter(const std::string& config) {
RELEASE_ASSERT(!finalized_, "");
envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager
hcm_config;
Expand Down
12 changes: 8 additions & 4 deletions test/config/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ class ConfigHelper {
static std::string httpProxyConfig(bool downstream_use_quic = false);
// A basic configuration for L7 proxying with QUIC transport.
static std::string quicHttpProxyConfig();
// A string for a basic buffer filter, which can be used with addFilter()
// A string for a basic buffer filter, which can be used with prependFilter()
static std::string defaultBufferFilter();
// A string for a small buffer filter, which can be used with addFilter()
// A string for a small buffer filter, which can be used with prependFilter()
static std::string smallBufferFilter();
// A string for a health check filter which can be used with addFilter()
// A string for a health check filter which can be used with prependFilter()
static std::string defaultHealthCheckFilter();
// A string for a squash filter which can be used with addFilter()
// A string for a squash filter which can be used with prependFilter()
static std::string defaultSquashFilter();
// A string for startTls transport socket config.
static std::string startTlsConfig();
Expand Down Expand Up @@ -213,6 +213,10 @@ class ConfigHelper {
void addVirtualHost(const envoy::config::route::v3::VirtualHost& vhost);

// Add an HTTP filter prior to existing filters.
void prependFilter(const std::string& filter_yaml);

// Add an HTTP filter prior to existing filters.
// TODO(rgs1): remove once envoy-filter-example has been updated.
void addFilter(const std::string& filter_yaml);

// Add a network filter prior to existing filters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AdaptiveConcurrencyIntegrationTest
void customInit() {
setDownstreamProtocol(Http::CodecType::HTTP2);
setUpstreamProtocol(Http::CodecType::HTTP2);
config_helper_.addFilter(ADAPTIVE_CONCURRENCY_CONFIG);
config_helper_.prependFilter(ADAPTIVE_CONCURRENCY_CONFIG);
initialize();
codec_client_ = makeHttpConnection(lookupPort("http"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AdmissionControlIntegrationTest : public Event::TestUsingSimulatedTime,

void initialize() override {
config_helper_.addConfigModifier(setEnableDownstreamTrailersHttp1());
config_helper_.addFilter(ADMISSION_CONTROL_CONFIG);
config_helper_.prependFilter(ADMISSION_CONTROL_CONFIG);
HttpIntegrationTest::initialize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ name: alternate_protocols_cache
alternate_protocols_cache_options:
name: default_alternate_protocols_cache
)EOF";
config_helper_.addFilter(filter);
config_helper_.prependFilter(filter);

upstream_tls_ = true;
config_helper_.configureUpstreamTls(/*use_alpn=*/true, /*http3=*/true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AwsLambdaFilterIntegrationTest : public testing::TestWithParam<Network::Ad
arn: "arn:aws:lambda:us-west-2:123456789:function:test"
payload_passthrough: {}
)EOF";
config_helper_.addFilter(fmt::format(filter, passthrough));
config_helper_.prependFilter(fmt::format(filter, passthrough));

constexpr auto metadata_yaml = R"EOF(
com.amazonaws.lambda:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ INSTANTIATE_TEST_SUITE_P(Protocols, BufferIntegrationTest,
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(BufferIntegrationTest, RouterNotFoundBodyBuffer) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
testRouterNotFoundWithBody();
}

TEST_P(BufferIntegrationTest, RouterRequestAndResponseWithGiantBodyBuffer) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
testRouterRequestAndResponseWithBody(4 * 1024 * 1024, 4 * 1024 * 1024, false);
}

TEST_P(BufferIntegrationTest, RouterHeaderOnlyRequestAndResponseBuffer) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
testRouterHeaderOnlyRequestAndResponse();
}

TEST_P(BufferIntegrationTest, RouterRequestAndResponseWithBodyBuffer) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
testRouterRequestAndResponseWithBody(1024, 512, false);
}

TEST_P(BufferIntegrationTest, RouterRequestAndResponseWithZeroByteBodyBuffer) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
testRouterRequestAndResponseWithBody(0, 0, false);
}

TEST_P(BufferIntegrationTest, RouterRequestPopulateContentLength) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
Expand All @@ -67,7 +67,7 @@ TEST_P(BufferIntegrationTest, RouterRequestPopulateContentLength) {
}

TEST_P(BufferIntegrationTest, RouterRequestPopulateContentLengthOnTrailers) {
config_helper_.addFilter(ConfigHelper::defaultBufferFilter());
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter());
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
Expand Down Expand Up @@ -103,7 +103,7 @@ TEST_P(BufferIntegrationTest, RouterRequestBufferLimitExceeded) {
config_helper_.addConfigModifier(
[](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) { hcm.mutable_delayed_close_timeout()->set_seconds(2000 * 1000); });
config_helper_.addFilter(ConfigHelper::smallBufferFilter());
config_helper_.prependFilter(ConfigHelper::smallBufferFilter());
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
Expand Down Expand Up @@ -142,7 +142,7 @@ ConfigHelper::HttpModifierFunction overrideConfig(const std::string& json_config
TEST_P(BufferIntegrationTest, RouteDisabled) {
ConfigHelper::HttpModifierFunction mod = overrideConfig(R"EOF({"disabled": true})EOF");
config_helper_.addConfigModifier(mod);
config_helper_.addFilter(ConfigHelper::smallBufferFilter());
config_helper_.prependFilter(ConfigHelper::smallBufferFilter());
config_helper_.setBufferLimits(1024, 1024);

initialize();
Expand All @@ -169,7 +169,7 @@ TEST_P(BufferIntegrationTest, RouteOverride) {
"max_request_bytes": 5242880
}})EOF");
config_helper_.addConfigModifier(mod);
config_helper_.addFilter(ConfigHelper::smallBufferFilter());
config_helper_.prependFilter(ConfigHelper::smallBufferFilter());

initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CacheIntegrationTest : public Event::TestUsingSimulatedTime,
}

void initializeFilter(const std::string& config) {
config_helper_.addFilter(config);
config_helper_.prependFilter(config);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection((lookupPort("http"))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ name: envoy.filters.http.cdn_loop
class CdnLoopFilterIntegrationTest : public HttpProtocolIntegrationTest {};

TEST_P(CdnLoopFilterIntegrationTest, NoCdnLoopHeader) {
config_helper_.addFilter(MaxDefaultConfig);
config_helper_.prependFilter(MaxDefaultConfig);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -48,7 +48,7 @@ TEST_P(CdnLoopFilterIntegrationTest, NoCdnLoopHeader) {
}

TEST_P(CdnLoopFilterIntegrationTest, CdnLoopHeaderWithOtherCdns) {
config_helper_.addFilter(MaxDefaultConfig);
config_helper_.prependFilter(MaxDefaultConfig);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -68,7 +68,7 @@ TEST_P(CdnLoopFilterIntegrationTest, CdnLoopHeaderWithOtherCdns) {
}

TEST_P(CdnLoopFilterIntegrationTest, MultipleCdnLoopHeaders) {
config_helper_.addFilter(MaxDefaultConfig);
config_helper_.prependFilter(MaxDefaultConfig);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -86,7 +86,7 @@ TEST_P(CdnLoopFilterIntegrationTest, MultipleCdnLoopHeaders) {
}

TEST_P(CdnLoopFilterIntegrationTest, CdnLoop0Allowed1Seen) {
config_helper_.addFilter(MaxDefaultConfig);
config_helper_.prependFilter(MaxDefaultConfig);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -103,7 +103,7 @@ TEST_P(CdnLoopFilterIntegrationTest, CdnLoop0Allowed1Seen) {
}

TEST_P(CdnLoopFilterIntegrationTest, UnparseableHeader) {
config_helper_.addFilter(MaxDefaultConfig);
config_helper_.prependFilter(MaxDefaultConfig);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -120,7 +120,7 @@ TEST_P(CdnLoopFilterIntegrationTest, UnparseableHeader) {
}

TEST_P(CdnLoopFilterIntegrationTest, CdnLoop2Allowed1Seen) {
config_helper_.addFilter(MaxOf2Config);
config_helper_.prependFilter(MaxOf2Config);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -140,7 +140,7 @@ TEST_P(CdnLoopFilterIntegrationTest, CdnLoop2Allowed1Seen) {
}

TEST_P(CdnLoopFilterIntegrationTest, CdnLoop2Allowed2Seen) {
config_helper_.addFilter(MaxOf2Config);
config_helper_.prependFilter(MaxOf2Config);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand All @@ -160,7 +160,7 @@ TEST_P(CdnLoopFilterIntegrationTest, CdnLoop2Allowed2Seen) {
}

TEST_P(CdnLoopFilterIntegrationTest, CdnLoop2Allowed3Seen) {
config_helper_.addFilter(MaxOf2Config);
config_helper_.prependFilter(MaxOf2Config);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CompositeFilterIntegrationTest : public testing::TestWithParam<Network::Ad
void initialize() override {
config_helper_.addRuntimeOverride("envoy.reloadable_features.experimental_matching_api",
"true");
config_helper_.addFilter(R"EOF(
config_helper_.prependFilter(R"EOF(
name: composite
typed_config:
"@type": type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CompressorIntegrationTest : public testing::TestWithParam<Network::Address
void TearDown() override { cleanupUpstreamAndDownstream(); }

void initializeFilter(const std::string& config) {
config_helper_.addFilter(config);
config_helper_.prependFilter(config);
initialize();
codec_client_ = makeHttpConnection(makeClientConnection((lookupPort("http"))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void WebsocketWithCompressorIntegrationTest::initialize() {
[&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void { hcm.mutable_http2_protocol_options()->set_allow_connect(true); });
}
config_helper_.addFilter(compressorFilterConfig);
config_helper_.prependFilter(compressorFilterConfig);
HttpProtocolIntegrationTest::initialize();
}

Expand Down Expand Up @@ -247,7 +247,7 @@ void CompressorProxyingConnectIntegrationTest::initialize() {
config_helper_.addConfigModifier(
[&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void { ConfigHelper::setConnectConfig(hcm, false, false); });
config_helper_.addFilter(compressorFilterConfig);
config_helper_.prependFilter(compressorFilterConfig);
HttpProtocolIntegrationTest::initialize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CorsFilterIntegrationTest : public testing::TestWithParam<Network::Address
CorsFilterIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, GetParam()) {}

void initialize() override {
config_helper_.addFilter("name: envoy.filters.http.cors");
config_helper_.prependFilter("name: envoy.filters.http.cors");
config_helper_.addConfigModifier(
[&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void {
Expand Down
22 changes: 11 additions & 11 deletions test/extensions/filters/http/csrf/csrf_filter_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ INSTANTIATE_TEST_SUITE_P(Protocols, CsrfFilterIntegrationTest,
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(CsrfFilterIntegrationTest, TestCsrfSuccess) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "PUT"},
{":path", "/"},
Expand All @@ -93,7 +93,7 @@ TEST_P(CsrfFilterIntegrationTest, TestCsrfSuccess) {
}

TEST_P(CsrfFilterIntegrationTest, TestCsrfDisabled) {
config_helper_.addFilter(CSRF_DISABLED_CONFIG);
config_helper_.prependFilter(CSRF_DISABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "PUT"},
{":path", "/"},
Expand All @@ -107,7 +107,7 @@ TEST_P(CsrfFilterIntegrationTest, TestCsrfDisabled) {
}

TEST_P(CsrfFilterIntegrationTest, TestNonMutationMethod) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "GET"},
{":path", "/"},
Expand All @@ -121,7 +121,7 @@ TEST_P(CsrfFilterIntegrationTest, TestNonMutationMethod) {
}

TEST_P(CsrfFilterIntegrationTest, TestOriginMismatch) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "PUT"},
{":path", "/"},
Expand All @@ -135,7 +135,7 @@ TEST_P(CsrfFilterIntegrationTest, TestOriginMismatch) {
}

TEST_P(CsrfFilterIntegrationTest, TestEnforcesPost) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "POST"},
{":path", "/"},
Expand All @@ -149,7 +149,7 @@ TEST_P(CsrfFilterIntegrationTest, TestEnforcesPost) {
}

TEST_P(CsrfFilterIntegrationTest, TestEnforcesDelete) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "DELETE"},
{":path", "/"},
Expand All @@ -163,7 +163,7 @@ TEST_P(CsrfFilterIntegrationTest, TestEnforcesDelete) {
}

TEST_P(CsrfFilterIntegrationTest, TestEnforcesPatch) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "PATCH"},
{":path", "/"},
Expand All @@ -177,7 +177,7 @@ TEST_P(CsrfFilterIntegrationTest, TestEnforcesPatch) {
}

TEST_P(CsrfFilterIntegrationTest, TestRefererFallback) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{":method", "DELETE"},
{":path", "/"},
{":scheme", "http"},
Expand All @@ -189,7 +189,7 @@ TEST_P(CsrfFilterIntegrationTest, TestRefererFallback) {
}

TEST_P(CsrfFilterIntegrationTest, TestMissingOrigin) {
config_helper_.addFilter(CSRF_FILTER_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {
{{":method", "DELETE"}, {":path", "/"}, {":scheme", "http"}, {"host", "test-origin"}}};
const auto& response = sendRequest(headers);
Expand All @@ -198,7 +198,7 @@ TEST_P(CsrfFilterIntegrationTest, TestMissingOrigin) {
}

TEST_P(CsrfFilterIntegrationTest, TestShadowOnlyMode) {
config_helper_.addFilter(CSRF_SHADOW_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_SHADOW_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "PUT"},
{":path", "/"},
Expand All @@ -212,7 +212,7 @@ TEST_P(CsrfFilterIntegrationTest, TestShadowOnlyMode) {
}

TEST_P(CsrfFilterIntegrationTest, TestFilterAndShadowEnabled) {
config_helper_.addFilter(CSRF_ENABLED_CONFIG);
config_helper_.prependFilter(CSRF_ENABLED_CONFIG);
Http::TestRequestHeaderMapImpl headers = {{
{":method", "PUT"},
{":path", "/"},
Expand Down
Loading