diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.cc index 9aaf9fee88d26..42bf1750fc9a8 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.cc @@ -314,16 +314,16 @@ ProxyProtoFilterChainMatchIntegrationTest::ProxyProtoFilterChainMatchIntegration }); } -void ProxyProtoFilterChainMatchIntegrationTest::send(const std::string& data) { +void ProxyProtoFilterChainMatchIntegrationTest::send(const std::string& data, bool end_stream) { initialize(); // Set verify to false because it is expected that Envoy will immediately disconnect after // receiving the PROXY header, and it is a race whether the `write()` will fail due to // disconnect, or finish the write before receiving the disconnect. constexpr bool verify = false; - + enableHalfClose(true); IntegrationTcpClientPtr tcp_client = makeTcpConnection(lookupPort("tcp_proxy")); - ASSERT_TRUE(tcp_client->write(data, false, verify)); + ASSERT_TRUE(tcp_client->write(data, end_stream, verify)); tcp_client->waitForDisconnect(); } @@ -338,6 +338,12 @@ TEST_P(ProxyProtoFilterChainMatchIntegrationTest, MatchDirectSourceAndSource) { testing::HasSubstr("directsource_localhost_and_source_1.2.3.0/24 -")); } +TEST_P(ProxyProtoFilterChainMatchIntegrationTest, CloseAfterProxyProtocol) { + send("PROXY TCP4 1.2.3.4 254.254.254.254 12345 1234", true); + EXPECT_THAT(waitForAccessLog(listener_access_log_name_), + testing::HasSubstr("directsource_localhost_and_source_1.2.3.0/24 -")); +} + // Test that a mismatched direct source prevents matching a filter chain with a matching source. TEST_P(ProxyProtoFilterChainMatchIntegrationTest, MismatchDirectSourceButMatchSource) { send("PROXY TCP4 5.5.5.5 254.254.254.254 12345 1234\r\nhello"); diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.h b/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.h index bdc45933b7ffe..c3780248c42a2 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.h +++ b/test/extensions/filters/listener/proxy_protocol/proxy_proto_integration_test.h @@ -28,7 +28,7 @@ class ProxyProtoFilterChainMatchIntegrationTest : public ProxyProtoTcpIntegratio public: ProxyProtoFilterChainMatchIntegrationTest(); - void send(const std::string& data); + void send(const std::string& data, bool end_stream = false); }; } // namespace Envoy