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/authenticator_test_base.h" | 5 #include "remoting/protocol/authenticator_test_base.h" |
6 | 6 |
7 #include "base/base64.h" | |
7 #include "base/file_path.h" | 8 #include "base/file_path.h" |
8 #include "base/file_util.h" | 9 #include "base/file_util.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 Loading... | |
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); |
Wez
2013/03/06 00:43:25
Can we switch to a Base64 encoded string in the fi
rmsousa
2013/03/06 04:36:49
These files are not owned by us, they're the test
| |
56 reinterpret_cast<const uint8*>(key_string.data() + | 57 key_pair_ = new RsaKeyPair(); |
57 key_string.length())); | 58 key_pair_->LoadFromString(key_base64); |
58 private_key_.reset( | |
59 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_vector)); | |
60 } | 59 } |
61 | 60 |
62 void AuthenticatorTestBase::RunAuthExchange() { | 61 void AuthenticatorTestBase::RunAuthExchange() { |
63 do { | 62 do { |
64 scoped_ptr<buzz::XmlElement> message; | 63 scoped_ptr<buzz::XmlElement> message; |
65 | 64 |
66 // Pass message from client to host. | 65 // Pass message from client to host. |
67 ASSERT_EQ(Authenticator::MESSAGE_READY, client_->state()); | 66 ASSERT_EQ(Authenticator::MESSAGE_READY, client_->state()); |
68 message = client_->GetNextMessage(); | 67 message = client_->GetNextMessage(); |
69 ASSERT_TRUE(message.get()); | 68 ASSERT_TRUE(message.get()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 146 |
148 void AuthenticatorTestBase::OnClientConnected( | 147 void AuthenticatorTestBase::OnClientConnected( |
149 net::Error error, | 148 net::Error error, |
150 scoped_ptr<net::StreamSocket> socket) { | 149 scoped_ptr<net::StreamSocket> socket) { |
151 client_callback_.OnDone(error); | 150 client_callback_.OnDone(error); |
152 client_socket_ = socket.Pass(); | 151 client_socket_ = socket.Pass(); |
153 } | 152 } |
154 | 153 |
155 } // namespace protocol | 154 } // namespace protocol |
156 } // namespace remoting | 155 } // namespace remoting |
OLD | NEW |