Skip to content

Commit

Permalink
add negative test
Browse files Browse the repository at this point in the history
Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov committed Sep 22, 2022
1 parent b557893 commit 826cb13
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/integration/tcp_tunneling_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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") {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 826cb13

Please sign in to comment.