Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc

Issue 580243003: Cleanup Fake* classes in remoting/protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sctp
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/message_reader_unittest.cc ('k') | remoting/remoting_test.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); 63 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin");
64 std::string key_string; 64 std::string key_string;
65 ASSERT_TRUE(base::ReadFileToString(key_path, &key_string)); 65 ASSERT_TRUE(base::ReadFileToString(key_path, &key_string));
66 std::string key_base64; 66 std::string key_base64;
67 base::Base64Encode(key_string, &key_base64); 67 base::Base64Encode(key_string, &key_base64);
68 key_pair_ = RsaKeyPair::FromString(key_base64); 68 key_pair_ = RsaKeyPair::FromString(key_base64);
69 ASSERT_TRUE(key_pair_.get()); 69 ASSERT_TRUE(key_pair_.get());
70 } 70 }
71 71
72 void RunChannelAuth(bool expected_fail) { 72 void RunChannelAuth(bool expected_fail) {
73 client_fake_socket_.reset(new FakeSocket()); 73 client_fake_socket_.reset(new FakeStreamSocket());
74 host_fake_socket_.reset(new FakeSocket()); 74 host_fake_socket_.reset(new FakeStreamSocket());
75 client_fake_socket_->PairWith(host_fake_socket_.get()); 75 client_fake_socket_->PairWith(host_fake_socket_.get());
76 76
77 client_auth_->SecureAndAuthenticate( 77 client_auth_->SecureAndAuthenticate(
78 client_fake_socket_.PassAs<net::StreamSocket>(), 78 client_fake_socket_.PassAs<net::StreamSocket>(),
79 base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected, 79 base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected,
80 base::Unretained(this))); 80 base::Unretained(this)));
81 81
82 host_auth_->SecureAndAuthenticate( 82 host_auth_->SecureAndAuthenticate(
83 host_fake_socket_.PassAs<net::StreamSocket>(), 83 host_fake_socket_.PassAs<net::StreamSocket>(),
84 base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected, 84 base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void OnClientConnected(int error, scoped_ptr<net::StreamSocket> socket) { 124 void OnClientConnected(int error, scoped_ptr<net::StreamSocket> socket) {
125 client_auth_.reset(); 125 client_auth_.reset();
126 client_callback_.OnDone(error, socket.get()); 126 client_callback_.OnDone(error, socket.get());
127 client_socket_ = socket.Pass(); 127 client_socket_ = socket.Pass();
128 } 128 }
129 129
130 base::MessageLoop message_loop_; 130 base::MessageLoop message_loop_;
131 131
132 scoped_refptr<RsaKeyPair> key_pair_; 132 scoped_refptr<RsaKeyPair> key_pair_;
133 std::string host_cert_; 133 std::string host_cert_;
134 scoped_ptr<FakeSocket> client_fake_socket_; 134 scoped_ptr<FakeStreamSocket> client_fake_socket_;
135 scoped_ptr<FakeSocket> host_fake_socket_; 135 scoped_ptr<FakeStreamSocket> host_fake_socket_;
136 scoped_ptr<ChannelAuthenticator> client_auth_; 136 scoped_ptr<ChannelAuthenticator> client_auth_;
137 scoped_ptr<ChannelAuthenticator> host_auth_; 137 scoped_ptr<ChannelAuthenticator> host_auth_;
138 MockChannelDoneCallback client_callback_; 138 MockChannelDoneCallback client_callback_;
139 MockChannelDoneCallback host_callback_; 139 MockChannelDoneCallback host_callback_;
140 scoped_ptr<net::StreamSocket> client_socket_; 140 scoped_ptr<net::StreamSocket> client_socket_;
141 scoped_ptr<net::StreamSocket> host_socket_; 141 scoped_ptr<net::StreamSocket> host_socket_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); 143 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest);
144 }; 144 };
145 145
(...skipping 24 matching lines...) Expand all
170 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( 170 host_auth_ = SslHmacChannelAuthenticator::CreateForHost(
171 host_cert_, key_pair_, kTestSharedSecret); 171 host_cert_, key_pair_, kTestSharedSecret);
172 172
173 RunChannelAuth(true); 173 RunChannelAuth(true);
174 174
175 ASSERT_TRUE(host_socket_.get() == NULL); 175 ASSERT_TRUE(host_socket_.get() == NULL);
176 } 176 }
177 177
178 } // namespace protocol 178 } // namespace protocol
179 } // namespace remoting 179 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/message_reader_unittest.cc ('k') | remoting/remoting_test.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698