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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 host_auth_->SecureAndAuthenticate( | 81 host_auth_->SecureAndAuthenticate( |
82 host_fake_socket_.Pass(), | 82 host_fake_socket_.Pass(), |
83 base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected, | 83 base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected, |
84 base::Unretained(this), std::string("ref argument value"))); | 84 base::Unretained(this), std::string("ref argument value"))); |
85 | 85 |
86 // Expect two callbacks to be called - the client callback and the host | 86 // Expect two callbacks to be called - the client callback and the host |
87 // callback. | 87 // callback. |
88 int callback_counter = 2; | 88 int callback_counter = 2; |
89 | 89 |
90 if (expected_fail) { | 90 if (expected_fail) { |
91 EXPECT_CALL(client_callback_, OnDone(net::ERR_FAILED, NULL)) | 91 EXPECT_CALL(client_callback_, OnDone(net::ERR_FAILED, nullptr)) |
92 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 92 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
93 EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED, NULL)) | 93 EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED, nullptr)) |
94 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 94 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
95 } else { | 95 } else { |
96 EXPECT_CALL(client_callback_, OnDone(net::OK, NotNull())) | 96 EXPECT_CALL(client_callback_, OnDone(net::OK, NotNull())) |
97 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 97 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
98 EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull())) | 98 EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull())) |
99 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 99 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
100 } | 100 } |
101 | 101 |
102 // Ensure that .Run() does not run unbounded if the callbacks are never | 102 // Ensure that .Run() does not run unbounded if the callbacks are never |
103 // called. | 103 // called. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 // Verify that a channel can be connected using a valid shared secret. | 145 // Verify that a channel can be connected using a valid shared secret. |
146 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { | 146 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { |
147 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( | 147 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
148 host_cert_, kTestSharedSecret); | 148 host_cert_, kTestSharedSecret); |
149 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 149 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
150 host_cert_, key_pair_, kTestSharedSecret); | 150 host_cert_, key_pair_, kTestSharedSecret); |
151 | 151 |
152 RunChannelAuth(false); | 152 RunChannelAuth(false); |
153 | 153 |
154 ASSERT_TRUE(client_socket_.get() != NULL); | 154 ASSERT_TRUE(client_socket_.get() != nullptr); |
155 ASSERT_TRUE(host_socket_.get() != NULL); | 155 ASSERT_TRUE(host_socket_.get() != nullptr); |
156 | 156 |
157 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 157 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
158 100, 2); | 158 100, 2); |
159 | 159 |
160 tester.Start(); | 160 tester.Start(); |
161 message_loop_.Run(); | 161 message_loop_.Run(); |
162 tester.CheckResults(); | 162 tester.CheckResults(); |
163 } | 163 } |
164 | 164 |
165 // Verify that channels cannot be using invalid shared secret. | 165 // Verify that channels cannot be using invalid shared secret. |
166 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { | 166 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { |
167 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( | 167 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
168 host_cert_, kTestSharedSecretBad); | 168 host_cert_, kTestSharedSecretBad); |
169 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 169 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
170 host_cert_, key_pair_, kTestSharedSecret); | 170 host_cert_, key_pair_, kTestSharedSecret); |
171 | 171 |
172 RunChannelAuth(true); | 172 RunChannelAuth(true); |
173 | 173 |
174 ASSERT_TRUE(host_socket_.get() == NULL); | 174 ASSERT_TRUE(host_socket_.get() == nullptr); |
175 } | 175 } |
176 | 176 |
177 } // namespace protocol | 177 } // namespace protocol |
178 } // namespace remoting | 178 } // namespace remoting |
OLD | NEW |