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

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

Issue 12316083: Move HostKeyPair into protocol::KeyPair. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reviewer comments Created 7 years, 9 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
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/authenticator_test_base.h" 5 #include "remoting/protocol/authenticator_test_base.h"
6 6
7 #include "base/base64.h"
7 #include "base/file_util.h" 8 #include "base/file_util.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
11 #include "base/timer.h" 12 #include "base/timer.h"
12 #include "crypto/rsa_private_key.h"
13 #include "net/base/test_data_directory.h" 13 #include "net/base/test_data_directory.h"
14 #include "remoting/base/rsa_key_pair.h"
14 #include "remoting/protocol/authenticator.h" 15 #include "remoting/protocol/authenticator.h"
15 #include "remoting/protocol/channel_authenticator.h" 16 #include "remoting/protocol/channel_authenticator.h"
16 #include "remoting/protocol/fake_session.h" 17 #include "remoting/protocol/fake_session.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 19 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
19 20
20 using testing::_; 21 using testing::_;
21 using testing::SaveArg; 22 using testing::SaveArg;
22 23
23 namespace remoting { 24 namespace remoting {
(...skipping 20 matching lines...) Expand all
44 45
45 void AuthenticatorTestBase::SetUp() { 46 void AuthenticatorTestBase::SetUp() {
46 base::FilePath certs_dir(net::GetTestCertsDirectory()); 47 base::FilePath certs_dir(net::GetTestCertsDirectory());
47 48
48 base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); 49 base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der");
49 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); 50 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_));
50 51
51 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); 52 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin");
52 std::string key_string; 53 std::string key_string;
53 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); 54 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string));
54 std::vector<uint8> key_vector( 55 std::string key_base64;
55 reinterpret_cast<const uint8*>(key_string.data()), 56 base::Base64Encode(key_string, &key_base64);
Sergey Ulanov 2013/03/06 20:51:34 ASSERT_TRUE
rmsousa 2013/03/07 03:27:44 Done.
56 reinterpret_cast<const uint8*>(key_string.data() + 57 key_pair_ = RsaKeyPair::FromString(key_base64);
57 key_string.length())); 58 ASSERT_TRUE(key_pair_);
58 private_key_.reset(
59 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_vector));
60 } 59 }
61 60
62 void AuthenticatorTestBase::RunAuthExchange() { 61 void AuthenticatorTestBase::RunAuthExchange() {
63 ContinueAuthExchangeWith(client_.get(), host_.get()); 62 ContinueAuthExchangeWith(client_.get(), host_.get());
64 } 63 }
65 64
66 // static 65 // static
67 void AuthenticatorTestBase::ContinueAuthExchangeWith(Authenticator* sender, 66 void AuthenticatorTestBase::ContinueAuthExchangeWith(Authenticator* sender,
68 Authenticator* receiver) { 67 Authenticator* receiver) {
69 scoped_ptr<buzz::XmlElement> message; 68 scoped_ptr<buzz::XmlElement> message;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 137
139 void AuthenticatorTestBase::OnClientConnected( 138 void AuthenticatorTestBase::OnClientConnected(
140 net::Error error, 139 net::Error error,
141 scoped_ptr<net::StreamSocket> socket) { 140 scoped_ptr<net::StreamSocket> socket) {
142 client_callback_.OnDone(error); 141 client_callback_.OnDone(error);
143 client_socket_ = socket.Pass(); 142 client_socket_ = socket.Pass();
144 } 143 }
145 144
146 } // namespace protocol 145 } // namespace protocol
147 } // namespace remoting 146 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698