| 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 // This test suite uses SSLClientSocket to test the implementation of | 5 // This test suite uses SSLClientSocket to test the implementation of |
| 6 // SSLServerSocket. In order to establish connections between the sockets | 6 // SSLServerSocket. In order to establish connections between the sockets |
| 7 // we need two additional classes: | 7 // we need two additional classes: |
| 8 // 1. FakeSocket | 8 // 1. FakeSocket |
| 9 // Connects SSL socket to FakeDataChannel. This class is just a stub. | 9 // Connects SSL socket to FakeDataChannel. This class is just a stub. |
| 10 // | 10 // |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 class MockCTVerifier : public CTVerifier { | 91 class MockCTVerifier : public CTVerifier { |
| 92 public: | 92 public: |
| 93 MockCTVerifier() = default; | 93 MockCTVerifier() = default; |
| 94 ~MockCTVerifier() override = default; | 94 ~MockCTVerifier() override = default; |
| 95 | 95 |
| 96 int Verify(X509Certificate* cert, | 96 int Verify(X509Certificate* cert, |
| 97 const std::string& stapled_ocsp_response, | 97 const std::string& stapled_ocsp_response, |
| 98 const std::string& sct_list_from_tls_extension, | 98 const std::string& sct_list_from_tls_extension, |
| 99 ct::CTVerifyResult* result, | 99 ct::CTVerifyResult* result, |
| 100 const BoundNetLog& net_log) override { | 100 const NetLogWithSource& net_log) override { |
| 101 return net::OK; | 101 return net::OK; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void SetObserver(Observer* observer) override {} | 104 void SetObserver(Observer* observer) override {} |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class MockCTPolicyEnforcer : public CTPolicyEnforcer { | 107 class MockCTPolicyEnforcer : public CTPolicyEnforcer { |
| 108 public: | 108 public: |
| 109 MockCTPolicyEnforcer() = default; | 109 MockCTPolicyEnforcer() = default; |
| 110 ~MockCTPolicyEnforcer() override = default; | 110 ~MockCTPolicyEnforcer() override = default; |
| 111 ct::CertPolicyCompliance DoesConformToCertPolicy( | 111 ct::CertPolicyCompliance DoesConformToCertPolicy( |
| 112 X509Certificate* cert, | 112 X509Certificate* cert, |
| 113 const SCTList& verified_scts, | 113 const SCTList& verified_scts, |
| 114 const BoundNetLog& net_log) override { | 114 const NetLogWithSource& net_log) override { |
| 115 return ct::CertPolicyCompliance::CERT_POLICY_COMPLIES_VIA_SCTS; | 115 return ct::CertPolicyCompliance::CERT_POLICY_COMPLIES_VIA_SCTS; |
| 116 } | 116 } |
| 117 | 117 |
| 118 ct::EVPolicyCompliance DoesConformToCTEVPolicy( | 118 ct::EVPolicyCompliance DoesConformToCTEVPolicy( |
| 119 X509Certificate* cert, | 119 X509Certificate* cert, |
| 120 const ct::EVCertsWhitelist* ev_whitelist, | 120 const ct::EVCertsWhitelist* ev_whitelist, |
| 121 const SCTList& verified_scts, | 121 const SCTList& verified_scts, |
| 122 const BoundNetLog& net_log) override { | 122 const NetLogWithSource& net_log) override { |
| 123 return ct::EVPolicyCompliance::EV_POLICY_COMPLIES_VIA_SCTS; | 123 return ct::EVPolicyCompliance::EV_POLICY_COMPLIES_VIA_SCTS; |
| 124 } | 124 } |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 class FakeDataChannel { | 127 class FakeDataChannel { |
| 128 public: | 128 public: |
| 129 FakeDataChannel() | 129 FakeDataChannel() |
| 130 : read_buf_len_(0), | 130 : read_buf_len_(0), |
| 131 closed_(false), | 131 closed_(false), |
| 132 write_called_after_close_(false), | 132 write_called_after_close_(false), |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 int GetPeerAddress(IPEndPoint* address) const override { | 286 int GetPeerAddress(IPEndPoint* address) const override { |
| 287 *address = IPEndPoint(IPAddress::IPv4AllZeros(), 0 /*port*/); | 287 *address = IPEndPoint(IPAddress::IPv4AllZeros(), 0 /*port*/); |
| 288 return OK; | 288 return OK; |
| 289 } | 289 } |
| 290 | 290 |
| 291 int GetLocalAddress(IPEndPoint* address) const override { | 291 int GetLocalAddress(IPEndPoint* address) const override { |
| 292 *address = IPEndPoint(IPAddress::IPv4AllZeros(), 0 /*port*/); | 292 *address = IPEndPoint(IPAddress::IPv4AllZeros(), 0 /*port*/); |
| 293 return OK; | 293 return OK; |
| 294 } | 294 } |
| 295 | 295 |
| 296 const BoundNetLog& NetLog() const override { return net_log_; } | 296 const NetLogWithSource& NetLog() const override { return net_log_; } |
| 297 | 297 |
| 298 void SetSubresourceSpeculation() override {} | 298 void SetSubresourceSpeculation() override {} |
| 299 void SetOmniboxSpeculation() override {} | 299 void SetOmniboxSpeculation() override {} |
| 300 | 300 |
| 301 bool WasEverUsed() const override { return true; } | 301 bool WasEverUsed() const override { return true; } |
| 302 | 302 |
| 303 bool WasNpnNegotiated() const override { return false; } | 303 bool WasNpnNegotiated() const override { return false; } |
| 304 | 304 |
| 305 NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } | 305 NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
| 306 | 306 |
| 307 bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } | 307 bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
| 308 | 308 |
| 309 void GetConnectionAttempts(ConnectionAttempts* out) const override { | 309 void GetConnectionAttempts(ConnectionAttempts* out) const override { |
| 310 out->clear(); | 310 out->clear(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void ClearConnectionAttempts() override {} | 313 void ClearConnectionAttempts() override {} |
| 314 | 314 |
| 315 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} | 315 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
| 316 | 316 |
| 317 int64_t GetTotalReceivedBytes() const override { | 317 int64_t GetTotalReceivedBytes() const override { |
| 318 NOTIMPLEMENTED(); | 318 NOTIMPLEMENTED(); |
| 319 return 0; | 319 return 0; |
| 320 } | 320 } |
| 321 | 321 |
| 322 private: | 322 private: |
| 323 BoundNetLog net_log_; | 323 NetLogWithSource net_log_; |
| 324 FakeDataChannel* incoming_; | 324 FakeDataChannel* incoming_; |
| 325 FakeDataChannel* outgoing_; | 325 FakeDataChannel* outgoing_; |
| 326 | 326 |
| 327 DISALLOW_COPY_AND_ASSIGN(FakeSocket); | 327 DISALLOW_COPY_AND_ASSIGN(FakeSocket); |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 } // namespace | 330 } // namespace |
| 331 | 331 |
| 332 // Verify the correctness of the test helper classes first. | 332 // Verify the correctness of the test helper classes first. |
| 333 TEST(FakeSocketTest, DataTransfer) { | 333 TEST(FakeSocketTest, DataTransfer) { |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 int server_ret = server_socket_->Handshake(handshake_callback.callback()); | 1113 int server_ret = server_socket_->Handshake(handshake_callback.callback()); |
| 1114 | 1114 |
| 1115 client_ret = connect_callback.GetResult(client_ret); | 1115 client_ret = connect_callback.GetResult(client_ret); |
| 1116 server_ret = handshake_callback.GetResult(server_ret); | 1116 server_ret = handshake_callback.GetResult(server_ret); |
| 1117 | 1117 |
| 1118 ASSERT_THAT(client_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); | 1118 ASSERT_THAT(client_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); |
| 1119 ASSERT_THAT(server_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); | 1119 ASSERT_THAT(server_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 } // namespace net | 1122 } // namespace net |
| OLD | NEW |