Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: net/socket/socket_test_util.cc

Issue 10690122: Change SpdySession::GetSSLInfo to get the SSLInfo from the underlying socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actual working test Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip); 697 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip);
698 CHECK(rv); 698 CHECK(rv);
699 *address = IPEndPoint(ip, 123); 699 *address = IPEndPoint(ip, 123);
700 return OK; 700 return OK;
701 } 701 }
702 702
703 const BoundNetLog& MockClientSocket::NetLog() const { 703 const BoundNetLog& MockClientSocket::NetLog() const {
704 return net_log_; 704 return net_log_;
705 } 705 }
706 706
707 void MockClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
708 NOTREACHED();
709 }
710
711 void MockClientSocket::GetSSLCertRequestInfo( 707 void MockClientSocket::GetSSLCertRequestInfo(
712 SSLCertRequestInfo* cert_request_info) { 708 SSLCertRequestInfo* cert_request_info) {
713 } 709 }
714 710
715 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, 711 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label,
716 bool has_context, 712 bool has_context,
717 const base::StringPiece& context, 713 const base::StringPiece& context,
718 unsigned char* out, 714 unsigned char* out,
719 unsigned int outlen) { 715 unsigned int outlen) {
720 memset(out, 'A', outlen); 716 memset(out, 'A', outlen);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 return num_bytes_read_; 861 return num_bytes_read_;
866 } 862 }
867 863
868 base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const { 864 base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const {
869 // Dummy value. 865 // Dummy value.
870 static const base::TimeDelta kTestingConnectTimeMicros = 866 static const base::TimeDelta kTestingConnectTimeMicros =
871 base::TimeDelta::FromMicroseconds(20); 867 base::TimeDelta::FromMicroseconds(20);
872 return kTestingConnectTimeMicros; 868 return kTestingConnectTimeMicros;
873 } 869 }
874 870
871 bool MockTCPClientSocket::WasNpnNegotiated() const {
872 return false;
873 }
874
875 bool MockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) const {
876 return false;
877 }
878
875 void MockTCPClientSocket::OnReadComplete(const MockRead& data) { 879 void MockTCPClientSocket::OnReadComplete(const MockRead& data) {
876 // There must be a read pending. 880 // There must be a read pending.
877 DCHECK(pending_buf_); 881 DCHECK(pending_buf_);
878 // You can't complete a read with another ERR_IO_PENDING status code. 882 // You can't complete a read with another ERR_IO_PENDING status code.
879 DCHECK_NE(ERR_IO_PENDING, data.result); 883 DCHECK_NE(ERR_IO_PENDING, data.result);
880 // Since we've been waiting for data, need_read_data_ should be true. 884 // Since we've been waiting for data, need_read_data_ should be true.
881 DCHECK(need_read_data_); 885 DCHECK(need_read_data_);
882 886
883 read_data_ = data; 887 read_data_ = data;
884 need_read_data_ = false; 888 need_read_data_ = false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 DeterministicMockTCPClientSocket::DeterministicMockTCPClientSocket( 939 DeterministicMockTCPClientSocket::DeterministicMockTCPClientSocket(
936 net::NetLog* net_log, DeterministicSocketData* data) 940 net::NetLog* net_log, DeterministicSocketData* data)
937 : MockClientSocket(net_log), 941 : MockClientSocket(net_log),
938 write_pending_(false), 942 write_pending_(false),
939 write_result_(0), 943 write_result_(0),
940 read_data_(), 944 read_data_(),
941 read_buf_(NULL), 945 read_buf_(NULL),
942 read_buf_len_(0), 946 read_buf_len_(0),
943 read_pending_(false), 947 read_pending_(false),
944 data_(data), 948 data_(data),
945 was_used_to_convey_data_(false) {} 949 was_used_to_convey_data_(false) {
950 peer_addr_ = data->connect_data().peer_addr;
951 }
946 952
947 DeterministicMockTCPClientSocket::~DeterministicMockTCPClientSocket() {} 953 DeterministicMockTCPClientSocket::~DeterministicMockTCPClientSocket() {}
948 954
949 void DeterministicMockTCPClientSocket::CompleteWrite() { 955 void DeterministicMockTCPClientSocket::CompleteWrite() {
950 was_used_to_convey_data_ = true; 956 was_used_to_convey_data_ = true;
951 write_pending_ = false; 957 write_pending_ = false;
952 write_callback_.Run(write_result_); 958 write_callback_.Run(write_result_);
953 } 959 }
954 960
955 int DeterministicMockTCPClientSocket::CompleteRead() { 961 int DeterministicMockTCPClientSocket::CompleteRead() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 } 1068 }
1063 1069
1064 int64 DeterministicMockTCPClientSocket::NumBytesRead() const { 1070 int64 DeterministicMockTCPClientSocket::NumBytesRead() const {
1065 return -1; 1071 return -1;
1066 } 1072 }
1067 1073
1068 base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const { 1074 base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const {
1069 return base::TimeDelta::FromMicroseconds(-1); 1075 return base::TimeDelta::FromMicroseconds(-1);
1070 } 1076 }
1071 1077
1078 bool DeterministicMockTCPClientSocket::WasNpnNegotiated() const {
1079 return false;
1080 }
1081
1082 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) const {
1083 return false;
1084 }
1085
1072 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} 1086 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {}
1073 1087
1074 // static 1088 // static
1075 void MockSSLClientSocket::ConnectCallback( 1089 void MockSSLClientSocket::ConnectCallback(
1076 MockSSLClientSocket *ssl_client_socket, 1090 MockSSLClientSocket *ssl_client_socket,
1077 const CompletionCallback& callback, 1091 const CompletionCallback& callback,
1078 int rv) { 1092 int rv) {
1079 if (rv == OK) 1093 if (rv == OK)
1080 ssl_client_socket->connected_ = true; 1094 ssl_client_socket->connected_ = true;
1081 callback.Run(rv); 1095 callback.Run(rv);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 } 1163 }
1150 1164
1151 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { 1165 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const {
1152 return transport_->socket()->GetPeerAddress(address); 1166 return transport_->socket()->GetPeerAddress(address);
1153 } 1167 }
1154 1168
1155 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const { 1169 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const {
1156 return base::TimeDelta::FromMicroseconds(-1); 1170 return base::TimeDelta::FromMicroseconds(-1);
1157 } 1171 }
1158 1172
1159 void MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { 1173 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) const {
1160 ssl_info->Reset(); 1174 ssl_info->Reset();
1161 ssl_info->cert = data_->cert; 1175 ssl_info->cert = data_->cert;
1162 ssl_info->client_cert_sent = data_->client_cert_sent; 1176 ssl_info->client_cert_sent = data_->client_cert_sent;
1163 ssl_info->channel_id_sent = data_->channel_id_sent; 1177 ssl_info->channel_id_sent = data_->channel_id_sent;
1178 return true;
1164 } 1179 }
1165 1180
1166 void MockSSLClientSocket::GetSSLCertRequestInfo( 1181 void MockSSLClientSocket::GetSSLCertRequestInfo(
1167 SSLCertRequestInfo* cert_request_info) { 1182 SSLCertRequestInfo* cert_request_info) {
1168 DCHECK(cert_request_info); 1183 DCHECK(cert_request_info);
1169 if (data_->cert_request_info) { 1184 if (data_->cert_request_info) {
1170 cert_request_info->host_and_port = 1185 cert_request_info->host_and_port =
1171 data_->cert_request_info->host_and_port; 1186 data_->cert_request_info->host_and_port;
1172 cert_request_info->client_certs = data_->cert_request_info->client_certs; 1187 cert_request_info->client_certs = data_->cert_request_info->client_certs;
1173 } else { 1188 } else {
(...skipping 12 matching lines...) Expand all
1186 if (is_npn_state_set_) 1201 if (is_npn_state_set_)
1187 return new_npn_value_; 1202 return new_npn_value_;
1188 return data_->was_npn_negotiated; 1203 return data_->was_npn_negotiated;
1189 } 1204 }
1190 1205
1191 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { 1206 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) {
1192 is_npn_state_set_ = true; 1207 is_npn_state_set_ = true;
1193 return new_npn_value_ = negotiated; 1208 return new_npn_value_ = negotiated;
1194 } 1209 }
1195 1210
1211 bool MockSSLClientSocket::WasNpnNegotiated() const {
1212 return was_npn_negotiated();
1213 }
1214
1196 NextProto MockSSLClientSocket::GetNegotiatedProtocol() const { 1215 NextProto MockSSLClientSocket::GetNegotiatedProtocol() const {
1197 if (is_protocol_negotiated_set_) 1216 if (is_protocol_negotiated_set_)
1198 return protocol_negotiated_; 1217 return protocol_negotiated_;
1199 return data_->protocol_negotiated; 1218 return data_->protocol_negotiated;
1200 } 1219 }
1201 1220
1202 void MockSSLClientSocket::set_protocol_negotiated( 1221 void MockSSLClientSocket::set_protocol_negotiated(
1203 NextProto protocol_negotiated) { 1222 NextProto protocol_negotiated) {
1204 is_protocol_negotiated_set_ = true; 1223 is_protocol_negotiated_set_ = true;
1205 protocol_negotiated_ = protocol_negotiated; 1224 protocol_negotiated_ = protocol_negotiated;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 1660
1642 const char kSOCKS5OkRequest[] = 1661 const char kSOCKS5OkRequest[] =
1643 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 1662 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1644 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 1663 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1645 1664
1646 const char kSOCKS5OkResponse[] = 1665 const char kSOCKS5OkResponse[] =
1647 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 1666 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1648 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 1667 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1649 1668
1650 } // namespace net 1669 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698