Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: remoting/test/test_chromoting_client.cc

Issue 1237093004: Support for connecting to localhost on the chromoting test driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/test/test_chromoting_client.cc
diff --git a/remoting/test/test_chromoting_client.cc b/remoting/test/test_chromoting_client.cc
index dbf4ecacc857efeba1d5cfd61d137b6bf691a82e..7bc721c5696d24777c0cee5dd5560f4a2b174c4f 100644
--- a/remoting/test/test_chromoting_client.cc
+++ b/remoting/test/test_chromoting_client.cc
@@ -26,6 +26,7 @@
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/third_party_client_authenticator.h"
#include "remoting/signaling/xmpp_signal_strategy.h"
+#include "remoting/test/host_info.h"
#include "remoting/test/remote_host_info_fetcher.h"
#include "remoting/test/test_video_renderer.h"
@@ -33,6 +34,7 @@ namespace {
const char kAppRemotingCapabilities[] =
"rateLimitResizeRequests desktopShape sendInitialResolution googleDrive";
+const char kChromotingCapabilities[] = "";
joedow 2015/07/14 19:58:44 This isn't really providing any value. This proba
tonychun 2015/07/15 17:32:50 Done.
const char kXmppHostName[] = "talk.google.com";
const int kXmppPortNumber = 5222;
@@ -58,6 +60,21 @@ void FetchThirdPartyToken(
}
}
+void FetchSecret(
+ const std::string& client_secret,
+ bool pairing_supported,
+ bool pairing_expected,
+ const remoting::protocol::SecretFetchedCallback& secret_fetched_callback) {
+ secret_fetched_callback.Run(client_secret);
+
+ // TODO(TonyChun): Pairing currently not supported for testing.
joedow 2015/07/14 19:58:44 Why include this code? The condition below actual
tonychun 2015/07/15 17:32:50 Done.
+ if (pairing_supported == pairing_expected) {
+ VLOG(2) << "Pairing supported!";
+ } else {
+ VLOG(2) << "Pairing not supported!";
+ }
+}
+
const char* ConnectionStateToFriendlyString(
remoting::protocol::ConnectionToHost::State state) {
switch (state) {
@@ -146,6 +163,86 @@ TestChromotingClient::~TestChromotingClient() {
EndConnection();
}
+void TestChromotingClient::StartConnection(const std::string& user_name,
+ const std::string& access_token,
+ const std::string& client_pin,
+ const HostInfo& host_info) {
joedow 2015/07/14 19:58:44 There is a lot of duplication here, can you refact
tonychun 2015/07/15 17:32:50 Done.
+ DCHECK(!user_name.empty());
+ DCHECK(!access_token.empty());
+ DCHECK(host_info.IsReadyForConnection());
+
+ // Required to establish a connection to the host.
+ jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
+
+ scoped_refptr<URLRequestContextGetter> request_context_getter;
+ request_context_getter = new URLRequestContextGetter(
+ base::ThreadTaskRunnerHandle::Get(), // network_runner
+ base::ThreadTaskRunnerHandle::Get()); // file_runner
+
+ client_context_.reset(new ClientContext(base::ThreadTaskRunnerHandle::Get()));
+
+ // Check to see if the user passed in a customized video renderer.
+ if (!video_renderer_) {
+ video_renderer_.reset(new TestVideoRenderer());
+ }
+
+ chromoting_client_.reset(new ChromotingClient(client_context_.get(),
+ this, // client_user_interface.
+ video_renderer_.get(),
+ nullptr)); // audio_player
+
+ if (test_connection_to_host_) {
+ chromoting_client_->SetConnectionToHostForTests(
+ test_connection_to_host_.Pass());
+ }
+
+ XmppSignalStrategy::XmppServerConfig xmpp_server_config;
+ xmpp_server_config.host = kXmppHostName;
+ xmpp_server_config.port = kXmppPortNumber;
+ xmpp_server_config.use_tls = true;
+ xmpp_server_config.username = user_name;
+ xmpp_server_config.auth_token = access_token;
+
+ // Set up the signal strategy. This must outlive the client object.
+ signal_strategy_.reset(
+ new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(),
+ request_context_getter, xmpp_server_config));
+
+ protocol::NetworkSettings network_settings(
+ protocol::NetworkSettings::NAT_TRAVERSAL_FULL);
+
+ scoped_ptr<protocol::ChromiumPortAllocator> port_allocator(
+ protocol::ChromiumPortAllocator::Create(request_context_getter,
+ network_settings));
+
+ scoped_ptr<protocol::TransportFactory> transport_factory(
+ new protocol::LibjingleTransportFactory(
+ signal_strategy_.get(), port_allocator.Pass(), network_settings,
+ protocol::TransportRole::CLIENT));
+
+ // Note: Only remote hosts without third party authenication methods
+ // can connect for now.
+ std::vector<protocol::AuthenticationMethod> auth_methods;
+ auth_methods.push_back(protocol::AuthenticationMethod::Spake2Pair());
+ auth_methods.push_back(protocol::AuthenticationMethod::Spake2(
+ protocol::AuthenticationMethod::HMAC_SHA256));
+ auth_methods.push_back(protocol::AuthenticationMethod::Spake2(
+ protocol::AuthenticationMethod::NONE));
+
+ protocol::FetchSecretCallback fetch_secret_callback =
+ base::Bind(&FetchSecret, client_pin, true);
+ scoped_ptr<protocol::Authenticator> authenticator(
+ new protocol::NegotiatingClientAuthenticator(
+ std::string(), // client_pairing_id
+ std::string(), // shared_secret
+ host_info.host_id, // authentication_tag
+ fetch_secret_callback, nullptr, auth_methods));
+
+ chromoting_client_->Start(signal_strategy_.get(), authenticator.Pass(),
+ transport_factory.Pass(), host_info.host_jid,
+ kChromotingCapabilities);
+}
+
void TestChromotingClient::StartConnection(
const std::string& user_name,
const std::string& access_token,
« remoting/test/test_chromoting_client.h ('K') | « remoting/test/test_chromoting_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698