Chromium Code Reviews| Index: net/spdy/spdy_proxy_client_socket_unittest.cc |
| =================================================================== |
| --- net/spdy/spdy_proxy_client_socket_unittest.cc (revision 117986) |
| +++ net/spdy/spdy_proxy_client_socket_unittest.cc (working copy) |
| @@ -199,8 +199,12 @@ |
| sock_.reset( |
| new SpdyProxyClientSocket(spdy_stream_, user_agent_, |
| endpoint_host_port_pair_, url_, |
| - proxy_host_port_, session_->http_auth_cache(), |
| - session_->http_auth_handler_factory())); |
| + proxy_host_port_, |
| + new HttpAuthController( |
| + HttpAuth::AUTH_PROXY, |
| + GURL(kProxyUrl), |
| + session_->http_auth_cache(), |
| + session_->http_auth_handler_factory()))); |
| } |
| scoped_refptr<IOBufferWithSize> SpdyProxyClientSocketTest::CreateBuffer( |
| @@ -450,7 +454,7 @@ |
| Initialize(reads, arraysize(reads), writes, arraysize(writes)); |
| - AssertConnectFails(ERR_TUNNEL_CONNECTION_FAILED); |
| + AssertConnectFails(ERR_PROXY_AUTH_REQUESTED); |
| const HttpResponseInfo* response = sock_->GetConnectResponseInfo(); |
| ASSERT_TRUE(response != NULL); |
| @@ -479,6 +483,39 @@ |
| AssertConnectionEstablished(); |
| } |
| +TEST_F(SpdyProxyClientSocketTest, ConnectWithAuthRestart) { |
| + scoped_ptr<spdy::SpdyFrame> conn(ConstructConnectRequestFrame()); |
| + scoped_ptr<spdy::SpdyFrame> auth(ConstructConnectAuthRequestFrame()); |
| + MockWrite writes[] = { |
| + CreateMockWrite(*conn, 0, false), |
| + }; |
| + |
| + scoped_ptr<spdy::SpdyFrame> resp(ConstructConnectAuthReplyFrame()); |
| + scoped_ptr<spdy::SpdyFrame> auth_resp(ConstructConnectReplyFrame()); |
| + MockRead reads[] = { |
| + CreateMockRead(*resp, 1, true), |
| + MockRead(true, 0, 3), // EOF |
| + }; |
| + |
| + Initialize(reads, arraysize(reads), writes, arraysize(writes)); |
| + |
| + AssertConnectFails(ERR_PROXY_AUTH_REQUESTED); |
| + |
| + const HttpResponseInfo* response = sock_->GetConnectResponseInfo(); |
| + ASSERT_TRUE(response != NULL); |
| + ASSERT_EQ(407, response->headers->response_code()); |
| + ASSERT_EQ("Proxy Authentication Required", |
| + response->headers->GetStatusText()); |
| + |
| + AddAuthToCache(); |
| + |
| + ASSERT_EQ(ERR_NO_KEEP_ALIVE_ON_AUTH_RESTART, |
| + sock_->RestartWithAuth(read_callback_.callback())); |
| + // A SpdyProxyClientSocket sits on a single SPDY stream which can |
| + // only be used for a single request/response. |
| + ASSERT_FALSE(sock_->IsConnectedAndIdle()); |
| +} |
| + |
|
vandebo (ex-Chrome)
2012/01/20 20:49:29
Can you add a test that requests non-basic, non-di
Ryan Hamilton
2012/01/20 21:51:35
Done. Though now that I think about it, I wonder
vandebo (ex-Chrome)
2012/01/20 21:58:20
SGTM
Ryan Hamilton
2012/01/23 18:37:27
Done.
|
| TEST_F(SpdyProxyClientSocketTest, ConnectFails) { |
| scoped_ptr<spdy::SpdyFrame> conn(ConstructConnectRequestFrame()); |
| MockWrite writes[] = { |
| @@ -831,7 +868,7 @@ |
| Initialize(reads, arraysize(reads), writes, arraysize(writes)); |
| - AssertConnectFails(ERR_TUNNEL_CONNECTION_FAILED); |
| + AssertConnectFails(ERR_PROXY_AUTH_REQUESTED); |
| Run(2); // SpdySession consumes the next two reads and sends then to |
| // sock_ to be buffered. |