chromium/remoting/host/it2me/it2me_native_messaging_host_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "remoting/host/it2me/it2me_native_messaging_host.h"

#include <cstdint>
#include <memory>
#include <string>
#include <utility>

#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/test/values_test_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/policy/core/common/fake_async_policy_loader.h"
#include "components/policy/policy_constants.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/it2me/it2me_constants.h"
#include "remoting/host/it2me/it2me_helpers.h"
#include "remoting/host/native_messaging/log_message_handler.h"
#include "remoting/host/native_messaging/native_messaging_pipe.h"
#include "remoting/host/native_messaging/pipe_messaging_channel.h"
#include "remoting/host/policy_watcher.h"
#include "remoting/host/setup/test_util.h"
#include "remoting/protocol/errors.h"
#include "remoting/protocol/ice_config.h"
#include "remoting/signaling/log_to_server.h"
#include "services/network/test/test_shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace remoting {

ErrorCode;

namespace {

const char kTestAccessCode[] =;
constexpr base::TimeDelta kTestAccessCodeLifetime =;
const char kTestClientUsername[] =;
const char kTestStunServer[] =;

void VerifyId(const base::Value::Dict& response, int expected_value) {}

void VerifyStringProperty(const base::Value::Dict& response,
                          const std::string& name,
                          const std::string& expected_value) {}

// Verity the values of the "type" and "id" properties
void VerifyCommonProperties(const base::Value::Dict& response,
                            const std::string& type,
                            int id) {}

base::Value::Dict CreateConnectMessage(int id) {}

base::Value::Dict CreateDisconnectMessage(int id) {}

}  // namespace

class MockIt2MeHost : public It2MeHost {};

void MockIt2MeHost::Connect(
    std::unique_ptr<ChromotingHostContext> context,
    base::Value::Dict policies,
    std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory,
    base::WeakPtr<It2MeHost::Observer> observer,
    CreateDeferredConnectContext create_connection_context,
    const std::string& username,
    const protocol::IceConfig& ice_config) {}

void MockIt2MeHost::Disconnect() {}

void MockIt2MeHost::CreateConnectionContextOnNetworkThread(
    CreateDeferredConnectContext create_connection_context) {}

void MockIt2MeHost::RunSetState(It2MeHostState state) {}

class MockIt2MeHostFactory : public It2MeHostFactory {};

class It2MeNativeMessagingHostTest : public testing::Test {};

void It2MeNativeMessagingHostTest::SetUp() {}

void It2MeNativeMessagingHostTest::TearDown() {}

void It2MeNativeMessagingHostTest::SetPolicies(base::Value::Dict dict) {}

std::optional<base::Value::Dict>
It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {}

void It2MeNativeMessagingHostTest::WriteMessageToInputPipe(
    const base::Value::Dict& message) {}

void It2MeNativeMessagingHostTest::VerifyHelloResponse(int request_id) {}

void It2MeNativeMessagingHostTest::VerifyErrorResponse() {}

void It2MeNativeMessagingHostTest::VerifyConnectResponses(int request_id) {}

void It2MeNativeMessagingHostTest::VerifyDisconnectResponses(int request_id) {}

void It2MeNativeMessagingHostTest::VerifyPolicyErrorResponse() {}

void It2MeNativeMessagingHostTest::TestBadRequest(
    const base::Value::Dict& message,
    bool expect_error_response) {}

void It2MeNativeMessagingHostTest::StartHost() {}

void It2MeNativeMessagingHostTest::ExitTest() {}

void It2MeNativeMessagingHostTest::ExitPolicyRunLoop() {}

void It2MeNativeMessagingHostTest::TestConnect() {}

// Test hello request.
TEST_F(It2MeNativeMessagingHostTest, Hello) {}

// Verify that response ID matches request ID.
TEST_F(It2MeNativeMessagingHostTest, Id) {}

TEST_F(It2MeNativeMessagingHostTest, ConnectMultiple) {}

TEST_F(It2MeNativeMessagingHostTest,
       ConnectRespectsSuppressUserDialogsParameterOnChromeOsOnly) {}

TEST_F(It2MeNativeMessagingHostTest,
       ConnectRespectsSuppressNotificationsParameterOnChromeOsOnly) {}

TEST_F(It2MeNativeMessagingHostTest,
       ConnectRespectsTerminateUponInputParameterOnChromeOsOnly) {}

TEST_F(It2MeNativeMessagingHostTest,
       ConnectRespectsIsEnterpriseAdminUserParameterOnChromeOsOnly) {}

TEST_F(It2MeNativeMessagingHostTest,
       ConnectRespectsCurtainLocalUserSessionParameterOnChromeOsOnly) {}

// Verify requests with no type are rejected.
TEST_F(It2MeNativeMessagingHostTest, MissingType) {}

// Verify rejection if type is unrecognized.
TEST_F(It2MeNativeMessagingHostTest, InvalidType) {}

// Verify rejection if type is unrecognized.
TEST_F(It2MeNativeMessagingHostTest, BadPoliciesBeforeConnect) {}

// Verify rejection if type is unrecognized.
TEST_F(It2MeNativeMessagingHostTest, BadPoliciesAfterConnect) {}

}  // namespace remoting