Index: net/http/http_proxy_client_socket_pool_unittest.cc |
diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc |
index d256646a3ce5d6c0fd6fbeb607340a0c4605d21b..19df6a08eeae96c0b41edbd07ea508b86dcc52dd 100644 |
--- a/net/http/http_proxy_client_socket_pool_unittest.cc |
+++ b/net/http/http_proxy_client_socket_pool_unittest.cc |
@@ -63,6 +63,7 @@ class TestProxyDelegate : public ProxyDelegate { |
public: |
TestProxyDelegate() |
: on_before_tunnel_request_called_(false), |
+ on_tunnel_request_completed_called_(false), |
on_tunnel_headers_received_called_(false) { |
} |
@@ -72,10 +73,23 @@ class TestProxyDelegate : public ProxyDelegate { |
return on_before_tunnel_request_called_; |
} |
+ bool on_tunnel_request_completed_called() const { |
+ return on_tunnel_request_completed_called_; |
+ } |
+ |
bool on_tunnel_headers_received_called() const { |
return on_tunnel_headers_received_called_; |
} |
+ void VerifyOnTunnelRequestCompleted(const std::string& endpoint, |
+ const std::string& proxy_server) const { |
+ EXPECT_TRUE(on_tunnel_request_completed_called_); |
+ EXPECT_TRUE(HostPortPair::FromString(endpoint).Equals( |
+ on_tunnel_request_completed_endpoint_)); |
+ EXPECT_TRUE(HostPortPair::FromString(proxy_server).Equals( |
+ on_tunnel_request_completed_proxy_server_)); |
+ } |
+ |
void VerifyOnTunnelHeadersReceived(const std::string& origin, |
const std::string& proxy_server, |
const std::string& status_line) const { |
@@ -93,6 +107,14 @@ class TestProxyDelegate : public ProxyDelegate { |
const ProxyService& proxy_service, |
ProxyInfo* result) override {} |
+ void OnTunnelConnectCompleted(const HostPortPair& endpoint, |
+ const HostPortPair& proxy_server, |
+ int net_error) override { |
+ on_tunnel_request_completed_called_ = true; |
+ on_tunnel_request_completed_endpoint_ = endpoint; |
+ on_tunnel_request_completed_proxy_server_ = proxy_server; |
+ } |
+ |
void OnFallback(const ProxyServer& bad_proxy, int net_error) override {} |
void OnBeforeSendHeaders(URLRequest* request, |
@@ -119,7 +141,10 @@ class TestProxyDelegate : public ProxyDelegate { |
private: |
bool on_before_tunnel_request_called_; |
+ bool on_tunnel_request_completed_called_; |
bool on_tunnel_headers_received_called_; |
+ HostPortPair on_tunnel_request_completed_endpoint_; |
+ HostPortPair on_tunnel_request_completed_proxy_server_; |
HostPortPair on_tunnel_headers_received_origin_; |
HostPortPair on_tunnel_headers_received_proxy_server_; |
std::string on_tunnel_headers_received_status_line_; |
@@ -344,6 +369,7 @@ TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) { |
EXPECT_TRUE(tunnel_socket->IsConnected()); |
EXPECT_FALSE(proxy_delegate->on_before_tunnel_request_called()); |
EXPECT_FALSE(proxy_delegate->on_tunnel_headers_received_called()); |
+ EXPECT_TRUE(proxy_delegate->on_tunnel_request_completed_called()); |
} |
// Make sure that HttpProxyConnectJob passes on its priority to its |
@@ -454,14 +480,24 @@ TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) { |
"www.google.com:443", |
proxy_host_port.c_str(), |
"HTTP/1.1 200 Connection Established"); |
+ proxy_delegate->VerifyOnTunnelRequestCompleted( |
+ "www.google.com:443", |
+ proxy_host_port.c_str()); |
} |
TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) { |
+ std::string proxy_host_port = |
+ GetParam().proxy_type == HTTP ? |
+ (kHttpProxyHost + std::string(":80")) : |
+ (kHttpsProxyHost + std::string(":443")); |
+ std::string request = |
+ "CONNECT www.google.com:443 HTTP/1.1\r\n" |
+ "Host: www.google.com\r\n" |
+ "Proxy-Connection: keep-alive\r\n" |
+ "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n" |
+ "Foo: " + proxy_host_port + "\r\n\r\n"; |
MockWrite writes[] = { |
- MockWrite(ASYNC, 0, "CONNECT www.google.com:443 HTTP/1.1\r\n" |
- "Host: www.google.com\r\n" |
- "Proxy-Connection: keep-alive\r\n" |
- "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
+ MockWrite(ASYNC, 0, request.c_str()), |
}; |
MockRead reads[] = { |
MockRead(ASYNC, 1, "HTTP/1.1 200 Connection Established\r\n\r\n"), |
@@ -483,7 +519,8 @@ TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) { |
arraysize(spdy_writes)); |
AddAuthToCache(); |
- int rv = handle_.Init("a", CreateTunnelParams(NULL), LOW, |
+ scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); |
+ int rv = handle_.Init("a", CreateTunnelParams(proxy_delegate.get()), LOW, |
callback_.callback(), &pool_, BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_FALSE(handle_.is_initialized()); |
@@ -496,6 +533,9 @@ TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) { |
HttpProxyClientSocket* tunnel_socket = |
static_cast<HttpProxyClientSocket*>(handle_.socket()); |
EXPECT_TRUE(tunnel_socket->IsConnected()); |
+ proxy_delegate->VerifyOnTunnelRequestCompleted( |
+ "www.google.com:443", |
+ proxy_host_port.c_str()); |
} |
// Make sure that HttpProxyConnectJob passes on its priority to its |