OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/host/security_key/remote_security_key_ipc_client.h" | 5 #include "remoting/host/security_key/remote_security_key_ipc_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
15 #include "remoting/host/security_key/fake_ipc_gnubby_auth_handler.h" | 15 #include "remoting/host/security_key/fake_ipc_gnubby_auth_handler.h" |
16 #include "remoting/host/security_key/fake_remote_security_key_ipc_server.h" | 16 #include "remoting/host/security_key/fake_remote_security_key_ipc_server.h" |
| 17 #include "remoting/host/security_key/remote_security_key_ipc_constants.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 const int kTestConnectionId = 1; | 21 const int kTestConnectionId = 1; |
21 const char kNonexistentIpcChannelName[] = "Nonexistent_IPC_Channel"; | 22 const char kNonexistentIpcChannelName[] = "Nonexistent_IPC_Channel"; |
22 const char kValidIpcChannelName[] = | 23 const char kValidIpcChannelName[] = |
23 "Remote_Security_Key_Ipc_Client_Test_Channel."; | 24 "Remote_Security_Key_Ipc_Client_Test_Channel."; |
24 const int kLargeMessageSizeBytes = 256 * 1024; | 25 const int kLargeMessageSizeBytes = 256 * 1024; |
25 } // namespace | 26 } // namespace |
26 | 27 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 OperationComplete(/*failed=*/false); | 141 OperationComplete(/*failed=*/false); |
141 } | 142 } |
142 | 143 |
143 void RemoteSecurityKeyIpcClientTest::ClientMessageReceived( | 144 void RemoteSecurityKeyIpcClientTest::ClientMessageReceived( |
144 const std::string& response_payload) { | 145 const std::string& response_payload) { |
145 last_message_received_ = response_payload; | 146 last_message_received_ = response_payload; |
146 OperationComplete(/*failed=*/false); | 147 OperationComplete(/*failed=*/false); |
147 } | 148 } |
148 | 149 |
149 std::string RemoteSecurityKeyIpcClientTest::GenerateUniqueTestChannelName() { | 150 std::string RemoteSecurityKeyIpcClientTest::GenerateUniqueTestChannelName() { |
150 return kValidIpcChannelName + IPC::Channel::GenerateUniqueRandomChannelID(); | 151 return GetChannelNamePathPrefixForTest() + kValidIpcChannelName + |
| 152 IPC::Channel::GenerateUniqueRandomChannelID(); |
151 } | 153 } |
152 | 154 |
153 void RemoteSecurityKeyIpcClientTest::EstablishConnection(bool expect_success) { | 155 void RemoteSecurityKeyIpcClientTest::EstablishConnection(bool expect_success) { |
154 // Start up the security key forwarding session IPC channel first, that way | 156 // Start up the security key forwarding session IPC channel first, that way |
155 // we can provide the channel using the fake GnubbyAuthHandler later on. | 157 // we can provide the channel using the fake GnubbyAuthHandler later on. |
156 std::string ipc_session_channel_name = GenerateUniqueTestChannelName(); | 158 std::string ipc_session_channel_name = GenerateUniqueTestChannelName(); |
157 ASSERT_TRUE(fake_ipc_server_.CreateChannel( | 159 ASSERT_TRUE(fake_ipc_server_.CreateChannel( |
158 ipc_session_channel_name, | 160 ipc_session_channel_name, |
159 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); | 161 /*request_timeout=*/base::TimeDelta::FromMilliseconds(500))); |
160 ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(ipc_session_channel_name)); | 162 ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(ipc_session_channel_name)); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 remote_security_key_ipc_client_.SetExpectedIpcServerSessionIdForTest( | 345 remote_security_key_ipc_client_.SetExpectedIpcServerSessionIdForTest( |
344 session_id_ + 1); | 346 session_id_ + 1); |
345 | 347 |
346 // Attempting to establish a connection should fail here since the IPC Server | 348 // Attempting to establish a connection should fail here since the IPC Server |
347 // is 'running' in a different session than expected. | 349 // is 'running' in a different session than expected. |
348 EstablishConnection(/*expect_success=*/false); | 350 EstablishConnection(/*expect_success=*/false); |
349 } | 351 } |
350 #endif // defined(OS_WIN) | 352 #endif // defined(OS_WIN) |
351 | 353 |
352 } // namespace remoting | 354 } // namespace remoting |
OLD | NEW |