From 0f08b73eb8894ea4f9ca9cc279545a2e63fee968 Mon Sep 17 00:00:00 2001 From: caschoener Date: Wed, 3 Aug 2022 17:10:14 +0000 Subject: [PATCH 01/11] uno Signed-off-by: caschoener dos Signed-off-by: caschoener --- library/common/http/header_utility.cc | 8 ++-- .../base_client_integration_test.cc | 24 +++++++++-- .../base_client_integration_test.h | 3 +- .../integration/client_integration_test.cc | 43 +++++++++++++++---- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/library/common/http/header_utility.cc b/library/common/http/header_utility.cc index 0a183d9751..99d689e51c 100644 --- a/library/common/http/header_utility.cc +++ b/library/common/http/header_utility.cc @@ -9,14 +9,14 @@ namespace Envoy { namespace Http { namespace Utility { -void toEnvoyHeaders(HeaderMap& transformed_headers, envoy_headers headers) { - Envoy::Http::StatefulHeaderKeyFormatter& formatter = transformed_headers.formatter().value(); +void toEnvoyHeaders(HeaderMap& envoy_result_headers, envoy_headers headers) { + Envoy::Http::StatefulHeaderKeyFormatter& formatter = envoy_result_headers.formatter().value(); for (envoy_map_size_t i = 0; i < headers.length; i++) { std::string key = Data::Utility::copyToString(headers.entries[i].key); // Make sure the formatter knows the original case. formatter.processKey(key); - transformed_headers.addCopy(LowerCaseString(key), - Data::Utility::copyToString(headers.entries[i].value)); + envoy_result_headers.addCopy(LowerCaseString(key), + Data::Utility::copyToString(headers.entries[i].value)); } // The C envoy_headers struct can be released now because the headers have been copied. release_envoy_headers(headers); diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 181f564895..ab6eb1fd0e 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -1,7 +1,9 @@ #include "test/common/integration/base_client_integration_test.h" #include "gtest/gtest.h" +#include "library/cc/bridge_utility.h" #include "library/common/config/internal.h" +#include "library/common/http/header_utility.h" namespace Envoy { namespace { @@ -90,16 +92,30 @@ void BaseClientIntegrationTest::initialize() { stream_ = (*stream_prototype_).start(explicit_flow_control_); std::string host(fake_upstreams_[0]->localAddress()->asStringView()); Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); - for (auto& entry : custom_headers_) { - auto values = {entry.second}; - builder.set(entry.first, values); - } if (upstreamProtocol() == Http::CodecType::HTTP2) { builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); } default_request_headers_ = std::make_shared(builder.build()); } +std::shared_ptr +BaseClientIntegrationTest::envoyToMobileHeaders(Http::TestRequestHeaderMapImpl request_headers) { + std::string host(fake_upstreams_[0]->localAddress()->asStringView()); + + envoy_headers eh = Http::Utility::toBridgeHeaders(request_headers); + Platform::RawHeaderMap rhm = Platform::envoyHeadersAsRawHeaderMap(eh); + + Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); + for (const auto& pair : rhm) { + builder.set(pair.first, pair.second); + } + if (upstreamProtocol() == Http::CodecType::HTTP2) { + builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); + } + auto mobile_headers = std::make_shared(builder.build()); + return mobile_headers; +} + void BaseClientIntegrationTest::threadRoutine(absl::Notification& engine_running) { setOnEngineRunning([&]() { engine_running.Notify(); }); engine_ = build(); diff --git a/test/common/integration/base_client_integration_test.h b/test/common/integration/base_client_integration_test.h index edca516ad5..c288dcfe42 100644 --- a/test/common/integration/base_client_integration_test.h +++ b/test/common/integration/base_client_integration_test.h @@ -44,13 +44,14 @@ class BaseClientIntegrationTest : public BaseIntegrationTest, public Platform::E void threadRoutine(absl::Notification& engine_running); // Must be called manually by subclasses in their TearDown(); void TearDown(); + std::shared_ptr + envoyToMobileHeaders(Http::TestRequestHeaderMapImpl request_headers); Event::ProvisionalDispatcherPtr dispatcher_ = std::make_unique(); envoy_http_callbacks bridge_callbacks_; ConditionalInitializer terminal_callback_; callbacks_called cc_{0, 0, 0, 0, 0, 0, 0, "", &terminal_callback_, {}}; std::shared_ptr default_request_headers_; - absl::flat_hash_map custom_headers_; Event::DispatcherPtr full_dispatcher_; Platform::StreamPrototypeSharedPtr stream_prototype_; Platform::StreamSharedPtr stream_; diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index 4a22f50472..32c775fcde 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -1,6 +1,7 @@ #include "source/extensions/http/header_formatters/preserve_case/config.h" #include "source/extensions/http/header_formatters/preserve_case/preserve_case_formatter.h" +#include "test/common/http/common.h" #include "test/common/integration/base_client_integration_test.h" #include "test/integration/autonomous_upstream.h" @@ -39,11 +40,16 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, ClientIntegrationTest, TestUtility::ipTestParamsToString); TEST_P(ClientIntegrationTest, Basic) { - Buffer::OwnedImpl request_data = Buffer::OwnedImpl("request body"); - custom_headers_.emplace(AutonomousStream::EXPECT_REQUEST_SIZE_BYTES, - std::to_string(request_data.length())); initialize(); + Buffer::OwnedImpl request_data = Buffer::OwnedImpl("request body"); + Http::TestRequestHeaderMapImpl custom_headers; + HttpTestUtility::addDefaultHeaders(custom_headers); + custom_headers.addCopy(AutonomousStream::EXPECT_REQUEST_SIZE_BYTES, + std::to_string(request_data.length())); + std::shared_ptr custom_request_headers = + envoyToMobileHeaders(custom_headers); + stream_prototype_->setOnData([this](envoy_data c_data, bool end_stream) { if (end_stream) { EXPECT_EQ(Data::Utility::copyToString(c_data), ""); @@ -54,7 +60,7 @@ TEST_P(ClientIntegrationTest, Basic) { release_envoy_data(c_data); }); - stream_->sendHeaders(default_request_headers_, false); + stream_->sendHeaders(custom_request_headers, false); envoy_data c_data = Data::Utility::toBridgeData(request_data); stream_->sendData(c_data); @@ -92,10 +98,15 @@ TEST_P(ClientIntegrationTest, BasicNon2xx) { } TEST_P(ClientIntegrationTest, BasicReset) { - custom_headers_.emplace(AutonomousStream::RESET_AFTER_REQUEST, "yes"); initialize(); - stream_->sendHeaders(default_request_headers_, true); + Http::TestRequestHeaderMapImpl custom_headers; + HttpTestUtility::addDefaultHeaders(custom_headers); + custom_headers.addCopy(AutonomousStream::RESET_AFTER_REQUEST, "yes"); + std::shared_ptr custom_request_headers = + envoyToMobileHeaders(custom_headers); + + stream_->sendHeaders(custom_request_headers, true); terminal_callback_.waitReady(); ASSERT_EQ(cc_.on_error_calls, 1); @@ -198,10 +209,23 @@ TEST_P(ClientIntegrationTest, CancelWithPartialStream) { // Test header key case sensitivity. TEST_P(ClientIntegrationTest, CaseSensitive) { - custom_headers_.emplace("FoO", "bar"); autonomous_upstream_ = false; initialize(); + Http::TestRequestHeaderMapImpl custom_headers; + HttpTestUtility::addDefaultHeaders(custom_headers); + custom_headers.header_map_->setFormatter( + std::make_unique< + Extensions::Http::HeaderFormatters::PreserveCase::PreserveCaseHeaderFormatter>( + false, envoy::extensions::http::header_formatters::preserve_case::v3:: + PreserveCaseFormatterConfig::DEFAULT)); + + custom_headers.addCopy("FoO", "bar"); + custom_headers.header_map_->formatter().value().get().processKey("FoO"); + + std::shared_ptr custom_request_headers = + envoyToMobileHeaders(custom_headers); + stream_prototype_->setOnHeaders( [this](Platform::ResponseHeadersSharedPtr headers, bool, envoy_stream_intel) { cc_.status = absl::StrCat(headers->httpStatus()); @@ -211,7 +235,7 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { return nullptr; }); - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(custom_request_headers, true); Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); @@ -220,6 +244,9 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { std::string upstream_request; EXPECT_TRUE(upstream_connection->waitForData(FakeRawConnection::waitForInexactMatch("GET /"), &upstream_request)); + + std::cout << "debug1"; + std::cout << upstream_request; EXPECT_TRUE(absl::StrContains(upstream_request, "FoO: bar")) << upstream_request; // Send mixed case headers, and verify via setOnHeaders they are received correctly. From bbb24fd0f9200014993397ad5b900325dce3c3d1 Mon Sep 17 00:00:00 2001 From: caschoener Date: Wed, 3 Aug 2022 20:42:43 +0000 Subject: [PATCH 02/11] remove debug Signed-off-by: caschoener --- test/common/integration/client_integration_test.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index 32c775fcde..21709471e3 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -245,8 +245,6 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { EXPECT_TRUE(upstream_connection->waitForData(FakeRawConnection::waitForInexactMatch("GET /"), &upstream_request)); - std::cout << "debug1"; - std::cout << upstream_request; EXPECT_TRUE(absl::StrContains(upstream_request, "FoO: bar")) << upstream_request; // Send mixed case headers, and verify via setOnHeaders they are received correctly. From d7f31d3356bb73e762ce62133bb900bf7860bb43 Mon Sep 17 00:00:00 2001 From: caschoener Date: Wed, 3 Aug 2022 22:34:04 +0000 Subject: [PATCH 03/11] add indirection to make tests pass Signed-off-by: caschoener --- library/cc/bridge_utility.cc | 2 +- library/common/http/header_utility.cc | 3 +-- .../base_client_integration_test.cc | 8 +++---- .../base_client_integration_test.h | 2 +- .../integration/client_integration_test.cc | 22 ++++++++++++++++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/library/cc/bridge_utility.cc b/library/cc/bridge_utility.cc index d5ba013efc..e013f5b217 100644 --- a/library/cc/bridge_utility.cc +++ b/library/cc/bridge_utility.cc @@ -1,5 +1,6 @@ #include "bridge_utility.h" +#include #include #include "library/common/data/utility.h" @@ -38,7 +39,6 @@ RawHeaderMap envoyHeadersAsRawHeaderMap(envoy_headers raw_headers) { for (auto i = 0; i < raw_headers.length; i++) { auto key = Data::Utility::copyToString(raw_headers.entries[i].key); auto value = Data::Utility::copyToString(raw_headers.entries[i].value); - if (!headers.contains(key)) { headers.emplace(key, std::vector()); } diff --git a/library/common/http/header_utility.cc b/library/common/http/header_utility.cc index 99d689e51c..b0e245d821 100644 --- a/library/common/http/header_utility.cc +++ b/library/common/http/header_utility.cc @@ -52,7 +52,7 @@ envoy_headers toBridgeHeaders(const HeaderMap& header_map, absl::string_view alp envoy_headers transformed_headers; transformed_headers.length = 0; transformed_headers.entries = headers; - + header_map.iterate( [&transformed_headers, &header_map](const HeaderEntry& header) -> HeaderMap::Iterate { std::string key_val = std::string(header.key().getStringView()); @@ -62,7 +62,6 @@ envoy_headers toBridgeHeaders(const HeaderMap& header_map, absl::string_view alp } envoy_data key = Data::Utility::copyToBridgeData(key_val); envoy_data value = Data::Utility::copyToBridgeData(header.value().getStringView()); - transformed_headers.entries[transformed_headers.length] = {key, value}; transformed_headers.length++; diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index ab6eb1fd0e..b5ccf170fa 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -99,14 +99,14 @@ void BaseClientIntegrationTest::initialize() { } std::shared_ptr -BaseClientIntegrationTest::envoyToMobileHeaders(Http::TestRequestHeaderMapImpl request_headers) { +BaseClientIntegrationTest::envoyToMobileHeaders(Http::TestRequestHeaderMapImpl *request_headers) { std::string host(fake_upstreams_[0]->localAddress()->asStringView()); - envoy_headers eh = Http::Utility::toBridgeHeaders(request_headers); - Platform::RawHeaderMap rhm = Platform::envoyHeadersAsRawHeaderMap(eh); + envoy_headers envoyHeaders = Http::Utility::toBridgeHeaders(*request_headers); + Platform::RawHeaderMap rawHeaderMap = Platform::envoyHeadersAsRawHeaderMap(envoyHeaders); Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); - for (const auto& pair : rhm) { + for (const auto& pair : rawHeaderMap) { builder.set(pair.first, pair.second); } if (upstreamProtocol() == Http::CodecType::HTTP2) { diff --git a/test/common/integration/base_client_integration_test.h b/test/common/integration/base_client_integration_test.h index c288dcfe42..bd74faebb0 100644 --- a/test/common/integration/base_client_integration_test.h +++ b/test/common/integration/base_client_integration_test.h @@ -45,7 +45,7 @@ class BaseClientIntegrationTest : public BaseIntegrationTest, public Platform::E // Must be called manually by subclasses in their TearDown(); void TearDown(); std::shared_ptr - envoyToMobileHeaders(Http::TestRequestHeaderMapImpl request_headers); + envoyToMobileHeaders(Http::TestRequestHeaderMapImpl *request_headers); Event::ProvisionalDispatcherPtr dispatcher_ = std::make_unique(); envoy_http_callbacks bridge_callbacks_; diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index 21709471e3..d54c278e59 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -48,7 +48,7 @@ TEST_P(ClientIntegrationTest, Basic) { custom_headers.addCopy(AutonomousStream::EXPECT_REQUEST_SIZE_BYTES, std::to_string(request_data.length())); std::shared_ptr custom_request_headers = - envoyToMobileHeaders(custom_headers); + envoyToMobileHeaders(&custom_headers); stream_prototype_->setOnData([this](envoy_data c_data, bool end_stream) { if (end_stream) { @@ -104,7 +104,7 @@ TEST_P(ClientIntegrationTest, BasicReset) { HttpTestUtility::addDefaultHeaders(custom_headers); custom_headers.addCopy(AutonomousStream::RESET_AFTER_REQUEST, "yes"); std::shared_ptr custom_request_headers = - envoyToMobileHeaders(custom_headers); + envoyToMobileHeaders(&custom_headers); stream_->sendHeaders(custom_request_headers, true); terminal_callback_.waitReady(); @@ -210,10 +210,26 @@ TEST_P(ClientIntegrationTest, CancelWithPartialStream) { // Test header key case sensitivity. TEST_P(ClientIntegrationTest, CaseSensitive) { autonomous_upstream_ = false; + Envoy::Extensions::Http::HeaderFormatters::PreserveCase:: + forceRegisterPreserveCaseFormatterFactoryConfig(); + config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { + ConfigHelper::HttpProtocolOptions protocol_options; + auto typed_extension_config = protocol_options.mutable_explicit_http_config() + ->mutable_http_protocol_options() + ->mutable_header_key_format() + ->mutable_stateful_formatter(); + typed_extension_config->set_name("preserve_case"); + typed_extension_config->mutable_typed_config()->set_type_url( + "type.googleapis.com/" + "envoy.extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig"); + ConfigHelper::setProtocolOptions(*bootstrap.mutable_static_resources()->mutable_clusters(0), + protocol_options); + }); initialize(); Http::TestRequestHeaderMapImpl custom_headers; HttpTestUtility::addDefaultHeaders(custom_headers); + custom_headers.header_map_->setFormatter( std::make_unique< Extensions::Http::HeaderFormatters::PreserveCase::PreserveCaseHeaderFormatter>( @@ -224,7 +240,7 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { custom_headers.header_map_->formatter().value().get().processKey("FoO"); std::shared_ptr custom_request_headers = - envoyToMobileHeaders(custom_headers); + envoyToMobileHeaders(&custom_headers); stream_prototype_->setOnHeaders( [this](Platform::ResponseHeadersSharedPtr headers, bool, envoy_stream_intel) { From 3ac0389587de69562d8b00e4cedaff36b8ce2883 Mon Sep 17 00:00:00 2001 From: caschoener Date: Wed, 3 Aug 2022 22:45:04 +0000 Subject: [PATCH 04/11] format again Signed-off-by: caschoener --- library/common/http/header_utility.cc | 2 +- test/common/integration/base_client_integration_test.cc | 2 +- test/common/integration/base_client_integration_test.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/common/http/header_utility.cc b/library/common/http/header_utility.cc index b0e245d821..ffbafaf158 100644 --- a/library/common/http/header_utility.cc +++ b/library/common/http/header_utility.cc @@ -52,7 +52,7 @@ envoy_headers toBridgeHeaders(const HeaderMap& header_map, absl::string_view alp envoy_headers transformed_headers; transformed_headers.length = 0; transformed_headers.entries = headers; - + header_map.iterate( [&transformed_headers, &header_map](const HeaderEntry& header) -> HeaderMap::Iterate { std::string key_val = std::string(header.key().getStringView()); diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index b5ccf170fa..659e955328 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -99,7 +99,7 @@ void BaseClientIntegrationTest::initialize() { } std::shared_ptr -BaseClientIntegrationTest::envoyToMobileHeaders(Http::TestRequestHeaderMapImpl *request_headers) { +BaseClientIntegrationTest::envoyToMobileHeaders(Http::TestRequestHeaderMapImpl* request_headers) { std::string host(fake_upstreams_[0]->localAddress()->asStringView()); envoy_headers envoyHeaders = Http::Utility::toBridgeHeaders(*request_headers); diff --git a/test/common/integration/base_client_integration_test.h b/test/common/integration/base_client_integration_test.h index bd74faebb0..1345509ae3 100644 --- a/test/common/integration/base_client_integration_test.h +++ b/test/common/integration/base_client_integration_test.h @@ -45,7 +45,7 @@ class BaseClientIntegrationTest : public BaseIntegrationTest, public Platform::E // Must be called manually by subclasses in their TearDown(); void TearDown(); std::shared_ptr - envoyToMobileHeaders(Http::TestRequestHeaderMapImpl *request_headers); + envoyToMobileHeaders(Http::TestRequestHeaderMapImpl* request_headers); Event::ProvisionalDispatcherPtr dispatcher_ = std::make_unique(); envoy_http_callbacks bridge_callbacks_; From fe86f651317a5a70d3ca5daba7fda39f50c7f239 Mon Sep 17 00:00:00 2001 From: caschoener Date: Wed, 3 Aug 2022 22:51:20 +0000 Subject: [PATCH 05/11] pass by reference Signed-off-by: caschoener --- test/common/integration/base_client_integration_test.cc | 6 +++--- test/common/integration/base_client_integration_test.h | 2 +- test/common/integration/client_integration_test.cc | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 659e955328..7d4627ecf2 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -98,11 +98,11 @@ void BaseClientIntegrationTest::initialize() { default_request_headers_ = std::make_shared(builder.build()); } -std::shared_ptr -BaseClientIntegrationTest::envoyToMobileHeaders(Http::TestRequestHeaderMapImpl* request_headers) { +std::shared_ptr BaseClientIntegrationTest::envoyToMobileHeaders( + const Http::TestRequestHeaderMapImpl& request_headers) { std::string host(fake_upstreams_[0]->localAddress()->asStringView()); - envoy_headers envoyHeaders = Http::Utility::toBridgeHeaders(*request_headers); + envoy_headers envoyHeaders = Http::Utility::toBridgeHeaders(request_headers); Platform::RawHeaderMap rawHeaderMap = Platform::envoyHeadersAsRawHeaderMap(envoyHeaders); Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); diff --git a/test/common/integration/base_client_integration_test.h b/test/common/integration/base_client_integration_test.h index 1345509ae3..8d77f8e087 100644 --- a/test/common/integration/base_client_integration_test.h +++ b/test/common/integration/base_client_integration_test.h @@ -45,7 +45,7 @@ class BaseClientIntegrationTest : public BaseIntegrationTest, public Platform::E // Must be called manually by subclasses in their TearDown(); void TearDown(); std::shared_ptr - envoyToMobileHeaders(Http::TestRequestHeaderMapImpl* request_headers); + envoyToMobileHeaders(const Http::TestRequestHeaderMapImpl& request_headers); Event::ProvisionalDispatcherPtr dispatcher_ = std::make_unique(); envoy_http_callbacks bridge_callbacks_; diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index d54c278e59..3c57ad44cd 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -48,7 +48,7 @@ TEST_P(ClientIntegrationTest, Basic) { custom_headers.addCopy(AutonomousStream::EXPECT_REQUEST_SIZE_BYTES, std::to_string(request_data.length())); std::shared_ptr custom_request_headers = - envoyToMobileHeaders(&custom_headers); + envoyToMobileHeaders(custom_headers); stream_prototype_->setOnData([this](envoy_data c_data, bool end_stream) { if (end_stream) { @@ -104,7 +104,7 @@ TEST_P(ClientIntegrationTest, BasicReset) { HttpTestUtility::addDefaultHeaders(custom_headers); custom_headers.addCopy(AutonomousStream::RESET_AFTER_REQUEST, "yes"); std::shared_ptr custom_request_headers = - envoyToMobileHeaders(&custom_headers); + envoyToMobileHeaders(custom_headers); stream_->sendHeaders(custom_request_headers, true); terminal_callback_.waitReady(); @@ -240,7 +240,7 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { custom_headers.header_map_->formatter().value().get().processKey("FoO"); std::shared_ptr custom_request_headers = - envoyToMobileHeaders(&custom_headers); + envoyToMobileHeaders(custom_headers); stream_prototype_->setOnHeaders( [this](Platform::ResponseHeadersSharedPtr headers, bool, envoy_stream_intel) { From defc626838b09df82c0dbb8be4586051a2cc7d08 Mon Sep 17 00:00:00 2001 From: caschoener Date: Thu, 4 Aug 2022 16:49:05 +0000 Subject: [PATCH 06/11] Change default_headers to impl Signed-off-by: caschoener --- library/cc/bridge_utility.cc | 2 +- .../base_client_integration_test.cc | 22 +++++----- .../base_client_integration_test.h | 7 ++- .../integration/client_integration_test.cc | 43 ++++++------------- .../integration/rtds_integration_test.cc | 4 +- .../integration/sds_integration_test.cc | 2 +- .../integration/xds_integration_test.cc | 6 ++- .../common/integration/xds_integration_test.h | 1 + 8 files changed, 39 insertions(+), 48 deletions(-) diff --git a/library/cc/bridge_utility.cc b/library/cc/bridge_utility.cc index e013f5b217..d5ba013efc 100644 --- a/library/cc/bridge_utility.cc +++ b/library/cc/bridge_utility.cc @@ -1,6 +1,5 @@ #include "bridge_utility.h" -#include #include #include "library/common/data/utility.h" @@ -39,6 +38,7 @@ RawHeaderMap envoyHeadersAsRawHeaderMap(envoy_headers raw_headers) { for (auto i = 0; i < raw_headers.length; i++) { auto key = Data::Utility::copyToString(raw_headers.entries[i].key); auto value = Data::Utility::copyToString(raw_headers.entries[i].value); + if (!headers.contains(key)) { headers.emplace(key, std::vector()); } diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 7d4627ecf2..6c190c45d4 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -1,5 +1,7 @@ #include "test/common/integration/base_client_integration_test.h" +#include "test/common/http/common.h" + #include "gtest/gtest.h" #include "library/cc/bridge_utility.h" #include "library/common/config/internal.h" @@ -91,27 +93,27 @@ void BaseClientIntegrationTest::initialize() { stream_ = (*stream_prototype_).start(explicit_flow_control_); std::string host(fake_upstreams_[0]->localAddress()->asStringView()); - Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); - if (upstreamProtocol() == Http::CodecType::HTTP2) { - builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); - } - default_request_headers_ = std::make_shared(builder.build()); + default_request_headers_ = {}; + HttpTestUtility::addDefaultHeaders(default_request_headers_); + default_request_headers_.setHost(fake_upstreams_[0]->localAddress()->asStringView()); } std::shared_ptr BaseClientIntegrationTest::envoyToMobileHeaders( const Http::TestRequestHeaderMapImpl& request_headers) { - std::string host(fake_upstreams_[0]->localAddress()->asStringView()); envoy_headers envoyHeaders = Http::Utility::toBridgeHeaders(request_headers); Platform::RawHeaderMap rawHeaderMap = Platform::envoyHeadersAsRawHeaderMap(envoyHeaders); - Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); - for (const auto& pair : rawHeaderMap) { - builder.set(pair.first, pair.second); - } + Platform::RequestHeadersBuilder builder( + Platform::RequestMethod::GET, + std::string(default_request_headers_.Scheme()->value().getStringView()), + std::string(default_request_headers_.Host()->value().getStringView()), "/"); if (upstreamProtocol() == Http::CodecType::HTTP2) { builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); } + for (const auto& pair : rawHeaderMap) { + builder.set(pair.first, pair.second); + } auto mobile_headers = std::make_shared(builder.build()); return mobile_headers; } diff --git a/test/common/integration/base_client_integration_test.h b/test/common/integration/base_client_integration_test.h index 8d77f8e087..4e5cf5293a 100644 --- a/test/common/integration/base_client_integration_test.h +++ b/test/common/integration/base_client_integration_test.h @@ -44,20 +44,19 @@ class BaseClientIntegrationTest : public BaseIntegrationTest, public Platform::E void threadRoutine(absl::Notification& engine_running); // Must be called manually by subclasses in their TearDown(); void TearDown(); - std::shared_ptr + // Converts TestRequestHeaderMapImpl to Envoy::Platform::RequestHeadersSharedPtr + Envoy::Platform::RequestHeadersSharedPtr envoyToMobileHeaders(const Http::TestRequestHeaderMapImpl& request_headers); - Event::ProvisionalDispatcherPtr dispatcher_ = std::make_unique(); envoy_http_callbacks bridge_callbacks_; ConditionalInitializer terminal_callback_; callbacks_called cc_{0, 0, 0, 0, 0, 0, 0, "", &terminal_callback_, {}}; - std::shared_ptr default_request_headers_; + Http::TestRequestHeaderMapImpl default_request_headers_; Event::DispatcherPtr full_dispatcher_; Platform::StreamPrototypeSharedPtr stream_prototype_; Platform::StreamSharedPtr stream_; Platform::EngineSharedPtr engine_; Thread::ThreadPtr envoy_thread_; - std::string scheme_ = "http"; bool explicit_flow_control_ = false; bool expect_dns_ = true; bool override_builder_config_ = false; diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index 3c57ad44cd..bbc566eeb9 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -43,12 +43,8 @@ TEST_P(ClientIntegrationTest, Basic) { initialize(); Buffer::OwnedImpl request_data = Buffer::OwnedImpl("request body"); - Http::TestRequestHeaderMapImpl custom_headers; - HttpTestUtility::addDefaultHeaders(custom_headers); - custom_headers.addCopy(AutonomousStream::EXPECT_REQUEST_SIZE_BYTES, - std::to_string(request_data.length())); - std::shared_ptr custom_request_headers = - envoyToMobileHeaders(custom_headers); + default_request_headers_.addCopy(AutonomousStream::EXPECT_REQUEST_SIZE_BYTES, + std::to_string(request_data.length())); stream_prototype_->setOnData([this](envoy_data c_data, bool end_stream) { if (end_stream) { @@ -60,7 +56,7 @@ TEST_P(ClientIntegrationTest, Basic) { release_envoy_data(c_data); }); - stream_->sendHeaders(custom_request_headers, false); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), false); envoy_data c_data = Data::Utility::toBridgeData(request_data); stream_->sendData(c_data); @@ -88,7 +84,7 @@ TEST_P(ClientIntegrationTest, BasicNon2xx) { ->setResponseHeaders(std::make_unique( Http::TestResponseHeaderMapImpl({{":status", "503"}, {"content-length", "0"}}))); - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); terminal_callback_.waitReady(); ASSERT_EQ(cc_.on_error_calls, 0); @@ -100,13 +96,9 @@ TEST_P(ClientIntegrationTest, BasicNon2xx) { TEST_P(ClientIntegrationTest, BasicReset) { initialize(); - Http::TestRequestHeaderMapImpl custom_headers; - HttpTestUtility::addDefaultHeaders(custom_headers); - custom_headers.addCopy(AutonomousStream::RESET_AFTER_REQUEST, "yes"); - std::shared_ptr custom_request_headers = - envoyToMobileHeaders(custom_headers); + default_request_headers_.addCopy(AutonomousStream::RESET_AFTER_REQUEST, "yes"); - stream_->sendHeaders(custom_request_headers, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); terminal_callback_.waitReady(); ASSERT_EQ(cc_.on_error_calls, 1); @@ -127,7 +119,7 @@ TEST_P(ClientIntegrationTest, BasicCancel) { return nullptr; }); - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); @@ -172,7 +164,7 @@ TEST_P(ClientIntegrationTest, CancelWithPartialStream) { return nullptr; }); - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); @@ -227,20 +219,14 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { }); initialize(); - Http::TestRequestHeaderMapImpl custom_headers; - HttpTestUtility::addDefaultHeaders(custom_headers); - - custom_headers.header_map_->setFormatter( + default_request_headers_.header_map_->setFormatter( std::make_unique< Extensions::Http::HeaderFormatters::PreserveCase::PreserveCaseHeaderFormatter>( false, envoy::extensions::http::header_formatters::preserve_case::v3:: PreserveCaseFormatterConfig::DEFAULT)); - custom_headers.addCopy("FoO", "bar"); - custom_headers.header_map_->formatter().value().get().processKey("FoO"); - - std::shared_ptr custom_request_headers = - envoyToMobileHeaders(custom_headers); + default_request_headers_.addCopy("FoO", "bar"); + default_request_headers_.header_map_->formatter().value().get().processKey("FoO"); stream_prototype_->setOnHeaders( [this](Platform::ResponseHeadersSharedPtr headers, bool, envoy_stream_intel) { @@ -250,8 +236,7 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { EXPECT_TRUE((*headers)["My-ResponsE-Header"][0] == "foo"); return nullptr; }); - - stream_->sendHeaders(custom_request_headers, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); @@ -281,7 +266,7 @@ TEST_P(ClientIntegrationTest, TimeoutOnRequestPath) { autonomous_upstream_ = false; initialize(); - stream_->sendHeaders(default_request_headers_, false); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), false); Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); @@ -302,7 +287,7 @@ TEST_P(ClientIntegrationTest, TimeoutOnResponsePath) { autonomous_upstream_ = false; initialize(); - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); diff --git a/test/common/integration/rtds_integration_test.cc b/test/common/integration/rtds_integration_test.cc index 469b96d4b1..17c90062d7 100644 --- a/test/common/integration/rtds_integration_test.cc +++ b/test/common/integration/rtds_integration_test.cc @@ -52,7 +52,7 @@ class RtdsIntegrationTest : public XdsIntegrationTest { } void initialize() override { - BaseClientIntegrationTest::initialize(); + XdsIntegrationTest::initialize(); initializeXdsStream(); } }; @@ -64,7 +64,7 @@ TEST_P(RtdsIntegrationTest, RtdsReload) { initialize(); // Send a request on the data plane. - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); terminal_callback_.waitReady(); EXPECT_EQ(cc_.on_headers_calls, 1); diff --git a/test/common/integration/sds_integration_test.cc b/test/common/integration/sds_integration_test.cc index bd6bbb3b38..3286de372c 100644 --- a/test/common/integration/sds_integration_test.cc +++ b/test/common/integration/sds_integration_test.cc @@ -95,7 +95,7 @@ TEST_P(SdsIntegrationTest, SdsForUpstreamCluster) { ASSERT_TRUE( waitForCounterGe("cluster.base_h2.client_ssl_socket_factory.ssl_context_update_by_sds", 1)); - stream_->sendHeaders(default_request_headers_, true); + stream_->sendHeaders(envoyToMobileHeaders(default_request_headers_), true); terminal_callback_.waitReady(); EXPECT_EQ(cc_.on_headers_calls, 1); diff --git a/test/common/integration/xds_integration_test.cc b/test/common/integration/xds_integration_test.cc index 7ac78d515c..e05507fb5b 100644 --- a/test/common/integration/xds_integration_test.cc +++ b/test/common/integration/xds_integration_test.cc @@ -22,7 +22,6 @@ XdsIntegrationTest::XdsIntegrationTest() : BaseClientIntegrationTest(ipVersion() expect_dns_ = false; // TODO(alyssawilk) debug. create_xds_upstream_ = true; sotw_or_delta_ = sotwOrDelta(); - scheme_ = "https"; if (sotw_or_delta_ == Grpc::SotwOrDelta::UnifiedSotw || sotw_or_delta_ == Grpc::SotwOrDelta::UnifiedDelta) { @@ -55,6 +54,11 @@ XdsIntegrationTest::XdsIntegrationTest() : BaseClientIntegrationTest(ipVersion() setAdminAddressPathForTests(admin_filename_); } +void XdsIntegrationTest::initialize() { + BaseClientIntegrationTest::initialize(); + default_request_headers_.setScheme("https"); +} + Network::Address::IpVersion XdsIntegrationTest::ipVersion() const { return std::get<0>(GetParam()); } diff --git a/test/common/integration/xds_integration_test.h b/test/common/integration/xds_integration_test.h index 3343dd9ef3..d273d2b016 100644 --- a/test/common/integration/xds_integration_test.h +++ b/test/common/integration/xds_integration_test.h @@ -20,6 +20,7 @@ class XdsIntegrationTest : public BaseClientIntegrationTest, public: XdsIntegrationTest(); virtual ~XdsIntegrationTest() = default; + void initialize() override; protected: void SetUp() override; From a398b4e977aa76a71139227ad13a91091ecd2461 Mon Sep 17 00:00:00 2001 From: caschoener Date: Thu, 4 Aug 2022 18:09:40 +0000 Subject: [PATCH 07/11] conversion function from scratch Signed-off-by: caschoener --- .../base_client_integration_test.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 6c190c45d4..1aebc399c5 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -3,9 +3,12 @@ #include "test/common/http/common.h" #include "gtest/gtest.h" +#include #include "library/cc/bridge_utility.h" #include "library/common/config/internal.h" #include "library/common/http/header_utility.h" +#include "library/common/data/utility.h" +#include "source/common/http/header_map_impl.h" namespace Envoy { namespace { @@ -93,7 +96,6 @@ void BaseClientIntegrationTest::initialize() { stream_ = (*stream_prototype_).start(explicit_flow_control_); std::string host(fake_upstreams_[0]->localAddress()->asStringView()); - default_request_headers_ = {}; HttpTestUtility::addDefaultHeaders(default_request_headers_); default_request_headers_.setHost(fake_upstreams_[0]->localAddress()->asStringView()); } @@ -111,6 +113,21 @@ std::shared_ptr BaseClientIntegrationTest::envoyToMobi if (upstreamProtocol() == Http::CodecType::HTTP2) { builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); } + + request_headers.iterate( + [&request_headers, &builder](const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate { + std::string key_val = std::string(header.key().getStringView()); + if (request_headers.formatter().has_value()) { + const Envoy::Http::StatefulHeaderKeyFormatter& formatter = request_headers.formatter().value(); + key_val = formatter.format(key_val); + } + auto key = std::string(key_val); + auto value = std::vector(); + value.push_back(std::string(header.value().getStringView())); + builder.set(key, value); + return Http::HeaderMap::Iterate::Continue; + }); + for (const auto& pair : rawHeaderMap) { builder.set(pair.first, pair.second); } From fb2276de2f7b9e82fbdeadce89d95c75dc1ed013 Mon Sep 17 00:00:00 2001 From: caschoener Date: Thu, 4 Aug 2022 18:18:23 +0000 Subject: [PATCH 08/11] cleanup Signed-off-by: caschoener --- library/common/http/header_utility.cc | 1 + .../base_client_integration_test.cc | 30 +++++++++---------- .../integration/client_integration_test.cc | 6 ---- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/library/common/http/header_utility.cc b/library/common/http/header_utility.cc index ffbafaf158..2ff51d85a3 100644 --- a/library/common/http/header_utility.cc +++ b/library/common/http/header_utility.cc @@ -62,6 +62,7 @@ envoy_headers toBridgeHeaders(const HeaderMap& header_map, absl::string_view alp } envoy_data key = Data::Utility::copyToBridgeData(key_val); envoy_data value = Data::Utility::copyToBridgeData(header.value().getStringView()); + transformed_headers.entries[transformed_headers.length] = {key, value}; transformed_headers.length++; diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 1aebc399c5..098a0dfddf 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -1,14 +1,13 @@ #include "test/common/integration/base_client_integration_test.h" +#include + #include "test/common/http/common.h" #include "gtest/gtest.h" -#include #include "library/cc/bridge_utility.h" #include "library/common/config/internal.h" #include "library/common/http/header_utility.h" -#include "library/common/data/utility.h" -#include "source/common/http/header_map_impl.h" namespace Envoy { namespace { @@ -115,18 +114,19 @@ std::shared_ptr BaseClientIntegrationTest::envoyToMobi } request_headers.iterate( - [&request_headers, &builder](const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate { - std::string key_val = std::string(header.key().getStringView()); - if (request_headers.formatter().has_value()) { - const Envoy::Http::StatefulHeaderKeyFormatter& formatter = request_headers.formatter().value(); - key_val = formatter.format(key_val); - } - auto key = std::string(key_val); - auto value = std::vector(); - value.push_back(std::string(header.value().getStringView())); - builder.set(key, value); - return Http::HeaderMap::Iterate::Continue; - }); + [&request_headers, &builder](const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate { + std::string key_val = std::string(header.key().getStringView()); + if (request_headers.formatter().has_value()) { + const Envoy::Http::StatefulHeaderKeyFormatter& formatter = + request_headers.formatter().value(); + key_val = formatter.format(key_val); + } + auto key = std::string(key_val); + auto value = std::vector(); + value.push_back(std::string(header.value().getStringView())); + builder.set(key, value); + return Http::HeaderMap::Iterate::Continue; + }); for (const auto& pair : rawHeaderMap) { builder.set(pair.first, pair.second); diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index bbc566eeb9..1ce457a3c9 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -1,15 +1,10 @@ #include "source/extensions/http/header_formatters/preserve_case/config.h" #include "source/extensions/http/header_formatters/preserve_case/preserve_case_formatter.h" -#include "test/common/http/common.h" #include "test/common/integration/base_client_integration_test.h" #include "test/integration/autonomous_upstream.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" #include "library/common/data/utility.h" -#include "library/common/engine.h" -#include "library/common/http/header_utility.h" #include "library/common/types/c_types.h" using testing::ReturnRef; @@ -245,7 +240,6 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { std::string upstream_request; EXPECT_TRUE(upstream_connection->waitForData(FakeRawConnection::waitForInexactMatch("GET /"), &upstream_request)); - EXPECT_TRUE(absl::StrContains(upstream_request, "FoO: bar")) << upstream_request; // Send mixed case headers, and verify via setOnHeaders they are received correctly. From 9e72e3ceb23e9ec9bcbdf61568380241a8a87fc6 Mon Sep 17 00:00:00 2001 From: caschoener Date: Thu, 4 Aug 2022 19:07:20 +0000 Subject: [PATCH 09/11] cleanup 2 Signed-off-by: caschoener --- library/common/http/header_utility.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/common/http/header_utility.cc b/library/common/http/header_utility.cc index 2ff51d85a3..99d689e51c 100644 --- a/library/common/http/header_utility.cc +++ b/library/common/http/header_utility.cc @@ -62,7 +62,7 @@ envoy_headers toBridgeHeaders(const HeaderMap& header_map, absl::string_view alp } envoy_data key = Data::Utility::copyToBridgeData(key_val); envoy_data value = Data::Utility::copyToBridgeData(header.value().getStringView()); - + transformed_headers.entries[transformed_headers.length] = {key, value}; transformed_headers.length++; From 464f0e684b2664b4b64e089513894b1ed78f9b39 Mon Sep 17 00:00:00 2001 From: caschoener Date: Thu, 4 Aug 2022 20:42:22 +0000 Subject: [PATCH 10/11] Address comments Signed-off-by: caschoener --- .../integration/base_client_integration_test.cc | 11 +++++------ .../integration/client_integration_test.cc | 16 ---------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 098a0dfddf..22acc866a7 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -108,20 +108,20 @@ std::shared_ptr BaseClientIntegrationTest::envoyToMobi Platform::RequestHeadersBuilder builder( Platform::RequestMethod::GET, std::string(default_request_headers_.Scheme()->value().getStringView()), - std::string(default_request_headers_.Host()->value().getStringView()), "/"); + std::string(default_request_headers_.Host()->value().getStringView()), + std::string(default_request_headers_.Path()->value().getStringView())); if (upstreamProtocol() == Http::CodecType::HTTP2) { builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); } request_headers.iterate( [&request_headers, &builder](const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate { - std::string key_val = std::string(header.key().getStringView()); + std::string key = std::string(header.key().getStringView()); if (request_headers.formatter().has_value()) { const Envoy::Http::StatefulHeaderKeyFormatter& formatter = request_headers.formatter().value(); - key_val = formatter.format(key_val); + key = formatter.format(key); } - auto key = std::string(key_val); auto value = std::vector(); value.push_back(std::string(header.value().getStringView())); builder.set(key, value); @@ -131,8 +131,7 @@ std::shared_ptr BaseClientIntegrationTest::envoyToMobi for (const auto& pair : rawHeaderMap) { builder.set(pair.first, pair.second); } - auto mobile_headers = std::make_shared(builder.build()); - return mobile_headers; + return std::make_shared(builder.build()); } void BaseClientIntegrationTest::threadRoutine(absl::Notification& engine_running) { diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index 1ce457a3c9..ec249d4781 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -1,4 +1,3 @@ -#include "source/extensions/http/header_formatters/preserve_case/config.h" #include "source/extensions/http/header_formatters/preserve_case/preserve_case_formatter.h" #include "test/common/integration/base_client_integration_test.h" @@ -197,21 +196,6 @@ TEST_P(ClientIntegrationTest, CancelWithPartialStream) { // Test header key case sensitivity. TEST_P(ClientIntegrationTest, CaseSensitive) { autonomous_upstream_ = false; - Envoy::Extensions::Http::HeaderFormatters::PreserveCase:: - forceRegisterPreserveCaseFormatterFactoryConfig(); - config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { - ConfigHelper::HttpProtocolOptions protocol_options; - auto typed_extension_config = protocol_options.mutable_explicit_http_config() - ->mutable_http_protocol_options() - ->mutable_header_key_format() - ->mutable_stateful_formatter(); - typed_extension_config->set_name("preserve_case"); - typed_extension_config->mutable_typed_config()->set_type_url( - "type.googleapis.com/" - "envoy.extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig"); - ConfigHelper::setProtocolOptions(*bootstrap.mutable_static_resources()->mutable_clusters(0), - protocol_options); - }); initialize(); default_request_headers_.header_map_->setFormatter( From 2703f3a77d182b530910018579df97158e5c4f7f Mon Sep 17 00:00:00 2001 From: caschoener Date: Fri, 5 Aug 2022 06:34:01 +0000 Subject: [PATCH 11/11] ali comments Signed-off-by: caschoener --- test/common/integration/base_client_integration_test.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/common/integration/base_client_integration_test.cc b/test/common/integration/base_client_integration_test.cc index 22acc866a7..487b6720f7 100644 --- a/test/common/integration/base_client_integration_test.cc +++ b/test/common/integration/base_client_integration_test.cc @@ -102,9 +102,6 @@ void BaseClientIntegrationTest::initialize() { std::shared_ptr BaseClientIntegrationTest::envoyToMobileHeaders( const Http::TestRequestHeaderMapImpl& request_headers) { - envoy_headers envoyHeaders = Http::Utility::toBridgeHeaders(request_headers); - Platform::RawHeaderMap rawHeaderMap = Platform::envoyHeadersAsRawHeaderMap(envoyHeaders); - Platform::RequestHeadersBuilder builder( Platform::RequestMethod::GET, std::string(default_request_headers_.Scheme()->value().getStringView()), @@ -128,9 +125,6 @@ std::shared_ptr BaseClientIntegrationTest::envoyToMobi return Http::HeaderMap::Iterate::Continue; }); - for (const auto& pair : rawHeaderMap) { - builder.set(pair.first, pair.second); - } return std::make_shared(builder.build()); }