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 "remoting/protocol/ssl_hmac_channel_authenticator.h" | 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" |
15 #include "base/test/test_timeouts.h" | 16 #include "base/test/test_timeouts.h" |
16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
17 #include "crypto/rsa_private_key.h" | 18 #include "crypto/rsa_private_key.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/test/cert_test_util.h" | 20 #include "net/test/cert_test_util.h" |
20 #include "net/test/test_data_directory.h" | 21 #include "net/test/test_data_directory.h" |
21 #include "remoting/base/rsa_key_pair.h" | 22 #include "remoting/base/rsa_key_pair.h" |
22 #include "remoting/protocol/connection_tester.h" | 23 #include "remoting/protocol/connection_tester.h" |
23 #include "remoting/protocol/fake_session.h" | 24 #include "remoting/protocol/fake_session.h" |
24 #include "remoting/protocol/p2p_stream_socket.h" | 25 #include "remoting/protocol/p2p_stream_socket.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } else { | 107 } else { |
107 EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull())) | 108 EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull())) |
108 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 109 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
109 } | 110 } |
110 | 111 |
111 // Ensure that .Run() does not run unbounded if the callbacks are never | 112 // Ensure that .Run() does not run unbounded if the callbacks are never |
112 // called. | 113 // called. |
113 base::Timer shutdown_timer(false, false); | 114 base::Timer shutdown_timer(false, false); |
114 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), | 115 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), |
115 base::MessageLoop::QuitWhenIdleClosure()); | 116 base::MessageLoop::QuitWhenIdleClosure()); |
116 message_loop_.Run(); | 117 base::RunLoop().Run(); |
117 } | 118 } |
118 | 119 |
119 void OnHostConnected(const std::string& ref_argument, | 120 void OnHostConnected(const std::string& ref_argument, |
120 int error, | 121 int error, |
121 std::unique_ptr<P2PStreamSocket> socket) { | 122 std::unique_ptr<P2PStreamSocket> socket) { |
122 // Try deleting the authenticator and verify that this doesn't destroy | 123 // Try deleting the authenticator and verify that this doesn't destroy |
123 // reference parameters. | 124 // reference parameters. |
124 host_auth_.reset(); | 125 host_auth_.reset(); |
125 DCHECK_EQ(ref_argument, "ref argument value"); | 126 DCHECK_EQ(ref_argument, "ref argument value"); |
126 | 127 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 RunChannelAuth(net::OK, net::OK); | 161 RunChannelAuth(net::OK, net::OK); |
161 | 162 |
162 ASSERT_TRUE(client_socket_.get() != nullptr); | 163 ASSERT_TRUE(client_socket_.get() != nullptr); |
163 ASSERT_TRUE(host_socket_.get() != nullptr); | 164 ASSERT_TRUE(host_socket_.get() != nullptr); |
164 | 165 |
165 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 166 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
166 100, 2); | 167 100, 2); |
167 | 168 |
168 tester.Start(); | 169 tester.Start(); |
169 message_loop_.Run(); | 170 base::RunLoop().Run(); |
170 tester.CheckResults(); | 171 tester.CheckResults(); |
171 } | 172 } |
172 | 173 |
173 // Verify that channels cannot be using invalid shared secret. | 174 // Verify that channels cannot be using invalid shared secret. |
174 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { | 175 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { |
175 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( | 176 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
176 host_cert_, kTestSharedSecretBad); | 177 host_cert_, kTestSharedSecretBad); |
177 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 178 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
178 host_cert_, key_pair_, kTestSharedSecret); | 179 host_cert_, key_pair_, kTestSharedSecret); |
179 | 180 |
(...skipping 16 matching lines...) Expand all Loading... |
196 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 197 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
197 host_cert_, key_pair_, kTestSharedSecret); | 198 host_cert_, key_pair_, kTestSharedSecret); |
198 | 199 |
199 RunChannelAuth(net::ERR_CERT_INVALID, net::ERR_CONNECTION_CLOSED); | 200 RunChannelAuth(net::ERR_CERT_INVALID, net::ERR_CONNECTION_CLOSED); |
200 | 201 |
201 ASSERT_TRUE(host_socket_.get() == nullptr); | 202 ASSERT_TRUE(host_socket_.get() == nullptr); |
202 } | 203 } |
203 | 204 |
204 } // namespace protocol | 205 } // namespace protocol |
205 } // namespace remoting | 206 } // namespace remoting |
OLD | NEW |