chromium/remoting/host/setup/host_starter_base_unittest.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/setup/host_starter_base.h"

#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/http/http_status_code.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/host_config.h"
#include "remoting/host/setup/daemon_controller.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace remoting {

namespace {

// Response for spoofing Gaia calls.
constexpr char kAccessToken[] =;
constexpr char kRefreshToken[] =;
constexpr char kGetTokensResponse[] =;
constexpr char kGetUserEmailResponseForUser[] =;
constexpr char kGetUserEmailResponseForServiceAccount[] =;

// Known values for testing config file generation.
constexpr char kTestUserEmail[] =;
constexpr char kTestRobotEmail[] =;
constexpr char kTestRobotAuthCode[] =;
constexpr char kTestDirectoryId[] =;
constexpr char kTestMachineName[] =;

class TestDaemonControllerDelegate : public DaemonController::Delegate {};

TestDaemonControllerDelegate::TestDaemonControllerDelegate() = default;

TestDaemonControllerDelegate::~TestDaemonControllerDelegate() = default;

DaemonController::State TestDaemonControllerDelegate::GetState() {}

std::optional<base::Value::Dict> TestDaemonControllerDelegate::GetConfig() {}

void TestDaemonControllerDelegate::CheckPermission(
    bool it2me,
    DaemonController::BoolCallback callback) {}

void TestDaemonControllerDelegate::SetConfigAndStart(
    base::Value::Dict config,
    bool consent,
    DaemonController::CompletionCallback done) {}

void TestDaemonControllerDelegate::UpdateConfig(
    base::Value::Dict config,
    DaemonController::CompletionCallback done) {}

void TestDaemonControllerDelegate::Stop(
    DaemonController::CompletionCallback done) {}

DaemonController::UsageStatsConsent
TestDaemonControllerDelegate::GetUsageStatsConsent() {}

class TestHostStarter : public HostStarterBase {};

TestHostStarter::TestHostStarter(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    scoped_refptr<DaemonController> daemon_controller,
    base::OnceClosure configure_gaia_for_service_account)
    :{}

TestHostStarter::~TestHostStarter() = default;

void TestHostStarter::RegisterNewHost(const std::string& public_key,
                                      std::optional<std::string> access_token) {}

void TestHostStarter::RemoveOldHostFromDirectory(base::OnceClosure on_removed) {}

void TestHostStarter::ReportError(const std::string& error_message,
                                  base::OnceClosure on_done) {}

}  // namespace

class HostStarterBaseTest : public testing::Test {};

HostStarterBaseTest::HostStarterBaseTest() = default;

HostStarterBaseTest::~HostStarterBaseTest() = default;

void HostStarterBaseTest::SetUp() {}

void HostStarterBaseTest::TearDown() {}

void HostStarterBaseTest::RunUntilQuit() {}

void HostStarterBaseTest::CompletionHandler(HostStarter::Result result) {}

void HostStarterBaseTest::ConfigureGaiaResponseForUser() {}

void HostStarterBaseTest::ConfigureGaiaResponseForServiceAccount() {}

TEST_F(HostStarterBaseTest, StartHostUsingOAuth) {}

TEST_F(HostStarterBaseTest, CorpCodePath) {}

TEST_F(HostStarterBaseTest, CloudCodePath) {}

TEST_F(HostStarterBaseTest, LegacyCloudCodePath) {}

TEST_F(HostStarterBaseTest, ExistingHostIsStopped) {}

TEST_F(HostStarterBaseTest, OAuthFlowWithMismatchedOwnerEmail) {}

TEST_F(HostStarterBaseTest, CorpFlowWithMismatchedOwnerEmailValue) {}

TEST_F(HostStarterBaseTest, RegisterNewHostCallbackDoesNotProvideId) {}

TEST_F(HostStarterBaseTest, RegisterNewHostCallbackProvideMismatchedId) {}

TEST_F(HostStarterBaseTest, RegisterNewHostCallbackDoesNotProvideAuthCode) {}

TEST_F(HostStarterBaseTest, RegisterNewHostCallbackDoesNotProvideOwnerEmail) {}

TEST_F(HostStarterBaseTest,
       RegisterNewHostCallbackDoesNotProvideServiceAccount) {}

TEST_F(HostStarterBaseTest, NewHostFailsToStart) {}

}  // namespace remoting