| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 void StaticSocketDataProvider::Reset() { | 280 void StaticSocketDataProvider::Reset() { |
| 281 helper_.Reset(); | 281 helper_.Reset(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) | 284 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) |
| 285 : connect(mode, result), | 285 : connect(mode, result), |
| 286 next_proto_status(SSLClientSocket::kNextProtoUnsupported), | 286 next_proto_status(SSLClientSocket::kNextProtoUnsupported), |
| 287 client_cert_sent(false), | 287 client_cert_sent(false), |
| 288 cert_request_info(NULL), | 288 cert_request_info(NULL), |
| 289 channel_id_sent(false), | 289 channel_id_sent(false), |
| 290 connection_status(0) { | 290 connection_status(0), |
| 291 token_binding_negotiated(false) { |
| 291 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2, | 292 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2, |
| 292 &connection_status); | 293 &connection_status); |
| 293 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 | 294 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 |
| 294 SSLConnectionStatusSetCipherSuite(0xcc14, &connection_status); | 295 SSLConnectionStatusSetCipherSuite(0xcc14, &connection_status); |
| 295 } | 296 } |
| 296 | 297 |
| 297 SSLSocketDataProvider::~SSLSocketDataProvider() { | 298 SSLSocketDataProvider::~SSLSocketDataProvider() { |
| 298 } | 299 } |
| 299 | 300 |
| 300 void SSLSocketDataProvider::SetNextProto(NextProto proto) { | 301 void SSLSocketDataProvider::SetNextProto(NextProto proto) { |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 int MockClientSocket::GetTLSUniqueChannelBinding(std::string* out) { | 820 int MockClientSocket::GetTLSUniqueChannelBinding(std::string* out) { |
| 820 out->assign(MockClientSocket::kTlsUnique); | 821 out->assign(MockClientSocket::kTlsUnique); |
| 821 return OK; | 822 return OK; |
| 822 } | 823 } |
| 823 | 824 |
| 824 ChannelIDService* MockClientSocket::GetChannelIDService() const { | 825 ChannelIDService* MockClientSocket::GetChannelIDService() const { |
| 825 NOTREACHED(); | 826 NOTREACHED(); |
| 826 return NULL; | 827 return NULL; |
| 827 } | 828 } |
| 828 | 829 |
| 830 int MockClientSocket::GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 831 std::vector<uint8_t>* out) { |
| 832 NOTREACHED(); |
| 833 return ERR_NOT_IMPLEMENTED; |
| 834 } |
| 835 |
| 829 SSLFailureState MockClientSocket::GetSSLFailureState() const { | 836 SSLFailureState MockClientSocket::GetSSLFailureState() const { |
| 830 return IsConnected() ? SSL_FAILURE_NONE : SSL_FAILURE_UNKNOWN; | 837 return IsConnected() ? SSL_FAILURE_NONE : SSL_FAILURE_UNKNOWN; |
| 831 } | 838 } |
| 832 | 839 |
| 833 SSLClientSocket::NextProtoStatus MockClientSocket::GetNextProto( | 840 SSLClientSocket::NextProtoStatus MockClientSocket::GetNextProto( |
| 834 std::string* proto) const { | 841 std::string* proto) const { |
| 835 proto->clear(); | 842 proto->clear(); |
| 836 return SSLClientSocket::kNextProtoUnsupported; | 843 return SSLClientSocket::kNextProtoUnsupported; |
| 837 } | 844 } |
| 838 | 845 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { | 1199 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { |
| 1193 return transport_->socket()->GetPeerAddress(address); | 1200 return transport_->socket()->GetPeerAddress(address); |
| 1194 } | 1201 } |
| 1195 | 1202 |
| 1196 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1203 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
| 1197 ssl_info->Reset(); | 1204 ssl_info->Reset(); |
| 1198 ssl_info->cert = data_->cert; | 1205 ssl_info->cert = data_->cert; |
| 1199 ssl_info->client_cert_sent = data_->client_cert_sent; | 1206 ssl_info->client_cert_sent = data_->client_cert_sent; |
| 1200 ssl_info->channel_id_sent = data_->channel_id_sent; | 1207 ssl_info->channel_id_sent = data_->channel_id_sent; |
| 1201 ssl_info->connection_status = data_->connection_status; | 1208 ssl_info->connection_status = data_->connection_status; |
| 1209 ssl_info->token_binding_negotiated = data_->token_binding_negotiated; |
| 1210 ssl_info->token_binding_key_param = data_->token_binding_key_param; |
| 1202 return true; | 1211 return true; |
| 1203 } | 1212 } |
| 1204 | 1213 |
| 1205 void MockSSLClientSocket::GetSSLCertRequestInfo( | 1214 void MockSSLClientSocket::GetSSLCertRequestInfo( |
| 1206 SSLCertRequestInfo* cert_request_info) { | 1215 SSLCertRequestInfo* cert_request_info) { |
| 1207 DCHECK(cert_request_info); | 1216 DCHECK(cert_request_info); |
| 1208 if (data_->cert_request_info) { | 1217 if (data_->cert_request_info) { |
| 1209 cert_request_info->host_and_port = | 1218 cert_request_info->host_and_port = |
| 1210 data_->cert_request_info->host_and_port; | 1219 data_->cert_request_info->host_and_port; |
| 1211 cert_request_info->client_certs = data_->cert_request_info->client_certs; | 1220 cert_request_info->client_certs = data_->cert_request_info->client_certs; |
| 1212 } else { | 1221 } else { |
| 1213 cert_request_info->Reset(); | 1222 cert_request_info->Reset(); |
| 1214 } | 1223 } |
| 1215 } | 1224 } |
| 1216 | 1225 |
| 1217 SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( | 1226 SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( |
| 1218 std::string* proto) const { | 1227 std::string* proto) const { |
| 1219 *proto = data_->next_proto; | 1228 *proto = data_->next_proto; |
| 1220 return data_->next_proto_status; | 1229 return data_->next_proto_status; |
| 1221 } | 1230 } |
| 1222 | 1231 |
| 1223 ChannelIDService* MockSSLClientSocket::GetChannelIDService() const { | 1232 ChannelIDService* MockSSLClientSocket::GetChannelIDService() const { |
| 1224 return data_->channel_id_service; | 1233 return data_->channel_id_service; |
| 1225 } | 1234 } |
| 1226 | 1235 |
| 1236 int MockSSLClientSocket::GetSignedEKMForTokenBinding( |
| 1237 crypto::ECPrivateKey* key, |
| 1238 std::vector<uint8_t>* out) { |
| 1239 out->push_back('A'); |
| 1240 return OK; |
| 1241 } |
| 1242 |
| 1227 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { | 1243 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { |
| 1228 NOTIMPLEMENTED(); | 1244 NOTIMPLEMENTED(); |
| 1229 } | 1245 } |
| 1230 | 1246 |
| 1231 void MockSSLClientSocket::OnWriteComplete(int rv) { | 1247 void MockSSLClientSocket::OnWriteComplete(int rv) { |
| 1232 NOTIMPLEMENTED(); | 1248 NOTIMPLEMENTED(); |
| 1233 } | 1249 } |
| 1234 | 1250 |
| 1235 void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) { | 1251 void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) { |
| 1236 NOTIMPLEMENTED(); | 1252 NOTIMPLEMENTED(); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 } | 1713 } |
| 1698 | 1714 |
| 1699 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { | 1715 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { |
| 1700 int64_t total = 0; | 1716 int64_t total = 0; |
| 1701 for (const MockWrite* write = writes; write != writes + writes_size; ++write) | 1717 for (const MockWrite* write = writes; write != writes + writes_size; ++write) |
| 1702 total += write->data_len; | 1718 total += write->data_len; |
| 1703 return total; | 1719 return total; |
| 1704 } | 1720 } |
| 1705 | 1721 |
| 1706 } // namespace net | 1722 } // namespace net |
| OLD | NEW |