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" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Ensure that .Run() does not run unbounded if the callbacks are never | 111 // Ensure that .Run() does not run unbounded if the callbacks are never |
112 // called. | 112 // called. |
113 base::Timer shutdown_timer(false, false); | 113 base::Timer shutdown_timer(false, false); |
114 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), | 114 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), |
115 base::MessageLoop::QuitWhenIdleClosure()); | 115 base::MessageLoop::QuitWhenIdleClosure()); |
116 message_loop_.Run(); | 116 message_loop_.Run(); |
117 } | 117 } |
118 | 118 |
119 void OnHostConnected(const std::string& ref_argument, | 119 void OnHostConnected(const std::string& ref_argument, |
120 int error, | 120 int error, |
121 scoped_ptr<P2PStreamSocket> socket) { | 121 std::unique_ptr<P2PStreamSocket> socket) { |
122 // Try deleting the authenticator and verify that this doesn't destroy | 122 // Try deleting the authenticator and verify that this doesn't destroy |
123 // reference parameters. | 123 // reference parameters. |
124 host_auth_.reset(); | 124 host_auth_.reset(); |
125 DCHECK_EQ(ref_argument, "ref argument value"); | 125 DCHECK_EQ(ref_argument, "ref argument value"); |
126 | 126 |
127 host_callback_.OnDone(error, socket.get()); | 127 host_callback_.OnDone(error, socket.get()); |
128 host_socket_ = std::move(socket); | 128 host_socket_ = std::move(socket); |
129 } | 129 } |
130 | 130 |
131 void OnClientConnected(int error, scoped_ptr<P2PStreamSocket> socket) { | 131 void OnClientConnected(int error, std::unique_ptr<P2PStreamSocket> socket) { |
132 client_auth_.reset(); | 132 client_auth_.reset(); |
133 client_callback_.OnDone(error, socket.get()); | 133 client_callback_.OnDone(error, socket.get()); |
134 client_socket_ = std::move(socket); | 134 client_socket_ = std::move(socket); |
135 } | 135 } |
136 | 136 |
137 base::MessageLoop message_loop_; | 137 base::MessageLoop message_loop_; |
138 | 138 |
139 scoped_refptr<RsaKeyPair> key_pair_; | 139 scoped_refptr<RsaKeyPair> key_pair_; |
140 std::string host_cert_; | 140 std::string host_cert_; |
141 scoped_ptr<FakeStreamSocket> client_fake_socket_; | 141 std::unique_ptr<FakeStreamSocket> client_fake_socket_; |
142 scoped_ptr<FakeStreamSocket> host_fake_socket_; | 142 std::unique_ptr<FakeStreamSocket> host_fake_socket_; |
143 scoped_ptr<ChannelAuthenticator> client_auth_; | 143 std::unique_ptr<ChannelAuthenticator> client_auth_; |
144 scoped_ptr<ChannelAuthenticator> host_auth_; | 144 std::unique_ptr<ChannelAuthenticator> host_auth_; |
145 MockChannelDoneCallback client_callback_; | 145 MockChannelDoneCallback client_callback_; |
146 MockChannelDoneCallback host_callback_; | 146 MockChannelDoneCallback host_callback_; |
147 scoped_ptr<P2PStreamSocket> client_socket_; | 147 std::unique_ptr<P2PStreamSocket> client_socket_; |
148 scoped_ptr<P2PStreamSocket> host_socket_; | 148 std::unique_ptr<P2PStreamSocket> host_socket_; |
149 | 149 |
150 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); | 150 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); |
151 }; | 151 }; |
152 | 152 |
153 // Verify that a channel can be connected using a valid shared secret. | 153 // Verify that a channel can be connected using a valid shared secret. |
154 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { | 154 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { |
155 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( | 155 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
156 host_cert_, kTestSharedSecret); | 156 host_cert_, kTestSharedSecret); |
157 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 157 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
158 host_cert_, key_pair_, kTestSharedSecret); | 158 host_cert_, key_pair_, kTestSharedSecret); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 196 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
197 host_cert_, key_pair_, kTestSharedSecret); | 197 host_cert_, key_pair_, kTestSharedSecret); |
198 | 198 |
199 RunChannelAuth(net::ERR_CERT_INVALID, net::ERR_CONNECTION_CLOSED); | 199 RunChannelAuth(net::ERR_CERT_INVALID, net::ERR_CONNECTION_CLOSED); |
200 | 200 |
201 ASSERT_TRUE(host_socket_.get() == nullptr); | 201 ASSERT_TRUE(host_socket_.get() == nullptr); |
202 } | 202 } |
203 | 203 |
204 } // namespace protocol | 204 } // namespace protocol |
205 } // namespace remoting | 205 } // namespace remoting |
OLD | NEW |