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/base64.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); | 49 base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); |
50 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); | 50 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); |
51 | 51 |
52 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); | 52 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
53 std::string key_string; | 53 std::string key_string; |
54 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); | 54 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); |
55 std::string key_base64; | 55 std::string key_base64; |
56 ASSERT_TRUE(base::Base64Encode(key_string, &key_base64)); | 56 ASSERT_TRUE(base::Base64Encode(key_string, &key_base64)); |
57 key_pair_ = RsaKeyPair::FromString(key_base64); | 57 key_pair_ = RsaKeyPair::FromString(key_base64); |
58 ASSERT_TRUE(key_pair_); | 58 ASSERT_TRUE(key_pair_); |
| 59 host_public_key_ = key_pair_->GetPublicKey(); |
59 } | 60 } |
60 | 61 |
61 void AuthenticatorTestBase::RunAuthExchange() { | 62 void AuthenticatorTestBase::RunAuthExchange() { |
62 ContinueAuthExchangeWith(client_.get(), host_.get()); | 63 ContinueAuthExchangeWith(client_.get(), host_.get()); |
63 } | 64 } |
64 | 65 |
| 66 void AuthenticatorTestBase::RunHostInitiatedAuthExchange() { |
| 67 ContinueAuthExchangeWith(host_.get(), client_.get()); |
| 68 } |
| 69 |
65 // static | 70 // static |
66 void AuthenticatorTestBase::ContinueAuthExchangeWith(Authenticator* sender, | 71 void AuthenticatorTestBase::ContinueAuthExchangeWith(Authenticator* sender, |
67 Authenticator* receiver) { | 72 Authenticator* receiver) { |
68 scoped_ptr<buzz::XmlElement> message; | 73 scoped_ptr<buzz::XmlElement> message; |
69 ASSERT_NE(Authenticator::WAITING_MESSAGE, sender->state()); | 74 ASSERT_NE(Authenticator::WAITING_MESSAGE, sender->state()); |
70 if (sender->state() == Authenticator::ACCEPTED || | 75 if (sender->state() == Authenticator::ACCEPTED || |
71 sender->state() == Authenticator::REJECTED) | 76 sender->state() == Authenticator::REJECTED) |
72 return; | 77 return; |
73 // Pass message from client to host. | 78 // Pass message from client to host. |
74 ASSERT_EQ(Authenticator::MESSAGE_READY, sender->state()); | 79 ASSERT_EQ(Authenticator::MESSAGE_READY, sender->state()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 142 |
138 void AuthenticatorTestBase::OnClientConnected( | 143 void AuthenticatorTestBase::OnClientConnected( |
139 net::Error error, | 144 net::Error error, |
140 scoped_ptr<net::StreamSocket> socket) { | 145 scoped_ptr<net::StreamSocket> socket) { |
141 client_callback_.OnDone(error); | 146 client_callback_.OnDone(error); |
142 client_socket_ = socket.Pass(); | 147 client_socket_ = socket.Pass(); |
143 } | 148 } |
144 | 149 |
145 } // namespace protocol | 150 } // namespace protocol |
146 } // namespace remoting | 151 } // namespace remoting |
OLD | NEW |