From 826cb132a1fc89578a2e576905bd6b546be26a60 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Thu, 22 Sep 2022 13:25:54 -0700 Subject: [PATCH] add negative test Signed-off-by: Kuat Yessenov --- test/integration/tcp_tunneling_integration_test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/tcp_tunneling_integration_test.cc b/test/integration/tcp_tunneling_integration_test.cc index 50f4489475b0..2fe44602bcc2 100644 --- a/test/integration/tcp_tunneling_integration_test.cc +++ b/test/integration/tcp_tunneling_integration_test.cc @@ -659,6 +659,9 @@ TEST_P(TcpTunnelingIntegrationTest, BasicUsePost) { } TEST_P(TcpTunnelingIntegrationTest, BasicHeaderEvaluationTunnelingConfig) { + const std::string access_log_filename = + TestEnvironment::temporaryPath(TestUtility::uniqueFilename()); + // Set the "downstream-local-ip" header in the CONNECT request. config_helper_.addConfigModifier([&](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void { envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy proxy_config; @@ -669,6 +672,12 @@ TEST_P(TcpTunnelingIntegrationTest, BasicHeaderEvaluationTunnelingConfig) { new_header->mutable_header()->set_key("downstream-local-ip"); new_header->mutable_header()->set_value("%DOWNSTREAM_LOCAL_ADDRESS_WITHOUT_PORT%"); + envoy::extensions::access_loggers::file::v3::FileAccessLog access_log_config; + access_log_config.mutable_log_format()->mutable_text_format_source()->set_inline_string( + "FILTER_STATE=%FILTER_STATE(envoy.tcp_proxy.propagate_response_headers:TYPED)%\n"); + access_log_config.set_path(access_log_filename); + proxy_config.add_access_log()->mutable_typed_config()->PackFrom(access_log_config); + auto* listeners = bootstrap.mutable_static_resources()->mutable_listeners(); for (auto& listener : *listeners) { if (listener.name() != "tcp_proxy") { @@ -705,6 +714,9 @@ TEST_P(TcpTunnelingIntegrationTest, BasicHeaderEvaluationTunnelingConfig) { upstream_request_->encodeHeaders(default_response_headers_, false); sendBidiData(fake_upstream_connection_); closeConnection(fake_upstream_connection_); + + // Verify response header value object is not present + EXPECT_THAT(waitForAccessLog(access_log_filename), testing::HasSubstr("FILTER_STATE=-")); } // Verify that the header evaluator is updated without lifetime issue.