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/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "crypto/rsa_private_key.h" | 10 #include "crypto/rsa_private_key.h" |
| 11 #include "net/base/cert_test_util.h" |
11 #include "remoting/protocol/authenticator.h" | 12 #include "remoting/protocol/authenticator.h" |
12 #include "remoting/protocol/channel_authenticator.h" | 13 #include "remoting/protocol/channel_authenticator.h" |
13 #include "remoting/protocol/fake_session.h" | 14 #include "remoting/protocol/fake_session.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
16 | 17 |
17 using testing::_; | 18 using testing::_; |
18 using testing::SaveArg; | 19 using testing::SaveArg; |
19 | 20 |
20 namespace remoting { | 21 namespace remoting { |
21 namespace protocol { | 22 namespace protocol { |
22 | 23 |
23 AuthenticatorTestBase::MockChannelDoneCallback::MockChannelDoneCallback() { | 24 AuthenticatorTestBase::MockChannelDoneCallback::MockChannelDoneCallback() { |
24 } | 25 } |
25 AuthenticatorTestBase::MockChannelDoneCallback::~MockChannelDoneCallback() { | 26 AuthenticatorTestBase::MockChannelDoneCallback::~MockChannelDoneCallback() { |
26 } | 27 } |
27 | 28 |
28 AuthenticatorTestBase::AuthenticatorTestBase() { | 29 AuthenticatorTestBase::AuthenticatorTestBase() { |
29 } | 30 } |
30 AuthenticatorTestBase::~AuthenticatorTestBase() { | 31 AuthenticatorTestBase::~AuthenticatorTestBase() { |
31 } | 32 } |
32 | 33 |
33 void AuthenticatorTestBase::SetUp() { | 34 void AuthenticatorTestBase::SetUp() { |
34 FilePath certs_dir; | 35 FilePath certs_dir(net::GetTestCertsDirectory()); |
35 PathService::Get(base::DIR_SOURCE_ROOT, &certs_dir); | |
36 certs_dir = certs_dir.AppendASCII("net"); | |
37 certs_dir = certs_dir.AppendASCII("data"); | |
38 certs_dir = certs_dir.AppendASCII("ssl"); | |
39 certs_dir = certs_dir.AppendASCII("certificates"); | |
40 | 36 |
41 FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); | 37 FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); |
42 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); | 38 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); |
43 | 39 |
44 FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); | 40 FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
45 std::string key_string; | 41 std::string key_string; |
46 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); | 42 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); |
47 std::vector<uint8> key_vector( | 43 std::vector<uint8> key_vector( |
48 reinterpret_cast<const uint8*>(key_string.data()), | 44 reinterpret_cast<const uint8*>(key_string.data()), |
49 reinterpret_cast<const uint8*>(key_string.data() + | 45 reinterpret_cast<const uint8*>(key_string.data() + |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 126 |
131 void AuthenticatorTestBase::OnClientConnected( | 127 void AuthenticatorTestBase::OnClientConnected( |
132 net::Error error, | 128 net::Error error, |
133 scoped_ptr<net::StreamSocket> socket) { | 129 scoped_ptr<net::StreamSocket> socket) { |
134 client_callback_.OnDone(error, socket.get()); | 130 client_callback_.OnDone(error, socket.get()); |
135 client_socket_ = socket.Pass(); | 131 client_socket_ = socket.Pass(); |
136 } | 132 } |
137 | 133 |
138 } // namespace protocol | 134 } // namespace protocol |
139 } // namespace remoting | 135 } // namespace remoting |
OLD | NEW |