OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 //----------------------------------------------------------------------------- | 38 //----------------------------------------------------------------------------- |
39 | 39 |
40 using testing::_; | 40 using testing::_; |
41 using testing::Return; | 41 using testing::Return; |
42 using testing::Truly; | 42 using testing::Truly; |
43 | 43 |
44 namespace net { | 44 namespace net { |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 const SSLConfig kDefaultSSLConfig; | |
49 | |
50 // WrappedStreamSocket is a base class that wraps an existing StreamSocket, | 48 // WrappedStreamSocket is a base class that wraps an existing StreamSocket, |
51 // forwarding the Socket and StreamSocket interfaces to the underlying | 49 // forwarding the Socket and StreamSocket interfaces to the underlying |
52 // transport. | 50 // transport. |
53 // This is to provide a common base class for subclasses to override specific | 51 // This is to provide a common base class for subclasses to override specific |
54 // StreamSocket methods for testing, while still communicating with a 'real' | 52 // StreamSocket methods for testing, while still communicating with a 'real' |
55 // StreamSocket. | 53 // StreamSocket. |
56 class WrappedStreamSocket : public StreamSocket { | 54 class WrappedStreamSocket : public StreamSocket { |
57 public: | 55 public: |
58 explicit WrappedStreamSocket(scoped_ptr<StreamSocket> transport) | 56 explicit WrappedStreamSocket(scoped_ptr<StreamSocket> transport) |
59 : transport_(transport.Pass()) {} | 57 : transport_(transport.Pass()) {} |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 TestCompletionCallback callback; | 782 TestCompletionCallback callback; |
785 CapturingNetLog log; | 783 CapturingNetLog log; |
786 scoped_ptr<StreamSocket> transport( | 784 scoped_ptr<StreamSocket> transport( |
787 new TCPClientSocket(addr, &log, NetLog::Source())); | 785 new TCPClientSocket(addr, &log, NetLog::Source())); |
788 int rv = transport->Connect(callback.callback()); | 786 int rv = transport->Connect(callback.callback()); |
789 if (rv == ERR_IO_PENDING) | 787 if (rv == ERR_IO_PENDING) |
790 rv = callback.WaitForResult(); | 788 rv = callback.WaitForResult(); |
791 EXPECT_EQ(OK, rv); | 789 EXPECT_EQ(OK, rv); |
792 | 790 |
793 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 791 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
794 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 792 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
795 EXPECT_FALSE(sock->IsConnected()); | 793 EXPECT_FALSE(sock->IsConnected()); |
796 | 794 |
797 rv = sock->Connect(callback.callback()); | 795 rv = sock->Connect(callback.callback()); |
798 if (rv == ERR_IO_PENDING) | 796 if (rv == ERR_IO_PENDING) |
799 rv = callback.WaitForResult(); | 797 rv = callback.WaitForResult(); |
800 scoped_refptr<SSLCertRequestInfo> request_info = new SSLCertRequestInfo(); | 798 scoped_refptr<SSLCertRequestInfo> request_info = new SSLCertRequestInfo(); |
801 sock->GetSSLCertRequestInfo(request_info.get()); | 799 sock->GetSSLCertRequestInfo(request_info.get()); |
802 sock->Disconnect(); | 800 sock->Disconnect(); |
803 EXPECT_FALSE(sock->IsConnected()); | 801 EXPECT_FALSE(sock->IsConnected()); |
804 EXPECT_TRUE( | 802 EXPECT_TRUE( |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 TestCompletionCallback callback; | 1003 TestCompletionCallback callback; |
1006 CapturingNetLog log; | 1004 CapturingNetLog log; |
1007 scoped_ptr<StreamSocket> transport( | 1005 scoped_ptr<StreamSocket> transport( |
1008 new TCPClientSocket(addr, &log, NetLog::Source())); | 1006 new TCPClientSocket(addr, &log, NetLog::Source())); |
1009 int rv = transport->Connect(callback.callback()); | 1007 int rv = transport->Connect(callback.callback()); |
1010 if (rv == ERR_IO_PENDING) | 1008 if (rv == ERR_IO_PENDING) |
1011 rv = callback.WaitForResult(); | 1009 rv = callback.WaitForResult(); |
1012 EXPECT_EQ(OK, rv); | 1010 EXPECT_EQ(OK, rv); |
1013 | 1011 |
1014 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1012 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1015 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1013 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1016 | 1014 |
1017 EXPECT_FALSE(sock->IsConnected()); | 1015 EXPECT_FALSE(sock->IsConnected()); |
1018 | 1016 |
1019 rv = sock->Connect(callback.callback()); | 1017 rv = sock->Connect(callback.callback()); |
1020 | 1018 |
1021 CapturingNetLog::CapturedEntryList entries; | 1019 CapturingNetLog::CapturedEntryList entries; |
1022 log.GetEntries(&entries); | 1020 log.GetEntries(&entries); |
1023 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); | 1021 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); |
1024 if (rv == ERR_IO_PENDING) | 1022 if (rv == ERR_IO_PENDING) |
1025 rv = callback.WaitForResult(); | 1023 rv = callback.WaitForResult(); |
(...skipping 21 matching lines...) Expand all Loading... |
1047 TestCompletionCallback callback; | 1045 TestCompletionCallback callback; |
1048 CapturingNetLog log; | 1046 CapturingNetLog log; |
1049 scoped_ptr<StreamSocket> transport( | 1047 scoped_ptr<StreamSocket> transport( |
1050 new TCPClientSocket(addr, &log, NetLog::Source())); | 1048 new TCPClientSocket(addr, &log, NetLog::Source())); |
1051 int rv = transport->Connect(callback.callback()); | 1049 int rv = transport->Connect(callback.callback()); |
1052 if (rv == ERR_IO_PENDING) | 1050 if (rv == ERR_IO_PENDING) |
1053 rv = callback.WaitForResult(); | 1051 rv = callback.WaitForResult(); |
1054 EXPECT_EQ(OK, rv); | 1052 EXPECT_EQ(OK, rv); |
1055 | 1053 |
1056 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1054 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1057 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1055 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1058 | 1056 |
1059 EXPECT_FALSE(sock->IsConnected()); | 1057 EXPECT_FALSE(sock->IsConnected()); |
1060 | 1058 |
1061 rv = sock->Connect(callback.callback()); | 1059 rv = sock->Connect(callback.callback()); |
1062 | 1060 |
1063 CapturingNetLog::CapturedEntryList entries; | 1061 CapturingNetLog::CapturedEntryList entries; |
1064 log.GetEntries(&entries); | 1062 log.GetEntries(&entries); |
1065 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); | 1063 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); |
1066 if (rv == ERR_IO_PENDING) | 1064 if (rv == ERR_IO_PENDING) |
1067 rv = callback.WaitForResult(); | 1065 rv = callback.WaitForResult(); |
(...skipping 23 matching lines...) Expand all Loading... |
1091 TestCompletionCallback callback; | 1089 TestCompletionCallback callback; |
1092 CapturingNetLog log; | 1090 CapturingNetLog log; |
1093 scoped_ptr<StreamSocket> transport( | 1091 scoped_ptr<StreamSocket> transport( |
1094 new TCPClientSocket(addr, &log, NetLog::Source())); | 1092 new TCPClientSocket(addr, &log, NetLog::Source())); |
1095 int rv = transport->Connect(callback.callback()); | 1093 int rv = transport->Connect(callback.callback()); |
1096 if (rv == ERR_IO_PENDING) | 1094 if (rv == ERR_IO_PENDING) |
1097 rv = callback.WaitForResult(); | 1095 rv = callback.WaitForResult(); |
1098 EXPECT_EQ(OK, rv); | 1096 EXPECT_EQ(OK, rv); |
1099 | 1097 |
1100 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1098 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1101 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1099 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1102 | 1100 |
1103 EXPECT_FALSE(sock->IsConnected()); | 1101 EXPECT_FALSE(sock->IsConnected()); |
1104 | 1102 |
1105 rv = sock->Connect(callback.callback()); | 1103 rv = sock->Connect(callback.callback()); |
1106 | 1104 |
1107 CapturingNetLog::CapturedEntryList entries; | 1105 CapturingNetLog::CapturedEntryList entries; |
1108 log.GetEntries(&entries); | 1106 log.GetEntries(&entries); |
1109 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); | 1107 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); |
1110 if (rv == ERR_IO_PENDING) | 1108 if (rv == ERR_IO_PENDING) |
1111 rv = callback.WaitForResult(); | 1109 rv = callback.WaitForResult(); |
(...skipping 23 matching lines...) Expand all Loading... |
1135 TestCompletionCallback callback; | 1133 TestCompletionCallback callback; |
1136 CapturingNetLog log; | 1134 CapturingNetLog log; |
1137 scoped_ptr<StreamSocket> transport( | 1135 scoped_ptr<StreamSocket> transport( |
1138 new TCPClientSocket(addr, &log, NetLog::Source())); | 1136 new TCPClientSocket(addr, &log, NetLog::Source())); |
1139 int rv = transport->Connect(callback.callback()); | 1137 int rv = transport->Connect(callback.callback()); |
1140 if (rv == ERR_IO_PENDING) | 1138 if (rv == ERR_IO_PENDING) |
1141 rv = callback.WaitForResult(); | 1139 rv = callback.WaitForResult(); |
1142 EXPECT_EQ(OK, rv); | 1140 EXPECT_EQ(OK, rv); |
1143 | 1141 |
1144 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1142 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1145 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1143 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1146 | 1144 |
1147 EXPECT_FALSE(sock->IsConnected()); | 1145 EXPECT_FALSE(sock->IsConnected()); |
1148 | 1146 |
1149 rv = sock->Connect(callback.callback()); | 1147 rv = sock->Connect(callback.callback()); |
1150 | 1148 |
1151 CapturingNetLog::CapturedEntryList entries; | 1149 CapturingNetLog::CapturedEntryList entries; |
1152 log.GetEntries(&entries); | 1150 log.GetEntries(&entries); |
1153 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); | 1151 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); |
1154 if (rv == ERR_IO_PENDING) | 1152 if (rv == ERR_IO_PENDING) |
1155 rv = callback.WaitForResult(); | 1153 rv = callback.WaitForResult(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 | 1191 |
1194 TestCompletionCallback callback; | 1192 TestCompletionCallback callback; |
1195 CapturingNetLog log; | 1193 CapturingNetLog log; |
1196 scoped_ptr<StreamSocket> transport( | 1194 scoped_ptr<StreamSocket> transport( |
1197 new TCPClientSocket(addr, &log, NetLog::Source())); | 1195 new TCPClientSocket(addr, &log, NetLog::Source())); |
1198 int rv = transport->Connect(callback.callback()); | 1196 int rv = transport->Connect(callback.callback()); |
1199 if (rv == ERR_IO_PENDING) | 1197 if (rv == ERR_IO_PENDING) |
1200 rv = callback.WaitForResult(); | 1198 rv = callback.WaitForResult(); |
1201 EXPECT_EQ(OK, rv); | 1199 EXPECT_EQ(OK, rv); |
1202 | 1200 |
1203 SSLConfig ssl_config = kDefaultSSLConfig; | 1201 SSLConfig ssl_config; |
1204 ssl_config.send_client_cert = true; | 1202 ssl_config.send_client_cert = true; |
1205 ssl_config.client_cert = NULL; | 1203 ssl_config.client_cert = NULL; |
1206 | 1204 |
1207 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1205 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1208 transport.Pass(), test_server.host_port_pair(), ssl_config)); | 1206 transport.Pass(), test_server.host_port_pair(), ssl_config)); |
1209 | 1207 |
1210 EXPECT_FALSE(sock->IsConnected()); | 1208 EXPECT_FALSE(sock->IsConnected()); |
1211 | 1209 |
1212 // Our test server accepts certificate-less connections. | 1210 // Our test server accepts certificate-less connections. |
1213 // TODO(davidben): Add a test which requires them and verify the error. | 1211 // TODO(davidben): Add a test which requires them and verify the error. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 | 1249 |
1252 TestCompletionCallback callback; | 1250 TestCompletionCallback callback; |
1253 scoped_ptr<StreamSocket> transport( | 1251 scoped_ptr<StreamSocket> transport( |
1254 new TCPClientSocket(addr, NULL, NetLog::Source())); | 1252 new TCPClientSocket(addr, NULL, NetLog::Source())); |
1255 int rv = transport->Connect(callback.callback()); | 1253 int rv = transport->Connect(callback.callback()); |
1256 if (rv == ERR_IO_PENDING) | 1254 if (rv == ERR_IO_PENDING) |
1257 rv = callback.WaitForResult(); | 1255 rv = callback.WaitForResult(); |
1258 EXPECT_EQ(OK, rv); | 1256 EXPECT_EQ(OK, rv); |
1259 | 1257 |
1260 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1258 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1261 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1259 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1262 | 1260 |
1263 rv = sock->Connect(callback.callback()); | 1261 rv = sock->Connect(callback.callback()); |
1264 if (rv == ERR_IO_PENDING) | 1262 if (rv == ERR_IO_PENDING) |
1265 rv = callback.WaitForResult(); | 1263 rv = callback.WaitForResult(); |
1266 EXPECT_EQ(OK, rv); | 1264 EXPECT_EQ(OK, rv); |
1267 EXPECT_TRUE(sock->IsConnected()); | 1265 EXPECT_TRUE(sock->IsConnected()); |
1268 | 1266 |
1269 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 1267 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
1270 scoped_refptr<IOBuffer> request_buffer( | 1268 scoped_refptr<IOBuffer> request_buffer( |
1271 new IOBuffer(arraysize(request_text) - 1)); | 1269 new IOBuffer(arraysize(request_text) - 1)); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 TestCompletionCallback callback; // Used for everything except Write. | 1534 TestCompletionCallback callback; // Used for everything except Write. |
1537 | 1535 |
1538 scoped_ptr<StreamSocket> transport( | 1536 scoped_ptr<StreamSocket> transport( |
1539 new TCPClientSocket(addr, NULL, NetLog::Source())); | 1537 new TCPClientSocket(addr, NULL, NetLog::Source())); |
1540 int rv = transport->Connect(callback.callback()); | 1538 int rv = transport->Connect(callback.callback()); |
1541 if (rv == ERR_IO_PENDING) | 1539 if (rv == ERR_IO_PENDING) |
1542 rv = callback.WaitForResult(); | 1540 rv = callback.WaitForResult(); |
1543 EXPECT_EQ(OK, rv); | 1541 EXPECT_EQ(OK, rv); |
1544 | 1542 |
1545 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1543 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1546 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1544 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1547 | 1545 |
1548 rv = sock->Connect(callback.callback()); | 1546 rv = sock->Connect(callback.callback()); |
1549 if (rv == ERR_IO_PENDING) | 1547 if (rv == ERR_IO_PENDING) |
1550 rv = callback.WaitForResult(); | 1548 rv = callback.WaitForResult(); |
1551 EXPECT_EQ(OK, rv); | 1549 EXPECT_EQ(OK, rv); |
1552 EXPECT_TRUE(sock->IsConnected()); | 1550 EXPECT_TRUE(sock->IsConnected()); |
1553 | 1551 |
1554 // Issue a "hanging" Read first. | 1552 // Issue a "hanging" Read first. |
1555 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); | 1553 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); |
1556 rv = sock->Read(buf.get(), 4096, callback.callback()); | 1554 rv = sock->Read(buf.get(), 4096, callback.callback()); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 | 1812 |
1815 TestCompletionCallback callback; | 1813 TestCompletionCallback callback; |
1816 scoped_ptr<StreamSocket> real_transport( | 1814 scoped_ptr<StreamSocket> real_transport( |
1817 new TCPClientSocket(addr, NULL, NetLog::Source())); | 1815 new TCPClientSocket(addr, NULL, NetLog::Source())); |
1818 scoped_ptr<SynchronousErrorStreamSocket> transport( | 1816 scoped_ptr<SynchronousErrorStreamSocket> transport( |
1819 new SynchronousErrorStreamSocket(real_transport.Pass())); | 1817 new SynchronousErrorStreamSocket(real_transport.Pass())); |
1820 int rv = callback.GetResult(transport->Connect(callback.callback())); | 1818 int rv = callback.GetResult(transport->Connect(callback.callback())); |
1821 EXPECT_EQ(OK, rv); | 1819 EXPECT_EQ(OK, rv); |
1822 | 1820 |
1823 SynchronousErrorStreamSocket* raw_transport = transport.get(); | 1821 SynchronousErrorStreamSocket* raw_transport = transport.get(); |
1824 scoped_ptr<SSLClientSocket> sock( | 1822 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1825 CreateSSLClientSocket(transport.Pass(), | 1823 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1826 test_server.host_port_pair(), | |
1827 kDefaultSSLConfig)); | |
1828 | 1824 |
1829 raw_transport->SetNextReadError(0); | 1825 raw_transport->SetNextReadError(0); |
1830 | 1826 |
1831 rv = callback.GetResult(sock->Connect(callback.callback())); | 1827 rv = callback.GetResult(sock->Connect(callback.callback())); |
1832 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 1828 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); |
1833 EXPECT_FALSE(sock->IsConnected()); | 1829 EXPECT_FALSE(sock->IsConnected()); |
1834 } | 1830 } |
1835 | 1831 |
1836 // Tests that SSLClientSocket cleanly returns a Read of size 0 if the | 1832 // Tests that SSLClientSocket cleanly returns a Read of size 0 if the |
1837 // underlying socket is cleanly closed. | 1833 // underlying socket is cleanly closed. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 | 1928 |
1933 TestCompletionCallback callback; | 1929 TestCompletionCallback callback; |
1934 scoped_ptr<StreamSocket> transport( | 1930 scoped_ptr<StreamSocket> transport( |
1935 new TCPClientSocket(addr, NULL, NetLog::Source())); | 1931 new TCPClientSocket(addr, NULL, NetLog::Source())); |
1936 int rv = transport->Connect(callback.callback()); | 1932 int rv = transport->Connect(callback.callback()); |
1937 if (rv == ERR_IO_PENDING) | 1933 if (rv == ERR_IO_PENDING) |
1938 rv = callback.WaitForResult(); | 1934 rv = callback.WaitForResult(); |
1939 EXPECT_EQ(OK, rv); | 1935 EXPECT_EQ(OK, rv); |
1940 | 1936 |
1941 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1937 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1942 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1938 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1943 | 1939 |
1944 rv = sock->Connect(callback.callback()); | 1940 rv = sock->Connect(callback.callback()); |
1945 if (rv == ERR_IO_PENDING) | 1941 if (rv == ERR_IO_PENDING) |
1946 rv = callback.WaitForResult(); | 1942 rv = callback.WaitForResult(); |
1947 EXPECT_EQ(OK, rv); | 1943 EXPECT_EQ(OK, rv); |
1948 | 1944 |
1949 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 1945 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
1950 scoped_refptr<IOBuffer> request_buffer( | 1946 scoped_refptr<IOBuffer> request_buffer( |
1951 new IOBuffer(arraysize(request_text) - 1)); | 1947 new IOBuffer(arraysize(request_text) - 1)); |
1952 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 1948 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 | 1982 |
1987 scoped_ptr<StreamSocket> real_transport( | 1983 scoped_ptr<StreamSocket> real_transport( |
1988 new TCPClientSocket(addr, NULL, NetLog::Source())); | 1984 new TCPClientSocket(addr, NULL, NetLog::Source())); |
1989 scoped_ptr<ReadBufferingStreamSocket> transport( | 1985 scoped_ptr<ReadBufferingStreamSocket> transport( |
1990 new ReadBufferingStreamSocket(real_transport.Pass())); | 1986 new ReadBufferingStreamSocket(real_transport.Pass())); |
1991 ReadBufferingStreamSocket* raw_transport = transport.get(); | 1987 ReadBufferingStreamSocket* raw_transport = transport.get(); |
1992 int rv = callback.GetResult(transport->Connect(callback.callback())); | 1988 int rv = callback.GetResult(transport->Connect(callback.callback())); |
1993 ASSERT_EQ(OK, rv); | 1989 ASSERT_EQ(OK, rv); |
1994 | 1990 |
1995 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1991 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1996 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1992 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
1997 | 1993 |
1998 rv = callback.GetResult(sock->Connect(callback.callback())); | 1994 rv = callback.GetResult(sock->Connect(callback.callback())); |
1999 ASSERT_EQ(OK, rv); | 1995 ASSERT_EQ(OK, rv); |
2000 ASSERT_TRUE(sock->IsConnected()); | 1996 ASSERT_TRUE(sock->IsConnected()); |
2001 | 1997 |
2002 const char request_text[] = "GET /ssl-many-small-records HTTP/1.0\r\n\r\n"; | 1998 const char request_text[] = "GET /ssl-many-small-records HTTP/1.0\r\n\r\n"; |
2003 scoped_refptr<IOBuffer> request_buffer( | 1999 scoped_refptr<IOBuffer> request_buffer( |
2004 new IOBuffer(arraysize(request_text) - 1)); | 2000 new IOBuffer(arraysize(request_text) - 1)); |
2005 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 2001 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
2006 | 2002 |
(...skipping 29 matching lines...) Expand all Loading... |
2036 | 2032 |
2037 TestCompletionCallback callback; | 2033 TestCompletionCallback callback; |
2038 scoped_ptr<StreamSocket> transport( | 2034 scoped_ptr<StreamSocket> transport( |
2039 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2035 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2040 int rv = transport->Connect(callback.callback()); | 2036 int rv = transport->Connect(callback.callback()); |
2041 if (rv == ERR_IO_PENDING) | 2037 if (rv == ERR_IO_PENDING) |
2042 rv = callback.WaitForResult(); | 2038 rv = callback.WaitForResult(); |
2043 EXPECT_EQ(OK, rv); | 2039 EXPECT_EQ(OK, rv); |
2044 | 2040 |
2045 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2041 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2046 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2042 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2047 | 2043 |
2048 rv = sock->Connect(callback.callback()); | 2044 rv = sock->Connect(callback.callback()); |
2049 if (rv == ERR_IO_PENDING) | 2045 if (rv == ERR_IO_PENDING) |
2050 rv = callback.WaitForResult(); | 2046 rv = callback.WaitForResult(); |
2051 EXPECT_EQ(OK, rv); | 2047 EXPECT_EQ(OK, rv); |
2052 | 2048 |
2053 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 2049 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
2054 scoped_refptr<IOBuffer> request_buffer( | 2050 scoped_refptr<IOBuffer> request_buffer( |
2055 new IOBuffer(arraysize(request_text) - 1)); | 2051 new IOBuffer(arraysize(request_text) - 1)); |
2056 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 2052 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
(...skipping 30 matching lines...) Expand all Loading... |
2087 CapturingNetLog log; | 2083 CapturingNetLog log; |
2088 log.SetLogLevel(NetLog::LOG_ALL); | 2084 log.SetLogLevel(NetLog::LOG_ALL); |
2089 scoped_ptr<StreamSocket> transport( | 2085 scoped_ptr<StreamSocket> transport( |
2090 new TCPClientSocket(addr, &log, NetLog::Source())); | 2086 new TCPClientSocket(addr, &log, NetLog::Source())); |
2091 int rv = transport->Connect(callback.callback()); | 2087 int rv = transport->Connect(callback.callback()); |
2092 if (rv == ERR_IO_PENDING) | 2088 if (rv == ERR_IO_PENDING) |
2093 rv = callback.WaitForResult(); | 2089 rv = callback.WaitForResult(); |
2094 EXPECT_EQ(OK, rv); | 2090 EXPECT_EQ(OK, rv); |
2095 | 2091 |
2096 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2092 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2097 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2093 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2098 | 2094 |
2099 rv = sock->Connect(callback.callback()); | 2095 rv = sock->Connect(callback.callback()); |
2100 if (rv == ERR_IO_PENDING) | 2096 if (rv == ERR_IO_PENDING) |
2101 rv = callback.WaitForResult(); | 2097 rv = callback.WaitForResult(); |
2102 EXPECT_EQ(OK, rv); | 2098 EXPECT_EQ(OK, rv); |
2103 EXPECT_TRUE(sock->IsConnected()); | 2099 EXPECT_TRUE(sock->IsConnected()); |
2104 | 2100 |
2105 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 2101 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
2106 scoped_refptr<IOBuffer> request_buffer( | 2102 scoped_refptr<IOBuffer> request_buffer( |
2107 new IOBuffer(arraysize(request_text) - 1)); | 2103 new IOBuffer(arraysize(request_text) - 1)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 2169 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
2174 | 2170 |
2175 scoped_ptr<StreamSocket> transport( | 2171 scoped_ptr<StreamSocket> transport( |
2176 new MockTCPClientSocket(addr, NULL, &data)); | 2172 new MockTCPClientSocket(addr, NULL, &data)); |
2177 int rv = transport->Connect(callback.callback()); | 2173 int rv = transport->Connect(callback.callback()); |
2178 if (rv == ERR_IO_PENDING) | 2174 if (rv == ERR_IO_PENDING) |
2179 rv = callback.WaitForResult(); | 2175 rv = callback.WaitForResult(); |
2180 EXPECT_EQ(OK, rv); | 2176 EXPECT_EQ(OK, rv); |
2181 | 2177 |
2182 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2178 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2183 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2179 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2184 | 2180 |
2185 rv = sock->Connect(callback.callback()); | 2181 rv = sock->Connect(callback.callback()); |
2186 if (rv == ERR_IO_PENDING) | 2182 if (rv == ERR_IO_PENDING) |
2187 rv = callback.WaitForResult(); | 2183 rv = callback.WaitForResult(); |
2188 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); | 2184 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); |
2189 } | 2185 } |
2190 | 2186 |
2191 TEST_F(SSLClientSocketTest, CipherSuiteDisables) { | 2187 TEST_F(SSLClientSocketTest, CipherSuiteDisables) { |
2192 // Rather than exhaustively disabling every RC4 ciphersuite defined at | 2188 // Rather than exhaustively disabling every RC4 ciphersuite defined at |
2193 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, | 2189 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 scoped_ptr<StreamSocket> transport( | 2274 scoped_ptr<StreamSocket> transport( |
2279 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2275 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2280 int rv = transport->Connect(callback.callback()); | 2276 int rv = transport->Connect(callback.callback()); |
2281 if (rv == ERR_IO_PENDING) | 2277 if (rv == ERR_IO_PENDING) |
2282 rv = callback.WaitForResult(); | 2278 rv = callback.WaitForResult(); |
2283 EXPECT_EQ(OK, rv); | 2279 EXPECT_EQ(OK, rv); |
2284 | 2280 |
2285 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle()); | 2281 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle()); |
2286 socket_handle->SetSocket(transport.Pass()); | 2282 socket_handle->SetSocket(transport.Pass()); |
2287 | 2283 |
2288 scoped_ptr<SSLClientSocket> sock( | 2284 scoped_ptr<SSLClientSocket> sock(socket_factory_->CreateSSLClientSocket( |
2289 socket_factory_->CreateSSLClientSocket(socket_handle.Pass(), | 2285 socket_handle.Pass(), test_server.host_port_pair(), SSLConfig(), |
2290 test_server.host_port_pair(), | 2286 context_)); |
2291 kDefaultSSLConfig, | |
2292 context_)); | |
2293 | 2287 |
2294 EXPECT_FALSE(sock->IsConnected()); | 2288 EXPECT_FALSE(sock->IsConnected()); |
2295 rv = sock->Connect(callback.callback()); | 2289 rv = sock->Connect(callback.callback()); |
2296 if (rv == ERR_IO_PENDING) | 2290 if (rv == ERR_IO_PENDING) |
2297 rv = callback.WaitForResult(); | 2291 rv = callback.WaitForResult(); |
2298 EXPECT_EQ(OK, rv); | 2292 EXPECT_EQ(OK, rv); |
2299 } | 2293 } |
2300 | 2294 |
2301 // Verifies that SSLClientSocket::ExportKeyingMaterial return a success | 2295 // Verifies that SSLClientSocket::ExportKeyingMaterial return a success |
2302 // code and different keying label results in different keying material. | 2296 // code and different keying label results in different keying material. |
2303 TEST_F(SSLClientSocketTest, ExportKeyingMaterial) { | 2297 TEST_F(SSLClientSocketTest, ExportKeyingMaterial) { |
2304 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 2298 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, |
2305 SpawnedTestServer::kLocalhost, | 2299 SpawnedTestServer::kLocalhost, |
2306 base::FilePath()); | 2300 base::FilePath()); |
2307 ASSERT_TRUE(test_server.Start()); | 2301 ASSERT_TRUE(test_server.Start()); |
2308 | 2302 |
2309 AddressList addr; | 2303 AddressList addr; |
2310 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 2304 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
2311 | 2305 |
2312 TestCompletionCallback callback; | 2306 TestCompletionCallback callback; |
2313 | 2307 |
2314 scoped_ptr<StreamSocket> transport( | 2308 scoped_ptr<StreamSocket> transport( |
2315 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2309 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2316 int rv = transport->Connect(callback.callback()); | 2310 int rv = transport->Connect(callback.callback()); |
2317 if (rv == ERR_IO_PENDING) | 2311 if (rv == ERR_IO_PENDING) |
2318 rv = callback.WaitForResult(); | 2312 rv = callback.WaitForResult(); |
2319 EXPECT_EQ(OK, rv); | 2313 EXPECT_EQ(OK, rv); |
2320 | 2314 |
2321 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2315 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2322 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2316 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2323 | 2317 |
2324 rv = sock->Connect(callback.callback()); | 2318 rv = sock->Connect(callback.callback()); |
2325 if (rv == ERR_IO_PENDING) | 2319 if (rv == ERR_IO_PENDING) |
2326 rv = callback.WaitForResult(); | 2320 rv = callback.WaitForResult(); |
2327 EXPECT_EQ(OK, rv); | 2321 EXPECT_EQ(OK, rv); |
2328 EXPECT_TRUE(sock->IsConnected()); | 2322 EXPECT_TRUE(sock->IsConnected()); |
2329 | 2323 |
2330 const int kKeyingMaterialSize = 32; | 2324 const int kKeyingMaterialSize = 32; |
2331 const char* kKeyingLabel1 = "client-socket-test-1"; | 2325 const char* kKeyingLabel1 = "client-socket-test-1"; |
2332 const char* kKeyingContext = ""; | 2326 const char* kKeyingContext = ""; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 2391 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
2398 | 2392 |
2399 TestCompletionCallback callback; | 2393 TestCompletionCallback callback; |
2400 scoped_ptr<StreamSocket> transport( | 2394 scoped_ptr<StreamSocket> transport( |
2401 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2395 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2402 int rv = transport->Connect(callback.callback()); | 2396 int rv = transport->Connect(callback.callback()); |
2403 rv = callback.GetResult(rv); | 2397 rv = callback.GetResult(rv); |
2404 EXPECT_EQ(OK, rv); | 2398 EXPECT_EQ(OK, rv); |
2405 | 2399 |
2406 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2400 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2407 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2401 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2408 EXPECT_FALSE(sock->IsConnected()); | 2402 EXPECT_FALSE(sock->IsConnected()); |
2409 rv = sock->Connect(callback.callback()); | 2403 rv = sock->Connect(callback.callback()); |
2410 rv = callback.GetResult(rv); | 2404 rv = callback.GetResult(rv); |
2411 | 2405 |
2412 EXPECT_EQ(ERR_CERT_INVALID, rv); | 2406 EXPECT_EQ(ERR_CERT_INVALID, rv); |
2413 EXPECT_TRUE(sock->IsConnected()); | 2407 EXPECT_TRUE(sock->IsConnected()); |
2414 | 2408 |
2415 // When given option CERT_CHAIN_WRONG_ROOT, SpawnedTestServer will present | 2409 // When given option CERT_CHAIN_WRONG_ROOT, SpawnedTestServer will present |
2416 // certs from redundant-server-chain.pem. | 2410 // certs from redundant-server-chain.pem. |
2417 CertificateList server_certs = | 2411 CertificateList server_certs = |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 TestCompletionCallback callback; | 2498 TestCompletionCallback callback; |
2505 CapturingNetLog log; | 2499 CapturingNetLog log; |
2506 scoped_ptr<StreamSocket> transport( | 2500 scoped_ptr<StreamSocket> transport( |
2507 new TCPClientSocket(addr, &log, NetLog::Source())); | 2501 new TCPClientSocket(addr, &log, NetLog::Source())); |
2508 int rv = transport->Connect(callback.callback()); | 2502 int rv = transport->Connect(callback.callback()); |
2509 if (rv == ERR_IO_PENDING) | 2503 if (rv == ERR_IO_PENDING) |
2510 rv = callback.WaitForResult(); | 2504 rv = callback.WaitForResult(); |
2511 EXPECT_EQ(OK, rv); | 2505 EXPECT_EQ(OK, rv); |
2512 | 2506 |
2513 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2507 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2514 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2508 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2515 EXPECT_FALSE(sock->IsConnected()); | 2509 EXPECT_FALSE(sock->IsConnected()); |
2516 rv = sock->Connect(callback.callback()); | 2510 rv = sock->Connect(callback.callback()); |
2517 | 2511 |
2518 CapturingNetLog::CapturedEntryList entries; | 2512 CapturingNetLog::CapturedEntryList entries; |
2519 log.GetEntries(&entries); | 2513 log.GetEntries(&entries); |
2520 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); | 2514 EXPECT_TRUE(LogContainsBeginEvent(entries, 5, NetLog::TYPE_SSL_CONNECT)); |
2521 if (rv == ERR_IO_PENDING) | 2515 if (rv == ERR_IO_PENDING) |
2522 rv = callback.WaitForResult(); | 2516 rv = callback.WaitForResult(); |
2523 | 2517 |
2524 EXPECT_EQ(OK, rv); | 2518 EXPECT_EQ(OK, rv); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 | 2746 |
2753 TestCompletionCallback callback; | 2747 TestCompletionCallback callback; |
2754 scoped_ptr<StreamSocket> transport( | 2748 scoped_ptr<StreamSocket> transport( |
2755 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2749 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2756 int rv = transport->Connect(callback.callback()); | 2750 int rv = transport->Connect(callback.callback()); |
2757 if (rv == ERR_IO_PENDING) | 2751 if (rv == ERR_IO_PENDING) |
2758 rv = callback.WaitForResult(); | 2752 rv = callback.WaitForResult(); |
2759 EXPECT_EQ(OK, rv); | 2753 EXPECT_EQ(OK, rv); |
2760 | 2754 |
2761 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2755 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2762 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 2756 transport.Pass(), test_server.host_port_pair(), SSLConfig())); |
2763 | 2757 |
2764 rv = sock->Connect(callback.callback()); | 2758 rv = sock->Connect(callback.callback()); |
2765 if (rv == ERR_IO_PENDING) | 2759 if (rv == ERR_IO_PENDING) |
2766 rv = callback.WaitForResult(); | 2760 rv = callback.WaitForResult(); |
2767 EXPECT_EQ(OK, rv); | 2761 EXPECT_EQ(OK, rv); |
2768 | 2762 |
2769 // The socket was just connected. It should be idle because it is speaking | 2763 // The socket was just connected. It should be idle because it is speaking |
2770 // HTTP. Although the transport has been used for the handshake, WasEverUsed() | 2764 // HTTP. Although the transport has been used for the handshake, WasEverUsed() |
2771 // returns false. | 2765 // returns false. |
2772 EXPECT_TRUE(sock->IsConnected()); | 2766 EXPECT_TRUE(sock->IsConnected()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2848 | 2842 |
2849 scoped_ptr<StreamSocket> transport( | 2843 scoped_ptr<StreamSocket> transport( |
2850 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2844 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2851 | 2845 |
2852 TestCompletionCallback callback; | 2846 TestCompletionCallback callback; |
2853 int rv = transport->Connect(callback.callback()); | 2847 int rv = transport->Connect(callback.callback()); |
2854 if (rv == ERR_IO_PENDING) | 2848 if (rv == ERR_IO_PENDING) |
2855 rv = callback.WaitForResult(); | 2849 rv = callback.WaitForResult(); |
2856 EXPECT_EQ(OK, rv); | 2850 EXPECT_EQ(OK, rv); |
2857 | 2851 |
2858 SSLConfig ssl_config = kDefaultSSLConfig; | 2852 SSLConfig ssl_config; |
2859 ssl_config.false_start_enabled = false; | 2853 ssl_config.false_start_enabled = false; |
2860 | 2854 |
2861 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2855 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2862 transport.Pass(), test_server.host_port_pair(), ssl_config)); | 2856 transport.Pass(), test_server.host_port_pair(), ssl_config)); |
2863 | 2857 |
2864 sock->SetHandshakeCompletionCallback(base::Bind( | 2858 sock->SetHandshakeCompletionCallback(base::Bind( |
2865 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); | 2859 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); |
2866 | 2860 |
2867 rv = callback.GetResult(sock->Connect(callback.callback())); | 2861 rv = callback.GetResult(sock->Connect(callback.callback())); |
2868 | 2862 |
(...skipping 16 matching lines...) Expand all Loading... |
2885 | 2879 |
2886 scoped_ptr<StreamSocket> transport( | 2880 scoped_ptr<StreamSocket> transport( |
2887 new TCPClientSocket(addr, NULL, NetLog::Source())); | 2881 new TCPClientSocket(addr, NULL, NetLog::Source())); |
2888 | 2882 |
2889 TestCompletionCallback callback; | 2883 TestCompletionCallback callback; |
2890 int rv = transport->Connect(callback.callback()); | 2884 int rv = transport->Connect(callback.callback()); |
2891 if (rv == ERR_IO_PENDING) | 2885 if (rv == ERR_IO_PENDING) |
2892 rv = callback.WaitForResult(); | 2886 rv = callback.WaitForResult(); |
2893 EXPECT_EQ(OK, rv); | 2887 EXPECT_EQ(OK, rv); |
2894 | 2888 |
2895 SSLConfig ssl_config = kDefaultSSLConfig; | 2889 SSLConfig ssl_config; |
2896 ssl_config.false_start_enabled = false; | 2890 ssl_config.false_start_enabled = false; |
2897 | 2891 |
2898 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2892 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
2899 transport.Pass(), test_server.host_port_pair(), ssl_config)); | 2893 transport.Pass(), test_server.host_port_pair(), ssl_config)); |
2900 | 2894 |
2901 sock->SetHandshakeCompletionCallback(base::Bind( | 2895 sock->SetHandshakeCompletionCallback(base::Bind( |
2902 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); | 2896 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); |
2903 | 2897 |
2904 rv = callback.GetResult(sock->Connect(callback.callback())); | 2898 rv = callback.GetResult(sock->Connect(callback.callback())); |
2905 | 2899 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3045 EXPECT_EQ(SSLInfo::HANDSHAKE_FULL, ssl_info.handshake_type); | 3039 EXPECT_EQ(SSLInfo::HANDSHAKE_FULL, ssl_info.handshake_type); |
3046 } | 3040 } |
3047 | 3041 |
3048 // Connect to a server using channel id. It should allow the connection. | 3042 // Connect to a server using channel id. It should allow the connection. |
3049 TEST_F(SSLClientSocketChannelIDTest, SendChannelID) { | 3043 TEST_F(SSLClientSocketChannelIDTest, SendChannelID) { |
3050 SpawnedTestServer::SSLOptions ssl_options; | 3044 SpawnedTestServer::SSLOptions ssl_options; |
3051 | 3045 |
3052 ASSERT_TRUE(ConnectToTestServer(ssl_options)); | 3046 ASSERT_TRUE(ConnectToTestServer(ssl_options)); |
3053 | 3047 |
3054 EnableChannelID(); | 3048 EnableChannelID(); |
3055 SSLConfig ssl_config = kDefaultSSLConfig; | 3049 SSLConfig ssl_config; |
3056 ssl_config.channel_id_enabled = true; | 3050 ssl_config.channel_id_enabled = true; |
3057 | 3051 |
3058 int rv; | 3052 int rv; |
3059 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3053 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
3060 | 3054 |
3061 EXPECT_EQ(OK, rv); | 3055 EXPECT_EQ(OK, rv); |
3062 EXPECT_TRUE(sock_->IsConnected()); | 3056 EXPECT_TRUE(sock_->IsConnected()); |
3063 EXPECT_TRUE(sock_->WasChannelIDSent()); | 3057 EXPECT_TRUE(sock_->WasChannelIDSent()); |
3064 | 3058 |
3065 sock_->Disconnect(); | 3059 sock_->Disconnect(); |
3066 EXPECT_FALSE(sock_->IsConnected()); | 3060 EXPECT_FALSE(sock_->IsConnected()); |
3067 } | 3061 } |
3068 | 3062 |
3069 // Connect to a server using Channel ID but failing to look up the Channel | 3063 // Connect to a server using Channel ID but failing to look up the Channel |
3070 // ID. It should fail. | 3064 // ID. It should fail. |
3071 TEST_F(SSLClientSocketChannelIDTest, FailingChannelID) { | 3065 TEST_F(SSLClientSocketChannelIDTest, FailingChannelID) { |
3072 SpawnedTestServer::SSLOptions ssl_options; | 3066 SpawnedTestServer::SSLOptions ssl_options; |
3073 | 3067 |
3074 ASSERT_TRUE(ConnectToTestServer(ssl_options)); | 3068 ASSERT_TRUE(ConnectToTestServer(ssl_options)); |
3075 | 3069 |
3076 EnableFailingChannelID(); | 3070 EnableFailingChannelID(); |
3077 SSLConfig ssl_config = kDefaultSSLConfig; | 3071 SSLConfig ssl_config; |
3078 ssl_config.channel_id_enabled = true; | 3072 ssl_config.channel_id_enabled = true; |
3079 | 3073 |
3080 int rv; | 3074 int rv; |
3081 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3075 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
3082 | 3076 |
3083 // TODO(haavardm@opera.com): Due to differences in threading, Linux returns | 3077 // TODO(haavardm@opera.com): Due to differences in threading, Linux returns |
3084 // ERR_UNEXPECTED while Mac and Windows return ERR_PROTOCOL_ERROR. Accept all | 3078 // ERR_UNEXPECTED while Mac and Windows return ERR_PROTOCOL_ERROR. Accept all |
3085 // error codes for now. | 3079 // error codes for now. |
3086 // http://crbug.com/373670 | 3080 // http://crbug.com/373670 |
3087 EXPECT_NE(OK, rv); | 3081 EXPECT_NE(OK, rv); |
3088 EXPECT_FALSE(sock_->IsConnected()); | 3082 EXPECT_FALSE(sock_->IsConnected()); |
3089 } | 3083 } |
3090 | 3084 |
3091 // Connect to a server using Channel ID but asynchronously failing to look up | 3085 // Connect to a server using Channel ID but asynchronously failing to look up |
3092 // the Channel ID. It should fail. | 3086 // the Channel ID. It should fail. |
3093 TEST_F(SSLClientSocketChannelIDTest, FailingChannelIDAsync) { | 3087 TEST_F(SSLClientSocketChannelIDTest, FailingChannelIDAsync) { |
3094 SpawnedTestServer::SSLOptions ssl_options; | 3088 SpawnedTestServer::SSLOptions ssl_options; |
3095 | 3089 |
3096 ASSERT_TRUE(ConnectToTestServer(ssl_options)); | 3090 ASSERT_TRUE(ConnectToTestServer(ssl_options)); |
3097 | 3091 |
3098 EnableAsyncFailingChannelID(); | 3092 EnableAsyncFailingChannelID(); |
3099 SSLConfig ssl_config = kDefaultSSLConfig; | 3093 SSLConfig ssl_config; |
3100 ssl_config.channel_id_enabled = true; | 3094 ssl_config.channel_id_enabled = true; |
3101 | 3095 |
3102 int rv; | 3096 int rv; |
3103 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3097 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
3104 | 3098 |
3105 EXPECT_EQ(ERR_UNEXPECTED, rv); | 3099 EXPECT_EQ(ERR_UNEXPECTED, rv); |
3106 EXPECT_FALSE(sock_->IsConnected()); | 3100 EXPECT_FALSE(sock_->IsConnected()); |
3107 } | 3101 } |
3108 | 3102 |
3109 } // namespace net | 3103 } // namespace net |
OLD | NEW |