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/socket_test_util.h" | 5 #include "net/socket/socket_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "net/base/address_family.h" | 17 #include "net/base/address_family.h" |
18 #include "net/base/address_list.h" | 18 #include "net/base/address_list.h" |
19 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
20 #include "net/base/load_timing_info.h" | 20 #include "net/base/load_timing_info.h" |
21 #include "net/http/http_network_session.h" | 21 #include "net/http/http_network_session.h" |
22 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
23 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
24 #include "net/socket/client_socket_pool_histograms.h" | 24 #include "net/socket/client_socket_pool_histograms.h" |
25 #include "net/socket/socket.h" | 25 #include "net/socket/socket.h" |
26 #include "net/ssl/ssl_cert_request_info.h" | 26 #include "net/ssl/ssl_cert_request_info.h" |
| 27 #include "net/ssl/ssl_connection_status_flags.h" |
27 #include "net/ssl/ssl_info.h" | 28 #include "net/ssl/ssl_info.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 | 30 |
30 // Socket events are easier to debug if you log individual reads and writes. | 31 // Socket events are easier to debug if you log individual reads and writes. |
31 // Enable these if locally debugging, but they are too noisy for the waterfall. | 32 // Enable these if locally debugging, but they are too noisy for the waterfall. |
32 #if 0 | 33 #if 0 |
33 #define NET_TRACE(level, s) DLOG(level) << s << __FUNCTION__ << "() " | 34 #define NET_TRACE(level, s) DLOG(level) << s << __FUNCTION__ << "() " |
34 #else | 35 #else |
35 #define NET_TRACE(level, s) EAT_STREAM_PARAMETERS | 36 #define NET_TRACE(level, s) EAT_STREAM_PARAMETERS |
36 #endif | 37 #endif |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 reads_.push_back(MockRead(ASYNC, data, length)); | 269 reads_.push_back(MockRead(ASYNC, data, length)); |
269 } | 270 } |
270 | 271 |
271 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) | 272 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) |
272 : connect(mode, result), | 273 : connect(mode, result), |
273 next_proto_status(SSLClientSocket::kNextProtoUnsupported), | 274 next_proto_status(SSLClientSocket::kNextProtoUnsupported), |
274 was_npn_negotiated(false), | 275 was_npn_negotiated(false), |
275 protocol_negotiated(kProtoUnknown), | 276 protocol_negotiated(kProtoUnknown), |
276 client_cert_sent(false), | 277 client_cert_sent(false), |
277 cert_request_info(NULL), | 278 cert_request_info(NULL), |
278 channel_id_sent(false) { | 279 channel_id_sent(false), |
| 280 connection_status(0) { |
| 281 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2, |
| 282 &connection_status); |
| 283 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 |
| 284 SSLConnectionStatusSetCipherSuite(0xcc14, &connection_status); |
279 } | 285 } |
280 | 286 |
281 SSLSocketDataProvider::~SSLSocketDataProvider() { | 287 SSLSocketDataProvider::~SSLSocketDataProvider() { |
282 } | 288 } |
283 | 289 |
284 void SSLSocketDataProvider::SetNextProto(NextProto proto) { | 290 void SSLSocketDataProvider::SetNextProto(NextProto proto) { |
285 was_npn_negotiated = true; | 291 was_npn_negotiated = true; |
286 next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 292 next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
287 protocol_negotiated = proto; | 293 protocol_negotiated = proto; |
288 next_proto = SSLClientSocket::NextProtoToString(proto); | 294 next_proto = SSLClientSocket::NextProtoToString(proto); |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 | 1376 |
1371 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { | 1377 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { |
1372 return transport_->socket()->GetPeerAddress(address); | 1378 return transport_->socket()->GetPeerAddress(address); |
1373 } | 1379 } |
1374 | 1380 |
1375 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1381 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
1376 ssl_info->Reset(); | 1382 ssl_info->Reset(); |
1377 ssl_info->cert = data_->cert; | 1383 ssl_info->cert = data_->cert; |
1378 ssl_info->client_cert_sent = data_->client_cert_sent; | 1384 ssl_info->client_cert_sent = data_->client_cert_sent; |
1379 ssl_info->channel_id_sent = data_->channel_id_sent; | 1385 ssl_info->channel_id_sent = data_->channel_id_sent; |
| 1386 ssl_info->connection_status = data_->connection_status; |
1380 return true; | 1387 return true; |
1381 } | 1388 } |
1382 | 1389 |
1383 void MockSSLClientSocket::GetSSLCertRequestInfo( | 1390 void MockSSLClientSocket::GetSSLCertRequestInfo( |
1384 SSLCertRequestInfo* cert_request_info) { | 1391 SSLCertRequestInfo* cert_request_info) { |
1385 DCHECK(cert_request_info); | 1392 DCHECK(cert_request_info); |
1386 if (data_->cert_request_info) { | 1393 if (data_->cert_request_info) { |
1387 cert_request_info->host_and_port = | 1394 cert_request_info->host_and_port = |
1388 data_->cert_request_info->host_and_port; | 1395 data_->cert_request_info->host_and_port; |
1389 cert_request_info->client_certs = data_->cert_request_info->client_certs; | 1396 cert_request_info->client_certs = data_->cert_request_info->client_certs; |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 | 1906 |
1900 const char kSOCKS5OkRequest[] = | 1907 const char kSOCKS5OkRequest[] = |
1901 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1908 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1902 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1909 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1903 | 1910 |
1904 const char kSOCKS5OkResponse[] = | 1911 const char kSOCKS5OkResponse[] = |
1905 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1912 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1906 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1913 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1907 | 1914 |
1908 } // namespace net | 1915 } // namespace net |
OLD | NEW |