| 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 "jingle/glue/chrome_async_socket.h" | 5 #include "jingle/glue/chrome_async_socket.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "jingle/glue/resolving_client_socket_factory.h" | 14 #include "jingle/glue/resolving_client_socket_factory.h" |
| 15 #include "net/base/address_list.h" | 15 #include "net/base/address_list.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 #include "net/cert/mock_cert_verifier.h" | 18 #include "net/cert/mock_cert_verifier.h" |
| 19 #include "net/http/transport_security_state.h" |
| 19 #include "net/socket/socket_test_util.h" | 20 #include "net/socket/socket_test_util.h" |
| 20 #include "net/socket/ssl_client_socket.h" | 21 #include "net/socket/ssl_client_socket.h" |
| 21 #include "net/ssl/ssl_config_service.h" | 22 #include "net/ssl/ssl_config_service.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/libjingle/source/talk/base/ipaddress.h" | 25 #include "third_party/libjingle/source/talk/base/ipaddress.h" |
| 25 #include "third_party/libjingle/source/talk/base/sigslot.h" | 26 #include "third_party/libjingle/source/talk/base/sigslot.h" |
| 26 #include "third_party/libjingle/source/talk/base/socketaddress.h" | 27 #include "third_party/libjingle/source/talk/base/socketaddress.h" |
| 27 | 28 |
| 28 namespace jingle_glue { | 29 namespace jingle_glue { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DISALLOW_COPY_AND_ASSIGN(AsyncSocketDataProvider); | 101 DISALLOW_COPY_AND_ASSIGN(AsyncSocketDataProvider); |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 class MockXmppClientSocketFactory : public ResolvingClientSocketFactory { | 104 class MockXmppClientSocketFactory : public ResolvingClientSocketFactory { |
| 104 public: | 105 public: |
| 105 MockXmppClientSocketFactory( | 106 MockXmppClientSocketFactory( |
| 106 net::ClientSocketFactory* mock_client_socket_factory, | 107 net::ClientSocketFactory* mock_client_socket_factory, |
| 107 const net::AddressList& address_list) | 108 const net::AddressList& address_list) |
| 108 : mock_client_socket_factory_(mock_client_socket_factory), | 109 : mock_client_socket_factory_(mock_client_socket_factory), |
| 109 address_list_(address_list), | 110 address_list_(address_list), |
| 110 cert_verifier_(new net::MockCertVerifier) { | 111 cert_verifier_(new net::MockCertVerifier), |
| 112 transport_security_state_(new net::TransportSecurityState) { |
| 111 } | 113 } |
| 112 | 114 |
| 113 // ResolvingClientSocketFactory implementation. | 115 // ResolvingClientSocketFactory implementation. |
| 114 virtual net::StreamSocket* CreateTransportClientSocket( | 116 virtual net::StreamSocket* CreateTransportClientSocket( |
| 115 const net::HostPortPair& host_and_port) OVERRIDE { | 117 const net::HostPortPair& host_and_port) OVERRIDE { |
| 116 return mock_client_socket_factory_->CreateTransportClientSocket( | 118 return mock_client_socket_factory_->CreateTransportClientSocket( |
| 117 address_list_, NULL, net::NetLog::Source()); | 119 address_list_, NULL, net::NetLog::Source()); |
| 118 } | 120 } |
| 119 | 121 |
| 120 virtual net::SSLClientSocket* CreateSSLClientSocket( | 122 virtual net::SSLClientSocket* CreateSSLClientSocket( |
| 121 net::ClientSocketHandle* transport_socket, | 123 net::ClientSocketHandle* transport_socket, |
| 122 const net::HostPortPair& host_and_port) OVERRIDE { | 124 const net::HostPortPair& host_and_port) OVERRIDE { |
| 123 net::SSLClientSocketContext context; | 125 net::SSLClientSocketContext context; |
| 124 context.cert_verifier = cert_verifier_.get(); | 126 context.cert_verifier = cert_verifier_.get(); |
| 127 context.transport_security_state = transport_security_state_.get(); |
| 125 return mock_client_socket_factory_->CreateSSLClientSocket( | 128 return mock_client_socket_factory_->CreateSSLClientSocket( |
| 126 transport_socket, host_and_port, ssl_config_, context); | 129 transport_socket, host_and_port, ssl_config_, context); |
| 127 } | 130 } |
| 128 | 131 |
| 129 private: | 132 private: |
| 130 scoped_ptr<net::ClientSocketFactory> mock_client_socket_factory_; | 133 scoped_ptr<net::ClientSocketFactory> mock_client_socket_factory_; |
| 131 net::AddressList address_list_; | 134 net::AddressList address_list_; |
| 132 net::SSLConfig ssl_config_; | 135 net::SSLConfig ssl_config_; |
| 133 scoped_ptr<net::CertVerifier> cert_verifier_; | 136 scoped_ptr<net::CertVerifier> cert_verifier_; |
| 137 scoped_ptr<net::TransportSecurityState> transport_security_state_; |
| 134 }; | 138 }; |
| 135 | 139 |
| 136 class ChromeAsyncSocketTest | 140 class ChromeAsyncSocketTest |
| 137 : public testing::Test, | 141 : public testing::Test, |
| 138 public sigslot::has_slots<> { | 142 public sigslot::has_slots<> { |
| 139 protected: | 143 protected: |
| 140 ChromeAsyncSocketTest() | 144 ChromeAsyncSocketTest() |
| 141 : ssl_socket_data_provider_(net::ASYNC, net::OK), | 145 : ssl_socket_data_provider_(net::ASYNC, net::OK), |
| 142 addr_("localhost", 35) {} | 146 addr_("localhost", 35) {} |
| 143 | 147 |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 message_loop_.RunUntilIdle(); | 1074 message_loop_.RunUntilIdle(); |
| 1071 | 1075 |
| 1072 ExpectNoSignal(); | 1076 ExpectNoSignal(); |
| 1073 | 1077 |
| 1074 DoSSLCloseOpenedNoError(); | 1078 DoSSLCloseOpenedNoError(); |
| 1075 } | 1079 } |
| 1076 | 1080 |
| 1077 } // namespace | 1081 } // namespace |
| 1078 | 1082 |
| 1079 } // namespace jingle_glue | 1083 } // namespace jingle_glue |
| OLD | NEW |