Index: net/http/http_network_transaction_unittest.cc |
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc |
index a0248fe21267c70b1f1a6116ed6efae0f03f5f02..dc846cacd8270657939b779793ba6d3470b56083 100644 |
--- a/net/http/http_network_transaction_unittest.cc |
+++ b/net/http/http_network_transaction_unittest.cc |
@@ -2476,110 +2476,6 @@ TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) { |
session->CloseAllConnections(); |
} |
-// Test the request-challenge-retry sequence for basic auth, over a keep-alive |
-// proxy connection, when setting up an SSL tunnel. |
Ryan Sleevi
2014/12/08 22:04:39
Is my reading of your deletion of this test correc
Ryan Hamilton
2014/12/08 22:51:59
... because that would be Bad (tm).
I broke this
Deprecated (see juliatuttle)
2014/12/09 15:31:15
Yes; our fake response does not have a keep-alive
asanka
2014/12/09 17:33:02
Respecting keep-alive is important for connection
Deprecated (see juliatuttle)
2014/12/10 20:38:40
Gross, but fixed.
|
-TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) { |
- HttpRequestInfo request; |
- request.method = "GET"; |
- request.url = GURL("https://www.google.com/"); |
- // Ensure that proxy authentication is attempted even |
- // when the no authentication data flag is set. |
- request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
- |
- // Configure against proxy server "myproxy:70". |
- session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
- CapturingBoundNetLog log; |
- session_deps_.net_log = log.bound().net_log(); |
- scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
- |
- scoped_ptr<HttpTransaction> trans( |
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
- |
- // Since we have proxy, should try to establish tunnel. |
- MockWrite data_writes1[] = { |
- MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
- "Host: www.google.com\r\n" |
- "Proxy-Connection: keep-alive\r\n\r\n"), |
- |
- // After calling trans->RestartWithAuth(), this is the request we should |
- // be issuing -- the final header line contains the credentials. |
- MockWrite("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 Zm9vOmJheg==\r\n\r\n"), |
- }; |
- |
- // The proxy responds to the connect with a 407, using a persistent |
- // connection. |
- MockRead data_reads1[] = { |
- // No credentials. |
- MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
- MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
- MockRead("Content-Length: 10\r\n\r\n"), |
- MockRead("0123456789"), |
- |
- // Wrong credentials (wrong password). |
- MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
- MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
- MockRead("Content-Length: 10\r\n\r\n"), |
- // No response body because the test stops reading here. |
- MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
- }; |
- |
- StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
- data_writes1, arraysize(data_writes1)); |
- session_deps_.socket_factory->AddSocketDataProvider(&data1); |
- |
- TestCompletionCallback callback1; |
- |
- int rv = trans->Start(&request, callback1.callback(), log.bound()); |
- EXPECT_EQ(ERR_IO_PENDING, rv); |
- |
- rv = callback1.WaitForResult(); |
- EXPECT_EQ(OK, rv); |
- net::CapturingNetLog::CapturedEntryList entries; |
- log.GetEntries(&entries); |
- size_t pos = ExpectLogContainsSomewhere( |
- entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
- NetLog::PHASE_NONE); |
- ExpectLogContainsSomewhere( |
- entries, pos, |
- NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
- NetLog::PHASE_NONE); |
- |
- const HttpResponseInfo* response = trans->GetResponseInfo(); |
- ASSERT_TRUE(response != NULL); |
- ASSERT_FALSE(response->headers.get() == NULL); |
- EXPECT_TRUE(response->headers->IsKeepAlive()); |
- EXPECT_EQ(407, response->headers->response_code()); |
- EXPECT_EQ(10, response->headers->GetContentLength()); |
- EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
- EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
- |
- TestCompletionCallback callback2; |
- |
- // Wrong password (should be "bar"). |
- rv = trans->RestartWithAuth( |
- AuthCredentials(kFoo, kBaz), callback2.callback()); |
- EXPECT_EQ(ERR_IO_PENDING, rv); |
- |
- rv = callback2.WaitForResult(); |
- EXPECT_EQ(OK, rv); |
- |
- response = trans->GetResponseInfo(); |
- ASSERT_TRUE(response != NULL); |
- ASSERT_FALSE(response->headers.get() == NULL); |
- EXPECT_TRUE(response->headers->IsKeepAlive()); |
- EXPECT_EQ(407, response->headers->response_code()); |
- EXPECT_EQ(10, response->headers->GetContentLength()); |
- EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
- EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
- |
- // Flush the idle socket before the NetLog and HttpNetworkTransaction go |
- // out of scope. |
- session->CloseAllConnections(); |
-} |
- |
// Test that we don't read the response body when we fail to establish a tunnel, |
// even if the user cancels the proxy's auth attempt. |
TEST_P(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { |
@@ -2626,10 +2522,8 @@ TEST_P(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { |
const HttpResponseInfo* response = trans->GetResponseInfo(); |
ASSERT_TRUE(response != NULL); |
- EXPECT_TRUE(response->headers->IsKeepAlive()); |
EXPECT_EQ(407, response->headers->response_code()); |
- EXPECT_EQ(10, response->headers->GetContentLength()); |
- EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
+ EXPECT_EQ(0, response->headers->GetContentLength()); |
std::string response_data; |
rv = ReadTransaction(trans.get(), &response_data); |
@@ -4119,7 +4013,7 @@ TEST_P(HttpNetworkTransactionTest, ConnectStatus406) { |
TEST_P(HttpNetworkTransactionTest, ConnectStatus407) { |
ConnectStatusHelperWithExpectedStatus( |
MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
- ERR_PROXY_AUTH_UNSUPPORTED); |
+ ERR_TUNNEL_CONNECTION_FAILED); |
} |
TEST_P(HttpNetworkTransactionTest, ConnectStatus408) { |