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" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 reads_.push_back(MockRead(ASYNC, data, length)); | 235 reads_.push_back(MockRead(ASYNC, data, length)); |
236 } | 236 } |
237 | 237 |
238 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) | 238 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) |
239 : connect(mode, result), | 239 : connect(mode, result), |
240 next_proto_status(SSLClientSocket::kNextProtoUnsupported), | 240 next_proto_status(SSLClientSocket::kNextProtoUnsupported), |
241 was_npn_negotiated(false), | 241 was_npn_negotiated(false), |
242 protocol_negotiated(SSLClientSocket::kProtoUnknown), | 242 protocol_negotiated(SSLClientSocket::kProtoUnknown), |
243 client_cert_sent(false), | 243 client_cert_sent(false), |
244 cert_request_info(NULL), | 244 cert_request_info(NULL), |
245 origin_bound_cert_type(CLIENT_CERT_INVALID_TYPE) { | 245 domain_bound_cert_type(CLIENT_CERT_INVALID_TYPE) { |
246 } | 246 } |
247 | 247 |
248 SSLSocketDataProvider::~SSLSocketDataProvider() { | 248 SSLSocketDataProvider::~SSLSocketDataProvider() { |
249 } | 249 } |
250 | 250 |
251 void SSLSocketDataProvider::SetNextProto(SSLClientSocket::NextProto proto) { | 251 void SSLSocketDataProvider::SetNextProto(SSLClientSocket::NextProto proto) { |
252 was_npn_negotiated = true; | 252 was_npn_negotiated = true; |
253 next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 253 next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
254 protocol_negotiated = proto; | 254 protocol_negotiated = proto; |
255 next_proto = SSLClientSocket::NextProtoToString(proto); | 255 next_proto = SSLClientSocket::NextProtoToString(proto); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 689 |
690 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, | 690 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, |
691 bool has_context, | 691 bool has_context, |
692 const base::StringPiece& context, | 692 const base::StringPiece& context, |
693 unsigned char* out, | 693 unsigned char* out, |
694 unsigned int outlen) { | 694 unsigned int outlen) { |
695 memset(out, 'A', outlen); | 695 memset(out, 'A', outlen); |
696 return OK; | 696 return OK; |
697 } | 697 } |
698 | 698 |
699 OriginBoundCertService* MockClientSocket::GetOriginBoundCertService() const { | 699 ServerBoundCertService* MockClientSocket::GetServerBoundCertService() const { |
700 NOTREACHED(); | 700 NOTREACHED(); |
701 return NULL; | 701 return NULL; |
702 } | 702 } |
703 | 703 |
704 SSLClientSocket::NextProtoStatus | 704 SSLClientSocket::NextProtoStatus |
705 MockClientSocket::GetNextProto(std::string* proto, std::string* server_protos) { | 705 MockClientSocket::GetNextProto(std::string* proto, std::string* server_protos) { |
706 proto->clear(); | 706 proto->clear(); |
707 server_protos->clear(); | 707 server_protos->clear(); |
708 return SSLClientSocket::kNextProtoUnsupported; | 708 return SSLClientSocket::kNextProtoUnsupported; |
709 } | 709 } |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 return -1; | 1125 return -1; |
1126 } | 1126 } |
1127 | 1127 |
1128 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const { | 1128 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const { |
1129 return base::TimeDelta::FromMicroseconds(-1); | 1129 return base::TimeDelta::FromMicroseconds(-1); |
1130 } | 1130 } |
1131 | 1131 |
1132 void MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1132 void MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
1133 ssl_info->Reset(); | 1133 ssl_info->Reset(); |
1134 ssl_info->cert = data_->cert; | 1134 ssl_info->cert = data_->cert; |
1135 ssl_info->client_cert_sent = WasOriginBoundCertSent() || | 1135 ssl_info->client_cert_sent = WasDomainBoundCertSent() || |
1136 data_->client_cert_sent; | 1136 data_->client_cert_sent; |
1137 } | 1137 } |
1138 | 1138 |
1139 void MockSSLClientSocket::GetSSLCertRequestInfo( | 1139 void MockSSLClientSocket::GetSSLCertRequestInfo( |
1140 SSLCertRequestInfo* cert_request_info) { | 1140 SSLCertRequestInfo* cert_request_info) { |
1141 DCHECK(cert_request_info); | 1141 DCHECK(cert_request_info); |
1142 if (data_->cert_request_info) { | 1142 if (data_->cert_request_info) { |
1143 cert_request_info->host_and_port = | 1143 cert_request_info->host_and_port = |
1144 data_->cert_request_info->host_and_port; | 1144 data_->cert_request_info->host_and_port; |
1145 cert_request_info->client_certs = data_->cert_request_info->client_certs; | 1145 cert_request_info->client_certs = data_->cert_request_info->client_certs; |
(...skipping 25 matching lines...) Expand all Loading... |
1171 return protocol_negotiated_; | 1171 return protocol_negotiated_; |
1172 return data_->protocol_negotiated; | 1172 return data_->protocol_negotiated; |
1173 } | 1173 } |
1174 | 1174 |
1175 void MockSSLClientSocket::set_protocol_negotiated( | 1175 void MockSSLClientSocket::set_protocol_negotiated( |
1176 SSLClientSocket::NextProto protocol_negotiated) { | 1176 SSLClientSocket::NextProto protocol_negotiated) { |
1177 is_protocol_negotiated_set_ = true; | 1177 is_protocol_negotiated_set_ = true; |
1178 protocol_negotiated_ = protocol_negotiated; | 1178 protocol_negotiated_ = protocol_negotiated; |
1179 } | 1179 } |
1180 | 1180 |
1181 bool MockSSLClientSocket::WasOriginBoundCertSent() const { | 1181 bool MockSSLClientSocket::WasDomainBoundCertSent() const { |
1182 return data_->origin_bound_cert_type != CLIENT_CERT_INVALID_TYPE; | 1182 return data_->domain_bound_cert_type != CLIENT_CERT_INVALID_TYPE; |
1183 } | 1183 } |
1184 | 1184 |
1185 SSLClientCertType MockSSLClientSocket::origin_bound_cert_type() const { | 1185 SSLClientCertType MockSSLClientSocket::domain_bound_cert_type() const { |
1186 return data_->origin_bound_cert_type; | 1186 return data_->domain_bound_cert_type; |
1187 } | 1187 } |
1188 | 1188 |
1189 SSLClientCertType MockSSLClientSocket::set_origin_bound_cert_type( | 1189 SSLClientCertType MockSSLClientSocket::set_domain_bound_cert_type( |
1190 SSLClientCertType type) { | 1190 SSLClientCertType type) { |
1191 return data_->origin_bound_cert_type = type; | 1191 return data_->domain_bound_cert_type = type; |
1192 } | 1192 } |
1193 | 1193 |
1194 OriginBoundCertService* MockSSLClientSocket::GetOriginBoundCertService() const { | 1194 ServerBoundCertService* MockSSLClientSocket::GetServerBoundCertService() const { |
1195 return data_->origin_bound_cert_service; | 1195 return data_->server_bound_cert_service; |
1196 } | 1196 } |
1197 | 1197 |
1198 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { | 1198 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { |
1199 NOTIMPLEMENTED(); | 1199 NOTIMPLEMENTED(); |
1200 } | 1200 } |
1201 | 1201 |
1202 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, | 1202 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, |
1203 net::NetLog* net_log) | 1203 net::NetLog* net_log) |
1204 : connected_(false), | 1204 : connected_(false), |
1205 data_(data), | 1205 data_(data), |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 | 1620 |
1621 const char kSOCKS5OkRequest[] = | 1621 const char kSOCKS5OkRequest[] = |
1622 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1622 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1623 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1623 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1624 | 1624 |
1625 const char kSOCKS5OkResponse[] = | 1625 const char kSOCKS5OkResponse[] = |
1626 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1626 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1627 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1627 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1628 | 1628 |
1629 } // namespace net | 1629 } // namespace net |
OLD | NEW |