From 75bcf658b3e2bbf5601b15ac6a1afe7f3b557dbd Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Wed, 14 Oct 2020 13:17:18 -0400 Subject: [PATCH 1/2] test: adding a test for CONNECT to an IP address Signed-off-by: Alyssa Wilk --- .../tcp_tunneling_integration_test.cc | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/integration/tcp_tunneling_integration_test.cc b/test/integration/tcp_tunneling_integration_test.cc index 00efaba709a69..8ad9a9846683e 100644 --- a/test/integration/tcp_tunneling_integration_test.cc +++ b/test/integration/tcp_tunneling_integration_test.cc @@ -272,6 +272,42 @@ TEST_P(ProxyingConnectIntegrationTest, ProxyConnect) { cleanupUpstreamAndDownstream(); } +TEST_P(ProxyingConnectIntegrationTest, ProxyConnectWithIP) { + initialize(); + + // Send request headers. + codec_client_ = makeHttpConnection(lookupPort("http")); + connect_headers_.setHost("1.2.3.4:80"); + auto encoder_decoder = codec_client_->startRequest(connect_headers_); + request_encoder_ = &encoder_decoder.first; + response_ = std::move(encoder_decoder.second); + + // Wait for them to arrive upstream. + AssertionResult result = + fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, fake_upstream_connection_); + RELEASE_ASSERT(result, result.message()); + result = fake_upstream_connection_->waitForNewStream(*dispatcher_, upstream_request_); + RELEASE_ASSERT(result, result.message()); + ASSERT_TRUE(upstream_request_->waitForHeadersComplete()); + EXPECT_EQ(upstream_request_->headers().get(Http::Headers::get().Method)[0]->value(), "CONNECT"); + if (upstreamProtocol() == FakeHttpConnection::Type::HTTP1) { + EXPECT_TRUE(upstream_request_->headers().get(Http::Headers::get().Protocol).empty()); + } else { + EXPECT_EQ(upstream_request_->headers().get(Http::Headers::get().Protocol)[0]->value(), + "bytestream"); + } + + // Send response headers + upstream_request_->encodeHeaders(default_response_headers_, false); + + // Wait for them to arrive downstream. + response_->waitForHeaders(); + EXPECT_EQ("200", response_->headers().getStatusValue()); + + cleanupUpstreamAndDownstream(); +} + + INSTANTIATE_TEST_SUITE_P(IpVersions, ConnectTerminationIntegrationTest, testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), TestUtility::ipTestParamsToString); From 72cc028c2588c3ea2b5936e5849ce1f4ba62cff1 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 29 Oct 2020 14:46:36 -0400 Subject: [PATCH 2/2] format? Signed-off-by: Alyssa Wilk --- test/integration/tcp_tunneling_integration_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/tcp_tunneling_integration_test.cc b/test/integration/tcp_tunneling_integration_test.cc index 8ad9a9846683e..efc7222c90cb8 100644 --- a/test/integration/tcp_tunneling_integration_test.cc +++ b/test/integration/tcp_tunneling_integration_test.cc @@ -307,7 +307,6 @@ TEST_P(ProxyingConnectIntegrationTest, ProxyConnectWithIP) { cleanupUpstreamAndDownstream(); } - INSTANTIATE_TEST_SUITE_P(IpVersions, ConnectTerminationIntegrationTest, testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), TestUtility::ipTestParamsToString);