summaryrefslogtreecommitdiffstats
path: root/remoting/test/test_chromoting_client.cc
diff options
context:
space:
mode:
authortonychun <tonychun@google.com>2015-07-20 13:29:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-20 20:29:40 +0000
commitf21b41ef4aa2b84f0be11fdc95c47cf54e543e1f (patch)
treedf3eef6144ca1c3479fd2500d5d9f8efaf2224b9 /remoting/test/test_chromoting_client.cc
parent094d8b992dff839ef9e1c88b4762d49523d3683b (diff)
downloadchromium_src-f21b41ef4aa2b84f0be11fdc95c47cf54e543e1f.zip
chromium_src-f21b41ef4aa2b84f0be11fdc95c47cf54e543e1f.tar.gz
chromium_src-f21b41ef4aa2b84f0be11fdc95c47cf54e543e1f.tar.bz2
Support for connecting to localhost on the chromoting test driver.
Completed connection to localhost. I've added a new StartConnection method in TestChromotingClient which reuses almost all of the code provided to create a chromoting connection. In addition, I've added a new parameter called "client-pin", which will allow for the user to pass in a PIN to authenticate the connection. BUG= Review URL: https://codereview.chromium.org/1237093004 Cr-Commit-Position: refs/heads/master@{#339504}
Diffstat (limited to 'remoting/test/test_chromoting_client.cc')
-rw-r--r--remoting/test/test_chromoting_client.cc60
1 files changed, 29 insertions, 31 deletions
diff --git a/remoting/test/test_chromoting_client.cc b/remoting/test/test_chromoting_client.cc
index dbf4eca..d838ba3 100644
--- a/remoting/test/test_chromoting_client.cc
+++ b/remoting/test/test_chromoting_client.cc
@@ -17,7 +17,6 @@
#include "remoting/client/chromoting_client.h"
#include "remoting/client/client_context.h"
#include "remoting/client/token_fetcher_proxy.h"
-#include "remoting/protocol/authentication_method.h"
#include "remoting/protocol/chromium_port_allocator.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/libjingle_transport_factory.h"
@@ -26,14 +25,10 @@
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/third_party_client_authenticator.h"
#include "remoting/signaling/xmpp_signal_strategy.h"
-#include "remoting/test/remote_host_info_fetcher.h"
+#include "remoting/test/connection_setup_info.h"
#include "remoting/test/test_video_renderer.h"
namespace {
-
-const char kAppRemotingCapabilities[] =
- "rateLimitResizeRequests desktopShape sendInitialResolution googleDrive";
-
const char kXmppHostName[] = "talk.google.com";
const int kXmppPortNumber = 5222;
@@ -58,6 +53,13 @@ void FetchThirdPartyToken(
}
}
+void FetchSecret(
+ const std::string& client_secret,
+ bool pairing_expected,
+ const remoting::protocol::SecretFetchedCallback& secret_fetched_callback) {
+ secret_fetched_callback.Run(client_secret);
+}
+
const char* ConnectionStateToFriendlyString(
remoting::protocol::ConnectionToHost::State state) {
switch (state) {
@@ -147,13 +149,7 @@ TestChromotingClient::~TestChromotingClient() {
}
void TestChromotingClient::StartConnection(
- const std::string& user_name,
- const std::string& access_token,
- const RemoteHostInfo& remote_host_info) {
- DCHECK(!user_name.empty());
- DCHECK(!access_token.empty());
- DCHECK(remote_host_info.IsReadyForConnection());
-
+ const ConnectionSetupInfo& connection_setup_info) {
// Required to establish a connection to the host.
jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
@@ -183,8 +179,8 @@ void TestChromotingClient::StartConnection(
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;
+ xmpp_server_config.username = connection_setup_info.user_name;
+ xmpp_server_config.auth_token = connection_setup_info.access_token;
// Set up the signal strategy. This must outlive the client object.
signal_strategy_.reset(
@@ -205,26 +201,28 @@ void TestChromotingClient::StartConnection(
scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
token_fetcher(new TokenFetcherProxy(
- base::Bind(&FetchThirdPartyToken, remote_host_info.authorization_code,
- remote_host_info.shared_secret),
- "FAKE_HOST_PUBLIC_KEY"));
-
- std::vector<protocol::AuthenticationMethod> auth_methods;
- auth_methods.push_back(protocol::AuthenticationMethod::ThirdParty());
+ base::Bind(&FetchThirdPartyToken,
+ connection_setup_info.authorization_code,
+ connection_setup_info.shared_secret),
+ connection_setup_info.public_key));
- // FetchSecretCallback is used for PIN based auth which we aren't using so we
- // can pass a null callback here.
protocol::FetchSecretCallback fetch_secret_callback;
+ if (!connection_setup_info.pin.empty()) {
+ fetch_secret_callback = base::Bind(&FetchSecret, connection_setup_info.pin);
+ }
+
scoped_ptr<protocol::Authenticator> authenticator(
new protocol::NegotiatingClientAuthenticator(
- std::string(), // client_pairing_id
- std::string(), // shared_secret
- std::string(), // authentication_tag
- fetch_secret_callback, token_fetcher.Pass(), auth_methods));
-
- chromoting_client_->Start(signal_strategy_.get(), authenticator.Pass(),
- transport_factory.Pass(), remote_host_info.host_jid,
- kAppRemotingCapabilities);
+ connection_setup_info.pairing_id,
+ connection_setup_info.shared_secret,
+ connection_setup_info.host_id,
+ fetch_secret_callback,
+ token_fetcher.Pass(),
+ connection_setup_info.auth_methods));
+
+ chromoting_client_->Start(
+ signal_strategy_.get(), authenticator.Pass(), transport_factory.Pass(),
+ connection_setup_info.host_jid, connection_setup_info.capabilities);
}
void TestChromotingClient::EndConnection() {