| Index: net/socket/ssl_client_socket_unittest.cc
|
| diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
|
| index 2eaa47e058f6e21a0072d75b8f2f620623a7c4b9..f698acfcc11bd010103d8c9931e12294d887c909 100644
|
| --- a/net/socket/ssl_client_socket_unittest.cc
|
| +++ b/net/socket/ssl_client_socket_unittest.cc
|
| @@ -1246,6 +1246,43 @@ TEST_F(SSLClientSocketTest, Read) {
|
| }
|
| }
|
|
|
| +// Tests that SSLClientSocket properly handles when the underlying transport
|
| +// synchronously fails a transport read in during the handshake. The error code
|
| +// should be preserved so SSLv3 fallback logic can condition on it.
|
| +TEST_F(SSLClientSocketTest, Connect_WithSynchronousError) {
|
| + SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + SpawnedTestServer::kLocalhost,
|
| + base::FilePath());
|
| + ASSERT_TRUE(test_server.Start());
|
| +
|
| + AddressList addr;
|
| + ASSERT_TRUE(test_server.GetAddressList(&addr));
|
| +
|
| + TestCompletionCallback callback;
|
| + scoped_ptr<StreamSocket> real_transport(
|
| + new TCPClientSocket(addr, NULL, NetLog::Source()));
|
| + scoped_ptr<SynchronousErrorStreamSocket> transport(
|
| + new SynchronousErrorStreamSocket(real_transport.Pass()));
|
| + int rv = callback.GetResult(transport->Connect(callback.callback()));
|
| + EXPECT_EQ(OK, rv);
|
| +
|
| + // Disable TLS False Start to avoid handshake non-determinism.
|
| + SSLConfig ssl_config;
|
| + ssl_config.false_start_enabled = false;
|
| +
|
| + SynchronousErrorStreamSocket* raw_transport = transport.get();
|
| + scoped_ptr<SSLClientSocket> sock(
|
| + CreateSSLClientSocket(transport.PassAs<StreamSocket>(),
|
| + test_server.host_port_pair(),
|
| + ssl_config));
|
| +
|
| + raw_transport->SetNextWriteError(ERR_CONNECTION_RESET);
|
| +
|
| + rv = callback.GetResult(sock->Connect(callback.callback()));
|
| + EXPECT_EQ(ERR_CONNECTION_RESET, rv);
|
| + EXPECT_FALSE(sock->IsConnected());
|
| +}
|
| +
|
| // Tests that the SSLClientSocket properly handles when the underlying transport
|
| // synchronously returns an error code - such as if an intermediary terminates
|
| // the socket connection uncleanly.
|
| @@ -1300,14 +1337,7 @@ TEST_F(SSLClientSocketTest, Read_WithSynchronousError) {
|
| // rv != ERR_IO_PENDING is insufficient, as ERR_IO_PENDING is a legitimate
|
| // result when using a dedicated task runner for NSS.
|
| rv = callback.GetResult(sock->Read(buf.get(), 4096, callback.callback()));
|
| -
|
| -#if !defined(USE_OPENSSL)
|
| - // SSLClientSocketNSS records the error exactly
|
| EXPECT_EQ(ERR_CONNECTION_RESET, rv);
|
| -#else
|
| - // SSLClientSocketOpenSSL treats any errors as a simple EOF.
|
| - EXPECT_EQ(0, rv);
|
| -#endif
|
| }
|
|
|
| // Tests that the SSLClientSocket properly handles when the underlying transport
|
| @@ -1381,14 +1411,7 @@ TEST_F(SSLClientSocketTest, Write_WithSynchronousError) {
|
| // checking that rv != ERR_IO_PENDING is insufficient, as ERR_IO_PENDING
|
| // is a legitimate result when using a dedicated task runner for NSS.
|
| rv = callback.GetResult(rv);
|
| -
|
| -#if !defined(USE_OPENSSL)
|
| - // SSLClientSocketNSS records the error exactly
|
| EXPECT_EQ(ERR_CONNECTION_RESET, rv);
|
| -#else
|
| - // SSLClientSocketOpenSSL treats any errors as a simple EOF.
|
| - EXPECT_EQ(0, rv);
|
| -#endif
|
| }
|
|
|
| // If there is a Write failure at the transport with no follow-up Read, although
|
| @@ -1631,14 +1654,7 @@ TEST_F(SSLClientSocketTest, Read_DeleteWhilePendingFullDuplex) {
|
| raw_transport->UnblockWrite();
|
|
|
| rv = read_callback.WaitForResult();
|
| -
|
| -#if !defined(USE_OPENSSL)
|
| - // NSS records the error exactly.
|
| EXPECT_EQ(ERR_CONNECTION_RESET, rv);
|
| -#else
|
| - // OpenSSL treats any errors as a simple EOF.
|
| - EXPECT_EQ(0, rv);
|
| -#endif
|
|
|
| // The Write callback should not have been called.
|
| EXPECT_FALSE(callback.have_result());
|
| @@ -1733,21 +1749,21 @@ TEST_F(SSLClientSocketTest, Read_WithWriteError) {
|
| }
|
| } while (rv > 0);
|
|
|
| -#if !defined(USE_OPENSSL)
|
| - // NSS records the error exactly.
|
| EXPECT_EQ(ERR_CONNECTION_RESET, rv);
|
| -#else
|
| - // OpenSSL treats the reset as a generic protocol error.
|
| - EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
|
| -#endif
|
|
|
| - // Release the read. Some bytes should go through.
|
| + // Release the read.
|
| raw_transport->UnblockReadResult();
|
| rv = read_callback.WaitForResult();
|
|
|
| - // Per the fix for http://crbug.com/249848, write failures currently break
|
| - // reads. Change this assertion if they're changed to not collide.
|
| +#if defined(USE_OPENSSL)
|
| + // Should still read bytes despite the write error.
|
| + EXPECT_LT(0, rv);
|
| +#else
|
| + // NSS attempts to flush the write buffer in PR_Read on an SSL socket before
|
| + // pumping the read state machine, unless configured with SSL_ENABLE_FDX, so
|
| + // the write error stops future reads.
|
| EXPECT_EQ(ERR_CONNECTION_RESET, rv);
|
| +#endif
|
| }
|
|
|
| TEST_F(SSLClientSocketTest, Read_SmallChunks) {
|
|
|