Commit 7432ef1a authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[remoting][IT2ME] Register support host over remoting API

This CL adds a RemotingRegisterSupportHostRequest that registers an
IT2ME host using the new remoting API. This will be used for the
ChromeOS enterprise use case but the website will still use the old
XMPP-based registration request until it is updated to support that.

Bug: 962765
Change-Id: Ifcf2eb6eaba76db6386ae27f86f20e06088383f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611023
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660738}
parent c6d7bccb
...@@ -245,10 +245,11 @@ static_library("common") { ...@@ -245,10 +245,11 @@ static_library("common") {
"process_stats_agent.h", "process_stats_agent.h",
"process_stats_sender.cc", "process_stats_sender.cc",
"process_stats_sender.h", "process_stats_sender.h",
"register_support_host_request.cc",
"register_support_host_request.h", "register_support_host_request.h",
"remote_input_filter.cc", "remote_input_filter.cc",
"remote_input_filter.h", "remote_input_filter.h",
"remoting_register_support_host_request.cc",
"remoting_register_support_host_request.h",
"resizing_host_observer.cc", "resizing_host_observer.cc",
"resizing_host_observer.h", "resizing_host_observer.h",
"resources.h", "resources.h",
...@@ -293,6 +294,8 @@ static_library("common") { ...@@ -293,6 +294,8 @@ static_library("common") {
"username.h", "username.h",
"xmpp_heartbeat_sender.cc", "xmpp_heartbeat_sender.cc",
"xmpp_heartbeat_sender.h", "xmpp_heartbeat_sender.h",
"xmpp_register_support_host_request.cc",
"xmpp_register_support_host_request.h",
] ]
libs = [] libs = []
...@@ -317,6 +320,7 @@ static_library("common") { ...@@ -317,6 +320,7 @@ static_library("common") {
"//remoting/host/input_monitor", "//remoting/host/input_monitor",
"//remoting/host/security_key", "//remoting/host/security_key",
"//remoting/proto/remoting/v1:directory_grpc_library", "//remoting/proto/remoting/v1:directory_grpc_library",
"//remoting/proto/remoting/v1:remote_support_host_grpc_library",
"//remoting/protocol", "//remoting/protocol",
"//remoting/resources", "//remoting/resources",
"//services/network:network_service", "//services/network:network_service",
...@@ -500,7 +504,6 @@ source_set("unit_tests") { ...@@ -500,7 +504,6 @@ source_set("unit_tests") {
"pin_hash_unittest.cc", "pin_hash_unittest.cc",
"policy_watcher_unittest.cc", "policy_watcher_unittest.cc",
"process_stats_sender_unittest.cc", "process_stats_sender_unittest.cc",
"register_support_host_request_unittest.cc",
"remote_input_filter_unittest.cc", "remote_input_filter_unittest.cc",
"resizing_host_observer_unittest.cc", "resizing_host_observer_unittest.cc",
"resources_unittest.cc", "resources_unittest.cc",
...@@ -513,6 +516,7 @@ source_set("unit_tests") { ...@@ -513,6 +516,7 @@ source_set("unit_tests") {
"token_validator_factory_impl_unittest.cc", "token_validator_factory_impl_unittest.cc",
"touch_injector_win_unittest.cc", "touch_injector_win_unittest.cc",
"xmpp_heartbeat_sender_unittest.cc", "xmpp_heartbeat_sender_unittest.cc",
"xmpp_register_support_host_request_unittest.cc",
] ]
if (use_ozone || is_chromeos) { if (use_ozone || is_chromeos) {
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "remoting/host/host_status_logger.h" #include "remoting/host/host_status_logger.h"
#include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h"
#include "remoting/host/it2me_desktop_environment.h" #include "remoting/host/it2me_desktop_environment.h"
#include "remoting/host/register_support_host_request.h"
#include "remoting/protocol/auth_util.h" #include "remoting/protocol/auth_util.h"
#include "remoting/protocol/chromium_port_allocator_factory.h" #include "remoting/protocol/chromium_port_allocator_factory.h"
#include "remoting/protocol/ice_transport.h" #include "remoting/protocol/ice_transport.h"
...@@ -78,6 +77,7 @@ void It2MeHost::Connect( ...@@ -78,6 +77,7 @@ void It2MeHost::Connect(
std::unique_ptr<ChromotingHostContext> host_context, std::unique_ptr<ChromotingHostContext> host_context,
std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<base::DictionaryValue> policies,
std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory,
std::unique_ptr<RegisterSupportHostRequest> register_request,
base::WeakPtr<It2MeHost::Observer> observer, base::WeakPtr<It2MeHost::Observer> observer,
std::unique_ptr<SignalStrategy> signal_strategy, std::unique_ptr<SignalStrategy> signal_strategy,
const std::string& username, const std::string& username,
...@@ -101,7 +101,8 @@ void It2MeHost::Connect( ...@@ -101,7 +101,8 @@ void It2MeHost::Connect(
// Switch to the network thread to start the actual connection. // Switch to the network thread to start the actual connection.
host_context_->network_task_runner()->PostTask( host_context_->network_task_runner()->PostTask(
FROM_HERE, base::BindOnce(&It2MeHost::ConnectOnNetworkThread, this, FROM_HERE, base::BindOnce(&It2MeHost::ConnectOnNetworkThread, this,
username, directory_bot_jid, ice_config)); username, directory_bot_jid, ice_config,
std::move(register_request)));
} }
void It2MeHost::Disconnect() { void It2MeHost::Disconnect() {
...@@ -110,9 +111,11 @@ void It2MeHost::Disconnect() { ...@@ -110,9 +111,11 @@ void It2MeHost::Disconnect() {
FROM_HERE, base::BindOnce(&It2MeHost::DisconnectOnNetworkThread, this)); FROM_HERE, base::BindOnce(&It2MeHost::DisconnectOnNetworkThread, this));
} }
void It2MeHost::ConnectOnNetworkThread(const std::string& username, void It2MeHost::ConnectOnNetworkThread(
const std::string& directory_bot_jid, const std::string& username,
const protocol::IceConfig& ice_config) { const std::string& directory_bot_jid,
const protocol::IceConfig& ice_config,
std::unique_ptr<RegisterSupportHostRequest> register_request) {
DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
DCHECK_EQ(kDisconnected, state_); DCHECK_EQ(kDisconnected, state_);
...@@ -139,11 +142,9 @@ void It2MeHost::ConnectOnNetworkThread(const std::string& username, ...@@ -139,11 +142,9 @@ void It2MeHost::ConnectOnNetworkThread(const std::string& username,
host_key_pair_ = RsaKeyPair::Generate(); host_key_pair_ = RsaKeyPair::Generate();
// Request registration of the host for support. // Request registration of the host for support.
std::unique_ptr<RegisterSupportHostRequest> register_request( register_request->StartRequest(
new RegisterSupportHostRequest( signal_strategy_.get(), host_key_pair_,
signal_strategy_.get(), host_key_pair_, directory_bot_jid, base::BindOnce(&It2MeHost::OnReceivedSupportID, base::Unretained(this)));
base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this))));
// Beyond this point nothing can fail, so save the config and request. // Beyond this point nothing can fail, so save the config and request.
register_request_ = std::move(register_request); register_request_ = std::move(register_request);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "remoting/host/host_status_observer.h" #include "remoting/host/host_status_observer.h"
#include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h"
#include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h"
#include "remoting/host/register_support_host_request.h"
#include "remoting/protocol/errors.h" #include "remoting/protocol/errors.h"
#include "remoting/protocol/port_range.h" #include "remoting/protocol/port_range.h"
#include "remoting/protocol/validating_authenticator.h" #include "remoting/protocol/validating_authenticator.h"
...@@ -80,6 +81,7 @@ class It2MeHost : public base::RefCountedThreadSafe<It2MeHost>, ...@@ -80,6 +81,7 @@ class It2MeHost : public base::RefCountedThreadSafe<It2MeHost>,
std::unique_ptr<ChromotingHostContext> context, std::unique_ptr<ChromotingHostContext> context,
std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<base::DictionaryValue> policies,
std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory,
std::unique_ptr<RegisterSupportHostRequest> register_request,
base::WeakPtr<It2MeHost::Observer> observer, base::WeakPtr<It2MeHost::Observer> observer,
std::unique_ptr<SignalStrategy> signal_strategy, std::unique_ptr<SignalStrategy> signal_strategy,
const std::string& username, const std::string& username,
...@@ -131,9 +133,11 @@ class It2MeHost : public base::RefCountedThreadSafe<It2MeHost>, ...@@ -131,9 +133,11 @@ class It2MeHost : public base::RefCountedThreadSafe<It2MeHost>,
It2MeConfirmationDialog::Result result); It2MeConfirmationDialog::Result result);
// Task posted to the network thread from Connect(). // Task posted to the network thread from Connect().
void ConnectOnNetworkThread(const std::string& username, void ConnectOnNetworkThread(
const std::string& directory_bot_jid, const std::string& username,
const protocol::IceConfig& ice_config); const std::string& directory_bot_jid,
const protocol::IceConfig& ice_config,
std::unique_ptr<RegisterSupportHostRequest> register_request);
// Called when the support host registration completes. // Called when the support host registration completes.
void OnReceivedSupportID(const std::string& support_id, void OnReceivedSupportID(const std::string& support_id,
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "remoting/host/chromoting_host_context.h" #include "remoting/host/chromoting_host_context.h"
#include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h"
#include "remoting/host/policy_watcher.h" #include "remoting/host/policy_watcher.h"
#include "remoting/host/xmpp_register_support_host_request.h"
#include "remoting/protocol/errors.h" #include "remoting/protocol/errors.h"
#include "remoting/protocol/transport_context.h" #include "remoting/protocol/transport_context.h"
#include "remoting/signaling/fake_signal_strategy.h" #include "remoting/signaling/fake_signal_strategy.h"
...@@ -291,10 +292,13 @@ void It2MeHostTest::StartHost(bool enable_dialogs) { ...@@ -291,10 +292,13 @@ void It2MeHostTest::StartHost(bool enable_dialogs) {
// false should only be run on ChromeOS. // false should only be run on ChromeOS.
it2me_host_->set_enable_dialogs(enable_dialogs); it2me_host_->set_enable_dialogs(enable_dialogs);
} }
it2me_host_->Connect(host_context_->Copy(), policies_->CreateDeepCopy(), auto register_host_request =
std::move(dialog_factory), weak_factory_.GetWeakPtr(), std::make_unique<XmppRegisterSupportHostRequest>("fake_bot_jid");
std::move(fake_signal_strategy), kTestUserName, it2me_host_->Connect(
"fake_bot_jid", ice_config); host_context_->Copy(), policies_->CreateDeepCopy(),
std::move(dialog_factory), std::move(register_host_request),
weak_factory_.GetWeakPtr(), std::move(fake_signal_strategy),
kTestUserName, "fake_bot_jid", ice_config);
base::RunLoop run_loop; base::RunLoop run_loop;
state_change_callback_ = state_change_callback_ =
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "remoting/host/host_exit_codes.h" #include "remoting/host/host_exit_codes.h"
#include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h"
#include "remoting/host/policy_watcher.h" #include "remoting/host/policy_watcher.h"
#include "remoting/host/xmpp_register_support_host_request.h"
#include "remoting/protocol/ice_config.h" #include "remoting/protocol/ice_config.h"
#include "remoting/signaling/delegating_signal_strategy.h" #include "remoting/signaling/delegating_signal_strategy.h"
...@@ -287,10 +288,13 @@ void It2MeNativeMessagingHost::ProcessConnect( ...@@ -287,10 +288,13 @@ void It2MeNativeMessagingHost::ProcessConnect(
#if defined(OS_CHROMEOS) || !defined(NDEBUG) #if defined(OS_CHROMEOS) || !defined(NDEBUG)
it2me_host_->set_enable_dialogs(!no_dialogs); it2me_host_->set_enable_dialogs(!no_dialogs);
#endif #endif
auto register_host_request =
std::make_unique<XmppRegisterSupportHostRequest>(directory_bot_jid);
it2me_host_->Connect(host_context_->Copy(), std::move(policies), it2me_host_->Connect(host_context_->Copy(), std::move(policies),
std::make_unique<It2MeConfirmationDialogFactory>(), std::make_unique<It2MeConfirmationDialogFactory>(),
weak_ptr_, std::move(signal_strategy), username, std::move(register_host_request), weak_ptr_,
directory_bot_jid, ice_config); std::move(signal_strategy), username, directory_bot_jid,
ice_config);
SendMessageToClient(std::move(response)); SendMessageToClient(std::move(response));
} }
......
...@@ -118,6 +118,7 @@ class MockIt2MeHost : public It2MeHost { ...@@ -118,6 +118,7 @@ class MockIt2MeHost : public It2MeHost {
void Connect(std::unique_ptr<ChromotingHostContext> context, void Connect(std::unique_ptr<ChromotingHostContext> context,
std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<base::DictionaryValue> policies,
std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory,
std::unique_ptr<RegisterSupportHostRequest> register_request,
base::WeakPtr<It2MeHost::Observer> observer, base::WeakPtr<It2MeHost::Observer> observer,
std::unique_ptr<SignalStrategy> signal_strategy, std::unique_ptr<SignalStrategy> signal_strategy,
const std::string& username, const std::string& username,
...@@ -137,6 +138,7 @@ void MockIt2MeHost::Connect( ...@@ -137,6 +138,7 @@ void MockIt2MeHost::Connect(
std::unique_ptr<ChromotingHostContext> context, std::unique_ptr<ChromotingHostContext> context,
std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<base::DictionaryValue> policies,
std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory,
std::unique_ptr<RegisterSupportHostRequest> register_request,
base::WeakPtr<It2MeHost::Observer> observer, base::WeakPtr<It2MeHost::Observer> observer,
std::unique_ptr<SignalStrategy> signal_strategy, std::unique_ptr<SignalStrategy> signal_strategy,
const std::string& username, const std::string& username,
...@@ -152,6 +154,7 @@ void MockIt2MeHost::Connect( ...@@ -152,6 +154,7 @@ void MockIt2MeHost::Connect(
host_context_ = std::move(context); host_context_ = std::move(context);
observer_ = std::move(observer); observer_ = std::move(observer);
signal_strategy_ = std::move(signal_strategy); signal_strategy_ = std::move(signal_strategy);
register_request_ = std::move(register_request);
OnPolicyUpdate(std::move(policies)); OnPolicyUpdate(std::move(policies));
...@@ -640,7 +643,7 @@ TEST_F(It2MeNativeMessagingHostTest, ...@@ -640,7 +643,7 @@ TEST_F(It2MeNativeMessagingHostTest,
connect_message.SetBoolean("noDialogs", true); connect_message.SetBoolean("noDialogs", true);
WriteMessageToInputPipe(connect_message); WriteMessageToInputPipe(connect_message);
VerifyConnectResponses(next_id); VerifyConnectResponses(next_id);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS) || !defined(NDEBUG)
EXPECT_FALSE(factory_raw_ptr_->host->enable_dialogs()); EXPECT_FALSE(factory_raw_ptr_->host->enable_dialogs());
#else #else
EXPECT_TRUE(factory_raw_ptr_->host->enable_dialogs()); EXPECT_TRUE(factory_raw_ptr_->host->enable_dialogs());
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -8,83 +8,38 @@ ...@@ -8,83 +8,38 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/callback.h" #include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "remoting/base/rsa_key_pair.h" #include "remoting/base/rsa_key_pair.h"
#include "remoting/protocol/errors.h" #include "remoting/protocol/errors.h"
#include "remoting/signaling/signal_strategy.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
namespace jingle_xmpp {
class XmlElement;
} // namespace jingle_xmpp
namespace base {
class TimeDelta;
} // namespace base
namespace remoting { namespace remoting {
class IqRequest; class SignalStrategy;
class IqSender;
// RegisterSupportHostRequest sends a request to register the host for // RegisterSupportHostRequest sends a request to register the host for
// a SupportID, as soon as the associated SignalStrategy becomes // a SupportID. When a response is received, it calls the callback specified in
// connected. When a response is received from the bot, it calls the // the StartRequest() method.
// callback specified in the Init() method. class RegisterSupportHostRequest {
class RegisterSupportHostRequest : public SignalStrategy::Listener {
public: public:
// First parameter is the new SessionID received from the bot. Second // First parameter is the new SessionID received from the bot. Second
// parameter is the amount of time until that id expires. Third parameter // parameter is the amount of time until that id expires. Third parameter
// is an error message if the request failed, or null if it succeeded. // is an error message if the request failed, or null if it succeeded.
typedef base::Callback<void(const std::string&, using RegisterCallback =
base::OnceCallback<void(const std::string&,
const base::TimeDelta&, const base::TimeDelta&,
protocol::ErrorCode error_code)> protocol::ErrorCode error_code)>;
RegisterCallback;
// |signal_strategy| and |key_pair| must outlive this RegisterSupportHostRequest() = default;
// object. |callback| is called when registration response is virtual ~RegisterSupportHostRequest() = default;
// received from the server. Callback is never called if the bot
// malfunctions and doesn't respond to the request.
//
// TODO(sergeyu): This class should have timeout for the bot
// response.
RegisterSupportHostRequest(SignalStrategy* signal_strategy,
scoped_refptr<RsaKeyPair> key_pair,
const std::string& directory_bot_jid,
const RegisterCallback& callback);
~RegisterSupportHostRequest() override;
// HostStatusObserver implementation. virtual void StartRequest(SignalStrategy* signal_strategy,
void OnSignalStrategyStateChange(SignalStrategy::State state) override; scoped_refptr<RsaKeyPair> key_pair,
bool OnSignalStrategyIncomingStanza(const jingle_xmpp::XmlElement* stanza) override; RegisterCallback callback) = 0;
private: private:
void DoSend();
std::unique_ptr<jingle_xmpp::XmlElement> CreateRegistrationRequest(
const std::string& jid);
std::unique_ptr<jingle_xmpp::XmlElement> CreateSignature(const std::string& jid);
void ProcessResponse(IqRequest* request, const jingle_xmpp::XmlElement* response);
void ParseResponse(const jingle_xmpp::XmlElement* response,
std::string* support_id,
base::TimeDelta* lifetime,
protocol::ErrorCode* error_code);
void CallCallback(const std::string& support_id,
base::TimeDelta lifetime,
protocol::ErrorCode error_code);
SignalStrategy* signal_strategy_;
scoped_refptr<RsaKeyPair> key_pair_;
std::string directory_bot_jid_;
RegisterCallback callback_;
std::unique_ptr<IqSender> iq_sender_;
std::unique_ptr<IqRequest> request_;
DISALLOW_COPY_AND_ASSIGN(RegisterSupportHostRequest); DISALLOW_COPY_AND_ASSIGN(RegisterSupportHostRequest);
}; };
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/remoting_register_support_host_request.h"
#include "base/strings/stringize_macros.h"
#include "remoting/base/grpc_support/grpc_async_unary_request.h"
#include "remoting/base/grpc_support/grpc_channel.h"
#include "remoting/base/grpc_support/grpc_util.h"
#include "remoting/base/oauth_token_getter.h"
#include "remoting/base/service_urls.h"
#include "remoting/host/host_details.h"
#include "remoting/signaling/ftl_signal_strategy.h"
#include "remoting/signaling/signaling_address.h"
#include "remoting/signaling/xmpp_signal_strategy.h"
namespace remoting {
namespace {
protocol::ErrorCode MapError(grpc::StatusCode status_code) {
switch (status_code) {
case grpc::StatusCode::OK:
return protocol::ErrorCode::OK;
case grpc::StatusCode::DEADLINE_EXCEEDED:
return protocol::ErrorCode::SIGNALING_TIMEOUT;
case grpc::StatusCode::PERMISSION_DENIED:
case grpc::StatusCode::UNAUTHENTICATED:
return protocol::ErrorCode::AUTHENTICATION_FAILED;
default:
return protocol::ErrorCode::SIGNALING_ERROR;
}
}
} // namespace
RemotingRegisterSupportHostRequest::RemotingRegisterSupportHostRequest(
std::unique_ptr<OAuthTokenGetter> token_getter)
: token_getter_(std::move(token_getter)),
grpc_executor_(token_getter_.get()) {
remote_support_ = RemoteSupportService::NewStub(CreateSslChannelForEndpoint(
ServiceUrls::GetInstance()->remoting_server_endpoint()));
}
RemotingRegisterSupportHostRequest::~RemotingRegisterSupportHostRequest() {
if (signal_strategy_) {
signal_strategy_->RemoveListener(this);
}
}
void RemotingRegisterSupportHostRequest::StartRequest(
SignalStrategy* signal_strategy,
scoped_refptr<RsaKeyPair> key_pair,
RegisterCallback callback) {
DCHECK(signal_strategy);
DCHECK(key_pair);
DCHECK(callback);
signal_strategy_ = static_cast<MuxingSignalStrategy*>(signal_strategy);
key_pair_ = key_pair;
callback_ = std::move(callback);
signal_strategy_->AddListener(this);
}
void RemotingRegisterSupportHostRequest::OnSignalStrategyStateChange(
SignalStrategy::State state) {
switch (state) {
case SignalStrategy::State::CONNECTED:
RegisterHost();
break;
case SignalStrategy::State::DISCONNECTED:
RunCallback({}, {}, protocol::ErrorCode::SIGNALING_ERROR);
break;
default:
// Do nothing.
break;
}
}
bool RemotingRegisterSupportHostRequest::OnSignalStrategyIncomingStanza(
const jingle_xmpp::XmlElement* stanza) {
return false;
}
void RemotingRegisterSupportHostRequest::RegisterHost() {
apis::v1::RegisterSupportHostRequest request;
request.set_public_key(key_pair_->GetPublicKey());
if (signal_strategy_->ftl_signal_strategy()->GetState() ==
SignalStrategy::State::CONNECTED) {
request.set_tachyon_id(
signal_strategy_->ftl_signal_strategy()->GetLocalAddress().jid());
}
if (signal_strategy_->xmpp_signal_strategy()->GetState() ==
SignalStrategy::State::CONNECTED) {
request.set_jabber_id(
signal_strategy_->xmpp_signal_strategy()->GetLocalAddress().jid());
}
request.set_host_version(STRINGIZE(VERSION));
request.set_host_os_name(GetHostOperatingSystemName());
request.set_host_os_version(GetHostOperatingSystemVersion());
auto grpc_request = CreateGrpcAsyncUnaryRequest(
base::BindOnce(&RemoteSupportService::Stub::AsyncRegisterSupportHost,
base::Unretained(remote_support_.get())),
request,
base::BindOnce(&RemotingRegisterSupportHostRequest::OnRegisterHostResult,
base::Unretained(this)));
grpc_executor_.ExecuteRpc(std::move(grpc_request));
}
void RemotingRegisterSupportHostRequest::OnRegisterHostResult(
const grpc::Status& status,
const apis::v1::RegisterSupportHostResponse& response) {
if (!status.ok()) {
RunCallback({}, {}, MapError(status.error_code()));
return;
}
base::TimeDelta lifetime =
base::TimeDelta::FromSeconds(response.support_id_lifetime_seconds());
RunCallback(response.support_id(), lifetime, protocol::ErrorCode::OK);
}
void RemotingRegisterSupportHostRequest::RunCallback(
const std::string& support_id,
base::TimeDelta lifetime,
protocol::ErrorCode error_code) {
// Cleanup state before calling the callback.
grpc_executor_.CancelPendingRequests();
signal_strategy_->RemoveListener(this);
signal_strategy_ = nullptr;
std::move(callback_).Run(support_id, lifetime, error_code);
}
} // namespace remoting
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_REMOTING_REGISTER_SUPPORT_HOST_REQUEST_H_
#define REMOTING_HOST_REMOTING_REGISTER_SUPPORT_HOST_REQUEST_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "remoting/base/grpc_support/grpc_authenticated_executor.h"
#include "remoting/host/register_support_host_request.h"
#include "remoting/proto/remoting/v1/remote_support_host_service.grpc.pb.h"
#include "remoting/signaling/muxing_signal_strategy.h"
namespace remoting {
class OAuthTokenGetter;
// A RegisterSupportHostRequest implementation that uses Remoting API to
// register the host.
//
// Note that IT ONLY WORKS WITH MuxingSignalStrategy.
class RemotingRegisterSupportHostRequest final
: public RegisterSupportHostRequest,
public SignalStrategy::Listener {
public:
explicit RemotingRegisterSupportHostRequest(
std::unique_ptr<OAuthTokenGetter> token_getter);
~RemotingRegisterSupportHostRequest() override;
// RegisterSupportHostRequest implementation.
void StartRequest(SignalStrategy* signal_strategy,
scoped_refptr<RsaKeyPair> key_pair,
RegisterCallback callback) override;
private:
using RemoteSupportService = apis::v1::RemoteSupportService;
// SignalStrategy::Listener interface.
void OnSignalStrategyStateChange(SignalStrategy::State state) override;
bool OnSignalStrategyIncomingStanza(
const jingle_xmpp::XmlElement* stanza) override;
void RegisterHost();
void OnRegisterHostResult(
const grpc::Status& status,
const apis::v1::RegisterSupportHostResponse& response);
void RunCallback(const std::string& support_id,
base::TimeDelta lifetime,
protocol::ErrorCode error_code);
MuxingSignalStrategy* signal_strategy_ = nullptr;
scoped_refptr<RsaKeyPair> key_pair_;
RegisterCallback callback_;
std::unique_ptr<OAuthTokenGetter> token_getter_;
GrpcAuthenticatedExecutor grpc_executor_;
std::unique_ptr<RemoteSupportService::Stub> remote_support_;
DISALLOW_COPY_AND_ASSIGN(RemotingRegisterSupportHostRequest);
};
} // namespace remoting
#endif // REMOTING_HOST_REMOTING_REGISTER_SUPPORT_HOST_REQUEST_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/register_support_host_request.h" #include "remoting/host/xmpp_register_support_host_request.h"
#include <stdint.h> #include <stdint.h>
...@@ -48,29 +48,32 @@ const char kSupportIdLifetimeTag[] = "support-id-lifetime"; ...@@ -48,29 +48,32 @@ const char kSupportIdLifetimeTag[] = "support-id-lifetime";
// The signaling timeout for register support host requests. // The signaling timeout for register support host requests.
constexpr int kRegisterRequestTimeoutInSeconds = 10; constexpr int kRegisterRequestTimeoutInSeconds = 10;
} // namespace
XmppRegisterSupportHostRequest::XmppRegisterSupportHostRequest(
const std::string& directory_bot_jid)
: directory_bot_jid_(directory_bot_jid) {}
XmppRegisterSupportHostRequest::~XmppRegisterSupportHostRequest() {
if (signal_strategy_)
signal_strategy_->RemoveListener(this);
} }
RegisterSupportHostRequest::RegisterSupportHostRequest( void XmppRegisterSupportHostRequest::StartRequest(
SignalStrategy* signal_strategy, SignalStrategy* signal_strategy,
scoped_refptr<RsaKeyPair> key_pair, scoped_refptr<RsaKeyPair> key_pair,
const std::string& directory_bot_jid, RegisterCallback callback) {
const RegisterCallback& callback) DCHECK(signal_strategy);
: signal_strategy_(signal_strategy), DCHECK(key_pair.get());
key_pair_(key_pair), DCHECK(callback);
directory_bot_jid_(directory_bot_jid), signal_strategy_ = signal_strategy;
callback_(callback) { key_pair_ = key_pair;
DCHECK(signal_strategy_); callback_ = std::move(callback);
DCHECK(key_pair_.get());
signal_strategy_->AddListener(this); signal_strategy_->AddListener(this);
iq_sender_.reset(new IqSender(signal_strategy_)); iq_sender_.reset(new IqSender(signal_strategy_));
} }
RegisterSupportHostRequest::~RegisterSupportHostRequest() { void XmppRegisterSupportHostRequest::OnSignalStrategyStateChange(
if (signal_strategy_)
signal_strategy_->RemoveListener(this);
}
void RegisterSupportHostRequest::OnSignalStrategyStateChange(
SignalStrategy::State state) { SignalStrategy::State state) {
if (state == SignalStrategy::CONNECTED) { if (state == SignalStrategy::CONNECTED) {
DCHECK(!callback_.is_null()); DCHECK(!callback_.is_null());
...@@ -79,9 +82,10 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange( ...@@ -79,9 +82,10 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange(
// remoting bot JID. // remoting bot JID.
std::string host_jid = signal_strategy_->GetLocalAddress().id(); std::string host_jid = signal_strategy_->GetLocalAddress().id();
request_ = iq_sender_->SendIq( request_ = iq_sender_->SendIq(
jingle_xmpp::STR_SET, directory_bot_jid_, CreateRegistrationRequest(host_jid), jingle_xmpp::STR_SET, directory_bot_jid_,
base::Bind(&RegisterSupportHostRequest::ProcessResponse, CreateRegistrationRequest(host_jid),
base::Unretained(this))); base::BindRepeating(&XmppRegisterSupportHostRequest::ProcessResponse,
base::Unretained(this)));
if (!request_) { if (!request_) {
LOG(ERROR) << "Error sending the register-support-host request."; LOG(ERROR) << "Error sending the register-support-host request.";
CallCallback(std::string(), base::TimeDelta(), CallCallback(std::string(), base::TimeDelta(),
...@@ -99,13 +103,14 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange( ...@@ -99,13 +103,14 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange(
} }
} }
bool RegisterSupportHostRequest::OnSignalStrategyIncomingStanza( bool XmppRegisterSupportHostRequest::OnSignalStrategyIncomingStanza(
const jingle_xmpp::XmlElement* stanza) { const jingle_xmpp::XmlElement* stanza) {
return false; return false;
} }
std::unique_ptr<XmlElement> std::unique_ptr<XmlElement>
RegisterSupportHostRequest::CreateRegistrationRequest(const std::string& jid) { XmppRegisterSupportHostRequest::CreateRegistrationRequest(
const std::string& jid) {
auto query = std::make_unique<XmlElement>( auto query = std::make_unique<XmlElement>(
QName(kChromotingXmlNamespace, kRegisterQueryTag)); QName(kChromotingXmlNamespace, kRegisterQueryTag));
...@@ -137,15 +142,15 @@ RegisterSupportHostRequest::CreateRegistrationRequest(const std::string& jid) { ...@@ -137,15 +142,15 @@ RegisterSupportHostRequest::CreateRegistrationRequest(const std::string& jid) {
return query; return query;
} }
std::unique_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( std::unique_ptr<XmlElement> XmppRegisterSupportHostRequest::CreateSignature(
const std::string& jid) { const std::string& jid) {
std::unique_ptr<XmlElement> signature_tag( std::unique_ptr<XmlElement> signature_tag(
new XmlElement(QName(kChromotingXmlNamespace, kSignatureTag))); new XmlElement(QName(kChromotingXmlNamespace, kSignatureTag)));
int64_t time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); int64_t time = static_cast<int64_t>(base::Time::Now().ToDoubleT());
std::string time_str(base::NumberToString(time)); std::string time_str(base::NumberToString(time));
signature_tag->AddAttr( signature_tag->AddAttr(QName(kChromotingXmlNamespace, kSignatureTimeAttr),
QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); time_str);
std::string message = NormalizeJid(jid) + ' ' + time_str; std::string message = NormalizeJid(jid) + ' ' + time_str;
std::string signature(key_pair_->SignMessage(message)); std::string signature(key_pair_->SignMessage(message));
...@@ -154,10 +159,10 @@ std::unique_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( ...@@ -154,10 +159,10 @@ std::unique_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature(
return signature_tag; return signature_tag;
} }
void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, void XmppRegisterSupportHostRequest::ParseResponse(const XmlElement* response,
std::string* support_id, std::string* support_id,
base::TimeDelta* lifetime, base::TimeDelta* lifetime,
ErrorCode* error_code) { ErrorCode* error_code) {
if (!response) { if (!response) {
LOG(ERROR) << "register-support-host request timed out."; LOG(ERROR) << "register-support-host request timed out.";
*error_code = ErrorCode::SIGNALING_TIMEOUT; *error_code = ErrorCode::SIGNALING_TIMEOUT;
...@@ -179,8 +184,8 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, ...@@ -179,8 +184,8 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
return; return;
} }
const XmlElement* result_element = response->FirstNamed(QName( const XmlElement* result_element = response->FirstNamed(
kChromotingXmlNamespace, kRegisterQueryResultTag)); QName(kChromotingXmlNamespace, kRegisterQueryResultTag));
if (!result_element) { if (!result_element) {
LOG(ERROR) << "<" << kRegisterQueryResultTag LOG(ERROR) << "<" << kRegisterQueryResultTag
<< "> is missing in the host registration response: " << "> is missing in the host registration response: "
...@@ -199,9 +204,8 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, ...@@ -199,9 +204,8 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
return; return;
} }
const XmlElement* lifetime_element = const XmlElement* lifetime_element = result_element->FirstNamed(
result_element->FirstNamed(QName(kChromotingXmlNamespace, QName(kChromotingXmlNamespace, kSupportIdLifetimeTag));
kSupportIdLifetimeTag));
if (!lifetime_element) { if (!lifetime_element) {
LOG(ERROR) << "<" << kSupportIdLifetimeTag LOG(ERROR) << "<" << kSupportIdLifetimeTag
<< "> is missing in the host registration response: " << "> is missing in the host registration response: "
...@@ -225,8 +229,9 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, ...@@ -225,8 +229,9 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
return; return;
} }
void RegisterSupportHostRequest::ProcessResponse(IqRequest* request, void XmppRegisterSupportHostRequest::ProcessResponse(
const XmlElement* response) { IqRequest* request,
const XmlElement* response) {
std::string support_id; std::string support_id;
base::TimeDelta lifetime; base::TimeDelta lifetime;
ErrorCode error_code = ErrorCode::OK; ErrorCode error_code = ErrorCode::OK;
...@@ -234,9 +239,9 @@ void RegisterSupportHostRequest::ProcessResponse(IqRequest* request, ...@@ -234,9 +239,9 @@ void RegisterSupportHostRequest::ProcessResponse(IqRequest* request,
CallCallback(support_id, lifetime, error_code); CallCallback(support_id, lifetime, error_code);
} }
void RegisterSupportHostRequest::CallCallback(const std::string& support_id, void XmppRegisterSupportHostRequest::CallCallback(const std::string& support_id,
base::TimeDelta lifetime, base::TimeDelta lifetime,
ErrorCode error_code) { ErrorCode error_code) {
// Cleanup state before calling the callback. // Cleanup state before calling the callback.
request_.reset(); request_.reset();
iq_sender_.reset(); iq_sender_.reset();
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_XMPP_REGISTER_SUPPORT_HOST_REQUEST_H_
#define REMOTING_HOST_XMPP_REGISTER_SUPPORT_HOST_REQUEST_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "remoting/base/rsa_key_pair.h"
#include "remoting/host/register_support_host_request.h"
#include "remoting/protocol/errors.h"
#include "remoting/signaling/signal_strategy.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
namespace jingle_xmpp {
class XmlElement;
} // namespace jingle_xmpp
namespace base {
class TimeDelta;
} // namespace base
namespace remoting {
class IqRequest;
class IqSender;
// XmppRegisterSupportHostRequest sends a request to register the host for
// a SupportID, as soon as the associated SignalStrategy becomes
// connected. When a response is received from the bot, it calls the
// callback specified in the Init() method.
class XmppRegisterSupportHostRequest : public RegisterSupportHostRequest,
public SignalStrategy::Listener {
public:
// |signal_strategy| and |key_pair| must outlive this
// object. |callback| is called when registration response is
// received from the server. Callback is never called if the bot
// malfunctions and doesn't respond to the request.
explicit XmppRegisterSupportHostRequest(const std::string& directory_bot_jid);
~XmppRegisterSupportHostRequest() override;
// RegisterSupportHostRequest implementation.
void StartRequest(SignalStrategy* signal_strategy,
scoped_refptr<RsaKeyPair> key_pair,
RegisterCallback callback) override;
// HostStatusObserver implementation.
void OnSignalStrategyStateChange(SignalStrategy::State state) override;
bool OnSignalStrategyIncomingStanza(
const jingle_xmpp::XmlElement* stanza) override;
private:
void DoSend();
std::unique_ptr<jingle_xmpp::XmlElement> CreateRegistrationRequest(
const std::string& jid);
std::unique_ptr<jingle_xmpp::XmlElement> CreateSignature(
const std::string& jid);
void ProcessResponse(IqRequest* request,
const jingle_xmpp::XmlElement* response);
void ParseResponse(const jingle_xmpp::XmlElement* response,
std::string* support_id,
base::TimeDelta* lifetime,
protocol::ErrorCode* error_code);
void CallCallback(const std::string& support_id,
base::TimeDelta lifetime,
protocol::ErrorCode error_code);
SignalStrategy* signal_strategy_ = nullptr;
scoped_refptr<RsaKeyPair> key_pair_;
std::string directory_bot_jid_;
RegisterCallback callback_;
std::unique_ptr<IqSender> iq_sender_;
std::unique_ptr<IqRequest> request_;
DISALLOW_COPY_AND_ASSIGN(XmppRegisterSupportHostRequest);
};
} // namespace remoting
#endif // REMOTING_HOST_XMPP_REGISTER_SUPPORT_HOST_REQUEST_H_
...@@ -2,18 +2,17 @@ ...@@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/register_support_host_request.h" #include "remoting/host/xmpp_register_support_host_request.h"
#include <stdint.h> #include <stdint.h>
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/stringize_macros.h" #include "base/strings/stringize_macros.h"
#include "base/test/mock_callback.h" #include "base/test/mock_callback.h"
#include "base/test/scoped_mock_time_message_loop_task_runner.h" #include "base/test/scoped_task_environment.h"
#include "remoting/base/constants.h" #include "remoting/base/constants.h"
#include "remoting/base/rsa_key_pair.h" #include "remoting/base/rsa_key_pair.h"
#include "remoting/base/test_rsa_key_pair.h" #include "remoting/base/test_rsa_key_pair.h"
...@@ -31,11 +30,11 @@ using jingle_xmpp::QName; ...@@ -31,11 +30,11 @@ using jingle_xmpp::QName;
using jingle_xmpp::XmlElement; using jingle_xmpp::XmlElement;
using testing::_; using testing::_;
using testing::DeleteArg;
using testing::Invoke; using testing::Invoke;
using testing::NotNull; using testing::NotNull;
using testing::Return; using testing::Return;
using testing::SaveArg; using testing::SaveArg;
using testing::DeleteArg;
namespace remoting { namespace remoting {
...@@ -58,10 +57,10 @@ ACTION_P(RemoveListener, list) { ...@@ -58,10 +57,10 @@ ACTION_P(RemoveListener, list) {
} // namespace } // namespace
class RegisterSupportHostRequestTest : public testing::Test { class XmppRegisterSupportHostRequestTest : public testing::Test {
public: public:
protected: protected:
RegisterSupportHostRequestTest() XmppRegisterSupportHostRequestTest()
: signal_strategy_(SignalingAddress(kTestJid)) {} : signal_strategy_(SignalingAddress(kTestJid)) {}
void SetUp() override { void SetUp() override {
...@@ -74,18 +73,17 @@ class RegisterSupportHostRequestTest : public testing::Test { ...@@ -74,18 +73,17 @@ class RegisterSupportHostRequestTest : public testing::Test {
.WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); .WillRepeatedly(RemoveListener(&signal_strategy_listeners_));
} }
base::MessageLoop message_loop_; base::test::ScopedTaskEnvironment scoped_task_environment_{
base::ScopedMockTimeMessageLoopTaskRunner mock_time_task_runner_; base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME};
MockSignalStrategy signal_strategy_; MockSignalStrategy signal_strategy_;
base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_; base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_;
scoped_refptr<RsaKeyPair> key_pair_; scoped_refptr<RsaKeyPair> key_pair_;
base::MockCallback<RegisterSupportHostRequest::RegisterCallback> callback_; base::MockCallback<RegisterSupportHostRequest::RegisterCallback> callback_;
}; };
TEST_F(RegisterSupportHostRequestTest, Timeout) { TEST_F(XmppRegisterSupportHostRequestTest, Timeout) {
std::unique_ptr<RegisterSupportHostRequest> request( auto request = std::make_unique<XmppRegisterSupportHostRequest>(kTestBotJid);
new RegisterSupportHostRequest(&signal_strategy_, key_pair_, kTestBotJid, request->StartRequest(&signal_strategy_, key_pair_, callback_.Get());
callback_.Get()));
EXPECT_CALL(signal_strategy_, GetNextId()).WillOnce(Return(kStanzaId)); EXPECT_CALL(signal_strategy_, GetNextId()).WillOnce(Return(kStanzaId));
EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull()))
.WillOnce(DoAll(DeleteArg<0>(), Return(true))); .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
...@@ -96,25 +94,23 @@ TEST_F(RegisterSupportHostRequestTest, Timeout) { ...@@ -96,25 +94,23 @@ TEST_F(RegisterSupportHostRequestTest, Timeout) {
EXPECT_CALL(callback_, Run("", base::TimeDelta::FromSeconds(0), EXPECT_CALL(callback_, Run("", base::TimeDelta::FromSeconds(0),
ErrorCode::SIGNALING_TIMEOUT)); ErrorCode::SIGNALING_TIMEOUT));
mock_time_task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(15)); scoped_task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(15));
} }
TEST_F(RegisterSupportHostRequestTest, Send) { TEST_F(XmppRegisterSupportHostRequestTest, Send) {
// |iq_request| is freed by RegisterSupportHostRequest. // |iq_request| is freed by XmppRegisterSupportHostRequest.
int64_t start_time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); int64_t start_time = static_cast<int64_t>(base::Time::Now().ToDoubleT());
std::unique_ptr<RegisterSupportHostRequest> request( auto request = std::make_unique<XmppRegisterSupportHostRequest>(kTestBotJid);
new RegisterSupportHostRequest(&signal_strategy_, key_pair_, kTestBotJid, request->StartRequest(&signal_strategy_, key_pair_, callback_.Get());
callback_.Get()));
XmlElement* sent_iq = nullptr; XmlElement* sent_iq = nullptr;
EXPECT_CALL(signal_strategy_, GetNextId()) EXPECT_CALL(signal_strategy_, GetNextId()).WillOnce(Return(kStanzaId));
.WillOnce(Return(kStanzaId));
EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull()))
.WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true)));
request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
mock_time_task_runner_->RunUntilIdle(); scoped_task_environment_.RunUntilIdle();
// Verify format of the query. // Verify format of the query.
std::unique_ptr<XmlElement> stanza(sent_iq); std::unique_ptr<XmlElement> stanza(sent_iq);
...@@ -172,13 +168,13 @@ TEST_F(RegisterSupportHostRequestTest, Send) { ...@@ -172,13 +168,13 @@ TEST_F(RegisterSupportHostRequestTest, Send) {
QName(kChromotingXmlNamespace, "register-support-host-result")); QName(kChromotingXmlNamespace, "register-support-host-result"));
response->AddElement(result); response->AddElement(result);
XmlElement* support_id = new XmlElement( XmlElement* support_id =
QName(kChromotingXmlNamespace, "support-id")); new XmlElement(QName(kChromotingXmlNamespace, "support-id"));
support_id->AddText(kSupportId); support_id->AddText(kSupportId);
result->AddElement(support_id); result->AddElement(support_id);
XmlElement* support_id_lifetime = new XmlElement( XmlElement* support_id_lifetime =
QName(kChromotingXmlNamespace, "support-id-lifetime")); new XmlElement(QName(kChromotingXmlNamespace, "support-id-lifetime"));
support_id_lifetime->AddText(kSupportIdLifetime); support_id_lifetime->AddText(kSupportIdLifetime);
result->AddElement(support_id_lifetime); result->AddElement(support_id_lifetime);
...@@ -189,7 +185,7 @@ TEST_F(RegisterSupportHostRequestTest, Send) { ...@@ -189,7 +185,7 @@ TEST_F(RegisterSupportHostRequestTest, Send) {
} }
EXPECT_EQ(1, consumed); EXPECT_EQ(1, consumed);
mock_time_task_runner_->RunUntilIdle(); scoped_task_environment_.RunUntilIdle();
} }
} // namespace remoting } // namespace remoting
...@@ -47,3 +47,10 @@ cc_grpc_library("network_traversal_grpc_library") { ...@@ -47,3 +47,10 @@ cc_grpc_library("network_traversal_grpc_library") {
":network_traversal_proto", ":network_traversal_proto",
] ]
} }
cc_grpc_library("remote_support_host_grpc_library") {
sources = [
"remote_support_host_messages.proto",
"remote_support_host_service.proto",
]
}
syntax = "proto2";
package remoting.apis.v1;
import "host_info.proto";
option optimize_for = LITE_RUNTIME;
// Request host info for a specific support host instance.
message GetSupportHostRequest {
// The unique identifier for the host being requested.
optional string support_id = 1;
}
// The response to a GetSupportHostRequest.
message GetSupportHostResponse {
// The connection info for the host associated with the given support_id.
optional HostInfo support_host = 1;
}
// Registers a support host instance.
message RegisterSupportHostRequest {
// Public key for the host. Must be a 2048-bit RSA key encoded with BASE64.
optional string public_key = 1;
// The ID associated with the host on the Talk network.
optional string jabber_id = 2;
// The ID associated with the host on the Tachyon network.
optional string tachyon_id = 3;
// Version of the It2Me host software installed on the host.
optional string host_version = 4;
// Operating system type of the host.
optional string host_os_name = 5;
// Operating system version of the host.
optional string host_os_version = 6;
}
// The response to a RegisterSupportHostRequest.
message RegisterSupportHostResponse {
// A unique identifier for the registered host.
optional string support_id = 1;
// The length of time |support_id| will remain valid.
optional int32 support_id_lifetime_seconds = 2;
}
syntax = "proto2";
package remoting.apis.v1;
import "remote_support_host_messages.proto";
option optimize_for = LITE_RUNTIME;
// A set of RPC services which provide remote support functionality.
service RemoteSupportService {
// RPC service which registers a remote support host.
rpc RegisterSupportHost(RegisterSupportHostRequest)
returns (RegisterSupportHostResponse) {}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment