Chromium Code Reviews| Index: net/websockets/websocket_stream_test.cc |
| diff --git a/net/websockets/websocket_stream_test.cc b/net/websockets/websocket_stream_test.cc |
| index 713af37715f2b427b8ec9f76a1c8e7b488c892c7..5d1130d2b20ff8249dcfd3d9107289dea7c90578 100644 |
| --- a/net/websockets/websocket_stream_test.cc |
| +++ b/net/websockets/websocket_stream_test.cc |
| @@ -22,6 +22,7 @@ |
| #include "net/base/test_data_directory.h" |
| #include "net/http/http_request_headers.h" |
| #include "net/http/http_response_headers.h" |
| +#include "net/proxy/proxy_service.h" |
| #include "net/socket/client_socket_handle.h" |
| #include "net/socket/socket_test_util.h" |
| #include "net/test/cert_test_util.h" |
| @@ -1412,5 +1413,36 @@ TEST_F(WebSocketStreamCreateTest, HandleErrConnectionClosed) { |
| EXPECT_TRUE(has_failed()); |
| } |
| +TEST_F(WebSocketStreamCreateTest, HandleErrTunnelConnectionFailed) { |
| + static const char kConnectRequest[] = |
| + "CONNECT localhost:80 HTTP/1.1\r\n" |
| + "Host: localhost\r\n" |
| + "Proxy-Connection: keep-alive\r\n" |
| + "\r\n"; |
| + |
| + static const char kTruncatedResponse[] = |
|
yhirano
2015/02/06 04:27:01
Is this truncated?
Adam Rice
2015/02/06 08:05:57
No. Sorry. Too much copy and paste! Fixed.
|
| + "HTTP/1.1 403 Forbidden\r\n" |
| + "Content-Type: text/html\r\n" |
| + "Content-Length: 9\r\n" |
| + "Connection: keep-alive\r\n" |
| + "\r\n" |
| + "Forbidden"; |
| + |
| + MockRead reads[] = {MockRead(SYNCHRONOUS, 1, kTruncatedResponse)}; |
| + MockWrite writes[] = {MockWrite(SYNCHRONOUS, 0, kConnectRequest)}; |
| + scoped_ptr<DeterministicSocketData> socket_data( |
| + BuildSocketData(reads, writes)); |
| + std::string proxy_config = "https=proxy:8000"; |
| + scoped_ptr<ProxyService> proxy_service( |
| + ProxyService::CreateFixed(proxy_config)); |
| + url_request_context_host_.SetProxyService(proxy_service.Pass()); |
| + CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(), |
| + "http://localhost", socket_data.Pass()); |
| + RunUntilIdle(); |
| + EXPECT_TRUE(has_failed()); |
| + EXPECT_EQ("Establishing a tunnel via proxy server failed.", |
| + failure_message()); |
| +} |
| + |
| } // namespace |
| } // namespace net |