summaryrefslogtreecommitdiffstats
path: root/net/base/ssl_client_socket_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/ssl_client_socket_unittest.cc')
-rw-r--r--net/base/ssl_client_socket_unittest.cc62
1 files changed, 48 insertions, 14 deletions
diff --git a/net/base/ssl_client_socket_unittest.cc b/net/base/ssl_client_socket_unittest.cc
index 7b551fe..7c7b170 100644
--- a/net/base/ssl_client_socket_unittest.cc
+++ b/net/base/ssl_client_socket_unittest.cc
@@ -79,8 +79,14 @@ TEST_F(SSLClientSocketTest, MAYBE_Connect) {
&addr, NULL);
EXPECT_EQ(net::OK, rv);
+ net::ClientSocket *transport = new net::TCPClientSocket(addr);
+ rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
+ socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName, kDefaultSSLConfig));
EXPECT_FALSE(sock->IsConnected());
@@ -111,8 +117,14 @@ TEST_F(SSLClientSocketTest, MAYBE_ConnectExpired) {
&addr, NULL);
EXPECT_EQ(net::OK, rv);
+ net::ClientSocket *transport = new net::TCPClientSocket(addr);
+ rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
+ socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName, kDefaultSSLConfig));
EXPECT_FALSE(sock->IsConnected());
@@ -126,7 +138,9 @@ TEST_F(SSLClientSocketTest, MAYBE_ConnectExpired) {
EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv);
}
- EXPECT_TRUE(sock->IsConnected());
+ // We cannot test sock->IsConnected(), as the NSS implementation disconnects
+ // the socket when it encounters an error, whereas other implementations
+ // leave it connected.
}
TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) {
@@ -140,8 +154,14 @@ TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) {
&addr, NULL);
EXPECT_EQ(net::OK, rv);
+ net::ClientSocket *transport = new net::TCPClientSocket(addr);
+ rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
+ socket_factory_->CreateSSLClientSocket(transport,
server_.kMismatchedHostName, kDefaultSSLConfig));
EXPECT_FALSE(sock->IsConnected());
@@ -155,13 +175,9 @@ TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) {
EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, rv);
}
- // The Windows code happens to keep the connection
- // open now in spite of an error. The designers of
- // this API intended to also allow the connection
- // to be closed on error, in which case the caller
- // should call ReconnectIgnoringLastError, but
- // that's currently unimplemented.
- EXPECT_TRUE(sock->IsConnected());
+ // We cannot test sock->IsConnected(), as the NSS implementation disconnects
+ // the socket when it encounters an error, whereas other implementations
+ // leave it connected.
}
// TODO(wtc): Add unit tests for IsConnectedAndIdle:
@@ -183,8 +199,14 @@ TEST_F(SSLClientSocketTest, MAYBE_Read) {
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
+ net::ClientSocket *transport = new net::TCPClientSocket(addr);
+ rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
+ socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName,
kDefaultSSLConfig));
@@ -231,8 +253,14 @@ TEST_F(SSLClientSocketTest, MAYBE_Read_SmallChunks) {
&addr, NULL);
EXPECT_EQ(net::OK, rv);
+ net::ClientSocket *transport = new net::TCPClientSocket(addr);
+ rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
+ socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName, kDefaultSSLConfig));
rv = sock->Connect(&callback);
@@ -277,8 +305,14 @@ TEST_F(SSLClientSocketTest, MAYBE_Read_Interrupted) {
&addr, NULL);
EXPECT_EQ(net::OK, rv);
+ net::ClientSocket *transport = new net::TCPClientSocket(addr);
+ rv = transport->Connect(&callback);
+ if (rv == net::ERR_IO_PENDING)
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
+ socket_factory_->CreateSSLClientSocket(transport,
server_.kHostName, kDefaultSSLConfig));
rv = sock->Connect(&callback);