Chromium Code Reviews| 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..6d42c1b7274104d3879de19f245fa77b96789832 100644 |
| --- a/remoting/test/test_chromoting_client.cc |
| +++ b/remoting/test/test_chromoting_client.cc |
| @@ -8,6 +8,7 @@ |
| #include <vector> |
| #include "base/logging.h" |
| +#include "base/strings/string_split.h" |
| #include "base/thread_task_runner_handle.h" |
| #include "jingle/glue/thread_wrapper.h" |
| #include "net/base/request_priority.h" |
| @@ -30,10 +31,6 @@ |
| #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 +55,14 @@ void FetchThirdPartyToken( |
| } |
| } |
| +void FetchSecret( |
| + const std::string& client_secret, |
| + bool pairing_supported, |
|
joedow
2015/07/16 03:23:19
is pairing_supported needed? You bind true to it
tonychun
2015/07/16 23:12:08
Removed the unused parameter.
|
| + 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 +152,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 ConnectionInfo& connection_info) { |
| // Required to establish a connection to the host. |
| jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| @@ -183,8 +182,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_info.user_name; |
| + xmpp_server_config.auth_token = connection_info.access_token; |
| // Set up the signal strategy. This must outlive the client object. |
| signal_strategy_.reset( |
| @@ -205,26 +204,37 @@ 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")); |
| - |
| + base::Bind(&FetchThirdPartyToken, |
| + connection_info.authorization_code, |
|
joedow
2015/07/16 03:23:19
indentation seems off here, either 4 spaces or lin
tonychun
2015/07/16 23:12:08
Done.
|
| + connection_info.shared_secret), |
| + connection_info.public_key)); |
| + |
| + // Parse |auth_methods_str| for authentication methods. |
|
joedow
2015/07/16 03:23:19
Why build this here? This feels like something th
tonychun
2015/07/16 23:12:08
Done.
|
| + std::vector<std::string> parts; |
| + base::SplitString(connection_info.auth_methods_str, ',', &parts); |
| std::vector<protocol::AuthenticationMethod> auth_methods; |
| - auth_methods.push_back(protocol::AuthenticationMethod::ThirdParty()); |
| + for (std::string part : parts) { |
| + protocol::AuthenticationMethod auth_method = |
| + protocol::AuthenticationMethod::FromString(part); |
| + if (auth_method.is_valid()) { |
| + auth_methods.push_back(auth_method); |
| + } |
| + } |
| - // 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_info.pin.empty()) { |
| + fetch_secret_callback = base::Bind(&FetchSecret, connection_info.pin, true); |
| + } |
| scoped_ptr<protocol::Authenticator> authenticator( |
| new protocol::NegotiatingClientAuthenticator( |
| - std::string(), // client_pairing_id |
| - std::string(), // shared_secret |
| - std::string(), // authentication_tag |
| + std::string(), // client_pairing_id |
| + std::string(), // shared_secret |
|
joedow
2015/07/16 03:23:19
you can pass the connection_info members for pairi
tonychun
2015/07/16 23:12:08
I've added a new member in ConnectionSetupInfo (ne
|
| + connection_info.host_id, // 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); |
| + transport_factory.Pass(), connection_info.host_jid, |
| + connection_info.capabilities); |
| } |
| void TestChromotingClient::EndConnection() { |