| Index: remoting/host/setup/me2me_native_messaging_host_unittest.cc
|
| diff --git a/remoting/host/setup/me2me_native_messaging_host_unittest.cc b/remoting/host/setup/me2me_native_messaging_host_unittest.cc
|
| index c9a0ae02ddd2957081f5fcc3355136b21a6f6e74..a260703be51ce419987280f93375bec3ce9409c1 100644
|
| --- a/remoting/host/setup/me2me_native_messaging_host_unittest.cc
|
| +++ b/remoting/host/setup/me2me_native_messaging_host_unittest.cc
|
| @@ -19,6 +19,7 @@
|
| #include "remoting/base/auto_thread_task_runner.h"
|
| #include "remoting/host/native_messaging/pipe_messaging_channel.h"
|
| #include "remoting/host/pin_hash.h"
|
| +#include "remoting/host/setup/mock_oauth_client.h"
|
| #include "remoting/host/setup/test_util.h"
|
| #include "remoting/protocol/pairing_registry.h"
|
| #include "remoting/protocol/protocol_mock_objects.h"
|
| @@ -134,6 +135,18 @@ void VerifyStartDaemonResponse(scoped_ptr<base::DictionaryValue> response) {
|
| EXPECT_EQ("OK", value);
|
| }
|
|
|
| +void VerifyGetCredentialsFromAuthCodeResponse(
|
| + scoped_ptr<base::DictionaryValue> response) {
|
| + ASSERT_TRUE(response);
|
| + std::string value;
|
| + EXPECT_TRUE(response->GetString("type", &value));
|
| + EXPECT_EQ("getCredentialsFromAuthCodeResponse", value);
|
| + EXPECT_TRUE(response->GetString("userEmail", &value));
|
| + EXPECT_EQ("fake_user_email", value);
|
| + EXPECT_TRUE(response->GetString("refreshToken", &value));
|
| + EXPECT_EQ("fake_refresh_token", value);
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace remoting {
|
| @@ -313,8 +326,12 @@ void Me2MeNativeMessagingHostTest::StartHost() {
|
| new PipeMessagingChannel(input_read_file.Pass(),
|
| output_write_file.Pass()));
|
|
|
| + scoped_ptr<OAuthClient> oauth_client(new MockOAuthClient(
|
| + "fake_user_email", "fake_refresh_token"));
|
| +
|
| host_.reset(new Me2MeNativeMessagingHost(
|
| - false, 0, channel.Pass(), daemon_controller, pairing_registry, nullptr));
|
| + false, 0, channel.Pass(), daemon_controller, pairing_registry,
|
| + oauth_client.Pass()));
|
| host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost,
|
| base::Unretained(this)));
|
|
|
| @@ -474,6 +491,11 @@ TEST_F(Me2MeNativeMessagingHostTest, All) {
|
| message.SetString("type", "startDaemon");
|
| WriteMessageToInputPipe(message);
|
|
|
| + message.SetInteger("id", next_id++);
|
| + message.SetString("type", "getCredentialsFromAuthCode");
|
| + message.SetString("authorizationCode", "fake_auth_code");
|
| + WriteMessageToInputPipe(message);
|
| +
|
| void (*verify_routines[])(scoped_ptr<base::DictionaryValue>) = {
|
| &VerifyHelloResponse,
|
| &VerifyGetHostNameResponse,
|
| @@ -485,6 +507,7 @@ TEST_F(Me2MeNativeMessagingHostTest, All) {
|
| &VerifyGetDaemonStateResponse,
|
| &VerifyUpdateDaemonConfigResponse,
|
| &VerifyStartDaemonResponse,
|
| + &VerifyGetCredentialsFromAuthCodeResponse,
|
| };
|
| ASSERT_EQ(arraysize(verify_routines), static_cast<size_t>(next_id));
|
|
|
| @@ -585,4 +608,11 @@ TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) {
|
| TestBadRequest(message);
|
| }
|
|
|
| +// Verify rejection if getCredentialsFromAuthCode has no auth code.
|
| +TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) {
|
| + base::DictionaryValue message;
|
| + message.SetString("type", "getCredentialsFromAuthCode");
|
| + TestBadRequest(message);
|
| +}
|
| +
|
| } // namespace remoting
|
|
|