Skip to content

Commit

Permalink
ext_proc: add integration test to verify host header can be added (en…
Browse files Browse the repository at this point in the history
…voyproxy#29886)

Adding an ext_proc integration test to verify with allow_envoy and allow_all_routing enabled in the ext_proc filter configure, the host header can be modified and x-envoy-xxxx header can be added.

This is to address: envoyproxy#29573

Risk Level: low, test only
Testing: new unit test
Docs Changes: n/a
Release Notes: n/a
Signed-off-by: Yanjun Xiang <[email protected]>
  • Loading branch information
yanjunxiang-google authored Oct 2, 2023
1 parent 1eb64ee commit 8e79b66
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,29 @@ TEST_P(ExtProcIntegrationTest, GetAndRespondImmediatelyWithEnvoyHeaderMutation)
EXPECT_THAT(response->headers(), HasNoHeader("x-envoy-foo"));
}

TEST_P(ExtProcIntegrationTest, GetAndImmediateRespondMutationAllowEnvoy) {
filter_mutation_rule_ = "true";
proto_config_.mutable_mutation_rules()->mutable_allow_envoy()->set_value(true);
proto_config_.mutable_mutation_rules()->mutable_allow_all_routing()->set_value(true);

initializeConfig();
HttpIntegrationTest::initialize();
auto response = sendDownstreamRequest(absl::nullopt);
processAndRespondImmediately(*grpc_upstreams_[0], true, [](ImmediateResponse& immediate) {
immediate.mutable_status()->set_code(envoy::type::v3::StatusCode::Unauthorized);
auto* hdr = immediate.mutable_headers()->add_set_headers();
hdr->mutable_header()->set_key("x-envoy-foo");
hdr->mutable_header()->set_value("bar");
auto* hdr1 = immediate.mutable_headers()->add_set_headers();
hdr1->mutable_header()->set_key("host");
hdr1->mutable_header()->set_value("test");
});

verifyDownstreamResponse(*response, 401);
EXPECT_THAT(response->headers(), SingleHeaderValueIs("host", "test"));
EXPECT_THAT(response->headers(), SingleHeaderValueIs("x-envoy-foo", "bar"));
}

// Test the filter with request body buffering enabled using
// an ext_proc server that responds to the request_body message
// by modifying a header that should cause an error.
Expand Down

0 comments on commit 8e79b66

Please sign in to comment.