Commit dc9bfb92 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Socket Pools Refactor: Move HTTP proxy socket tagging tests.

These tests were in http_proxy_client_socket_pool_unittest.cc.
Since the HttpProxyClientSocketPool has since been removed, they need
a new home. This CL moves them in with most of the other socket tagging
tests, in TransportClientSocketPool's unit test file.

This is part of an effort to flatten the socket pools.
https://docs.google.com/document/d/1g0EA4iDqaDhNXA_mq-YK3SlSX-xRkoKvZetAQqdRrxM/edit

Bug: 472729
Change-Id: Ibf5a26aef732108cb5e1cfedcaf92811387091e3
Reviewed-on: https://chromium-review.googlesource.com/c/1471910
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636063}
parent c955aea5
......@@ -463,99 +463,4 @@ TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupRedirect) {
}
}
// Test that SocketTag passed into HttpProxyClientSocketPool is applied to
// returned underlying TCP sockets.
#if defined(OS_ANDROID)
TEST_P(HttpProxyClientSocketPoolTest, Tag) {
// Socket tagging only supports Android without data reduction proxy, so only
// HTTP proxies are supported.
if (GetParam() != HTTP)
return;
Initialize(base::span<MockRead>(), base::span<MockWrite>(),
base::span<MockRead>(), base::span<MockWrite>());
SocketTag tag1(SocketTag::UNSET_UID, 0x12345678);
SocketTag tag2(getuid(), 0x87654321);
// Verify requested socket is tagged properly.
int rv = handle_.Init(
"a", CreateNoTunnelParams(), LOW, tag1,
ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(),
ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(handle_.is_initialized());
ASSERT_TRUE(handle_.socket());
EXPECT_TRUE(handle_.socket()->IsConnected());
EXPECT_EQ(socket_factory()->GetLastProducedTCPSocket()->tag(), tag1);
EXPECT_TRUE(
socket_factory()->GetLastProducedTCPSocket()->tagged_before_connected());
// Verify reused socket is retagged properly.
StreamSocket* socket = handle_.socket();
handle_.Reset();
rv = handle_.Init(
"a", CreateNoTunnelParams(), LOW, tag2,
ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(),
ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(handle_.socket());
EXPECT_TRUE(handle_.socket()->IsConnected());
EXPECT_EQ(handle_.socket(), socket);
EXPECT_EQ(socket_factory()->GetLastProducedTCPSocket()->tag(), tag2);
handle_.socket()->Disconnect();
handle_.Reset();
}
TEST_P(HttpProxyClientSocketPoolTest, TagWithProxy) {
// Socket tagging only supports Android without data reduction proxy, so only
// HTTP proxies are supported.
if (GetParam() != HTTP)
return;
std::string request =
"CONNECT www.google.com:443 HTTP/1.1\r\n"
"Host: www.google.com:443\r\n"
"Proxy-Connection: keep-alive\r\n"
"Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n";
MockWrite writes[] = {
MockWrite(SYNCHRONOUS, 0, request.c_str()),
};
MockRead reads[] = {
MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 Connection Established\r\n\r\n"),
};
Initialize(reads, writes, base::span<MockRead>(), base::span<MockWrite>());
AddAuthToCache();
SocketTag tag1(SocketTag::UNSET_UID, 0x12345678);
SocketTag tag2(getuid(), 0x87654321);
// Verify requested socket is tagged properly.
int rv = handle_.Init(
"a", CreateTunnelParams(), LOW, tag1,
ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(),
ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(handle_.is_initialized());
ASSERT_TRUE(handle_.socket());
EXPECT_TRUE(handle_.socket()->IsConnected());
EXPECT_EQ(socket_factory()->GetLastProducedTCPSocket()->tag(), tag1);
EXPECT_TRUE(
socket_factory()->GetLastProducedTCPSocket()->tagged_before_connected());
// Verify reused socket is retagged properly.
StreamSocket* socket = handle_.socket();
handle_.Reset();
rv = handle_.Init(
"a", CreateNoTunnelParams(), LOW, tag2,
ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(),
ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(handle_.socket());
EXPECT_TRUE(handle_.socket()->IsConnected());
EXPECT_EQ(handle_.socket(), socket);
EXPECT_EQ(socket_factory()->GetLastProducedTCPSocket()->tag(), tag2);
handle_.socket()->Disconnect();
handle_.Reset();
}
#endif
} // namespace net
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment