Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fuzz] fix h1 end to end fuzz test issue #15318

Merged
merged 4 commits into from
Mar 8, 2021
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
7 changes: 4 additions & 3 deletions test/integration/h1_capture_direct_response_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ namespace Envoy {

void H1FuzzIntegrationTest::initialize() {
const std::string body = "Response body";
const std::string file_path = TestEnvironment::writeStringToFileForTest("test_envoy", body);
const std::string prefix("/");
const Http::Code status(Http::Code::OK);
config_helper_.addConfigModifier(
[&file_path, &prefix](
[&body, &prefix](
envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void {
auto* route_config = hcm.mutable_route_config();
Expand All @@ -19,7 +18,9 @@ void H1FuzzIntegrationTest::initialize() {
hcm.mutable_route_config()->mutable_virtual_hosts(0)->mutable_routes(0);
default_route->mutable_match()->set_prefix(prefix);
default_route->mutable_direct_response()->set_status(static_cast<uint32_t>(status));
default_route->mutable_direct_response()->mutable_body()->set_filename(file_path);
// Use inline bytes rather than a filename to avoid using a path that may look illegal to
// Envoy.
default_route->mutable_direct_response()->mutable_body()->set_inline_bytes(body);
// adding headers to the default route
auto* header_value_option = route_config->mutable_response_headers_to_add()->Add();
header_value_option->mutable_header()->set_value("direct-response-enabled");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions test/integration/h2_capture_direct_response_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ namespace Envoy {

void H2FuzzIntegrationTest::initialize() {
const std::string body = "Response body";
const std::string file_path = TestEnvironment::writeStringToFileForTest("test_envoy", body);
const std::string prefix("/");
const Http::Code status(Http::Code::OK);

setDownstreamProtocol(Http::CodecClient::Type::HTTP2);
setUpstreamProtocol(FakeHttpConnection::Type::HTTP2);

config_helper_.addConfigModifier(
[&file_path, &prefix](
[&body, &prefix](
envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void {
auto* route_config = hcm.mutable_route_config();
Expand All @@ -23,7 +22,9 @@ void H2FuzzIntegrationTest::initialize() {
hcm.mutable_route_config()->mutable_virtual_hosts(0)->mutable_routes(0);
default_route->mutable_match()->set_prefix(prefix);
default_route->mutable_direct_response()->set_status(static_cast<uint32_t>(status));
default_route->mutable_direct_response()->mutable_body()->set_filename(file_path);
// Use inline bytes rather than a filename to avoid using a path that may look illegal to
// Envoy.
default_route->mutable_direct_response()->mutable_body()->set_inline_bytes(body);
// adding headers to the default route
auto* header_value_option = route_config->mutable_response_headers_to_add()->Add();
header_value_option->mutable_header()->set_value("direct-response-enabled");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.