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