chromium/chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/chrome_management_service_unittest.cc

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

#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/chrome_management_service.h"

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

#include "base/command_line.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/multiprocess_test.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/shared_command_constants.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/metrics_utils.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/mojo_helper/mock_mojo_helper.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/mojo_helper/mojo_helper.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/invitation.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"

_;
Test;

namespace enterprise_connectors {

namespace {

constexpr char kChromeManagementServiceStatusHistogramName[] =;
constexpr char kFakeDMToken[] =;
constexpr char kFakeDmServerUrl[] =;
constexpr char kFakeNonce[] =;
constexpr char kStringPipeName[] =;
constexpr uint64_t kUintPipeName =;
constexpr uint16_t kCustomErrorCode =;

}  // namespace

MockMojoHelper;

class ChromeManagementServiceTest : public testing::Test {};

// Tests when the chrome management service successfully called to
// rotate the key.
MULTIPROCESS_TEST_MAIN(Successful) {}

TEST_F(ChromeManagementServiceTest, Success_Nonce) {}

TEST_F(ChromeManagementServiceTest, Success_NoNonce) {}

// Tests when the chrome management service failed due to a missing
// rotate dtkey switch.
MULTIPROCESS_TEST_MAIN(CommandFailure) {}

TEST_F(ChromeManagementServiceTest, Failure_IncorrectCommand) {}

// Tests when the chrome management service failed due to incorrect process
// permissions.
MULTIPROCESS_TEST_MAIN(PermissionsFailure) {}

TEST_F(ChromeManagementServiceTest, Failure_IncorrectPermissions) {}

// Tests when the chrome management service failed due to an invalid platform
// channel endpoint.
MULTIPROCESS_TEST_MAIN(PlatformChannelEndpointFailure) {}

TEST_F(ChromeManagementServiceTest,
       MojoFailure_InvalidPlatformChannelEndpoint) {}

// Tests when the chrome management service failed due to a failure accepting
// the mojo invitation.
MULTIPROCESS_TEST_MAIN(AcceptMojoInvitationFailure) {}

TEST_F(ChromeManagementServiceTest, MojoFailure_AcceptInvitationFailure) {}

// Tests when the chrome management service failed due to an invalid scoped
// message pipe handle.
MULTIPROCESS_TEST_MAIN(InvalidPipeHandle) {}

TEST_F(ChromeManagementServiceTest, MojoFailure_InvalidPipeHandle) {}

// Tests when the chrome management service failed due to an invalid pending
// remote url loader factory.
MULTIPROCESS_TEST_MAIN(InvalidPendingRemoteUrlLoaderFactory) {}

TEST_F(ChromeManagementServiceTest,
       MojoFailure_InvalidPendingRemoteLoaderFactory) {}

// Tests when the chrome management service failed due to an unbound remote url
// loader factory.
MULTIPROCESS_TEST_MAIN(UnboundRemoteUrlLoaderFactory) {}

TEST_F(ChromeManagementServiceTest, MojoFailure_UnboundRemoteLoaderFactory) {}

// Tests when the chrome management service failed due to a disconnected remote
// url loader factory.
MULTIPROCESS_TEST_MAIN(DisconnectedRemoteUrlLoaderFactory) {}

TEST_F(ChromeManagementServiceTest,
       MojoFailure_DisconnectedRemoteLoaderFactory) {}

// Tests when the chrome management service failed due to a failed
// key rotation.
MULTIPROCESS_TEST_MAIN(RotateDTKeyFailure) {}

TEST_F(ChromeManagementServiceTest, Failure_RotateDTKeyFailure) {}

}  // namespace enterprise_connectors