chromium/chrome/enterprise_companion/test/integration_tests.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 <optional>
#include <string>

#include "base/base64.h"
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/containers/flat_map.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/path_service.h"
#include "base/process/process.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/enterprise_companion/app/app.h"
#include "chrome/enterprise_companion/device_management_storage/dm_storage.h"
#include "chrome/enterprise_companion/enterprise_companion.h"
#include "chrome/enterprise_companion/enterprise_companion_client.h"
#include "chrome/enterprise_companion/enterprise_companion_status.h"
#include "chrome/enterprise_companion/global_constants.h"
#include "chrome/enterprise_companion/installer_paths.h"
#include "chrome/enterprise_companion/ipc_support.h"
#include "chrome/enterprise_companion/proto/enterprise_companion_event.pb.h"
#include "chrome/enterprise_companion/test/test_server.h"
#include "chrome/enterprise_companion/test/test_utils.h"
#include "components/named_mojo_ipc_server/named_mojo_ipc_server_client_util.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/test/policy_builder.h"
#include "components/policy/core/common/policy_switches.h"
#include "components/policy/test_support/client_storage.h"
#include "components/policy/test_support/embedded_policy_test_server.h"
#include "components/policy/test_support/policy_storage.h"
#include "device_management_backend.pb.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_WIN)
#include "base/strings/utf_string_conversions.h"
#endif

namespace enterprise_companion {

namespace {

constexpr char kFakeEnrollmentToken[] =;
constexpr char kFakeMachineLevelOmahaPolicyValue[] =;
constexpr char kFakeMachineLevelUserPolicyValue[] =;
constexpr char kFakeMachineLevelExtensionPolicyValue[] =;

#if BUILDFLAG(IS_POSIX)
constexpr char kTestExe[] =;
#elif BUILDFLAG(IS_WIN)
constexpr char kTestExe[] = "enterprise_companion_test.exe";
#endif

}  // namespace

class IntegrationTests : public ::testing::Test {};

// Running the application installer should configure a valid installation.
TEST_F(IntegrationTests, Install) {}

// Attempting to shut down the server when it's not running should fail.
TEST_F(IntegrationTests, ShutdownWithoutServerFails) {}

// The server should shut down upon request.
TEST_F(IntegrationTests, Shutdown) {}

// The server should fail to fetch policies if no enrollment token is present
// and the device is not registered.
TEST_F(IntegrationTests, FetchPoliciesWithoutRegistrationFails) {}

// The application should register the device and fetch policies upon request.
TEST_F(IntegrationTests, FetchPoliciesAndRegister) {}

// The application should fetch policies upon request without re-registering
// if the device is already managed.
TEST_F(IntegrationTests, FetchPoliciesAlreadyRegistered) {}

// The application should invalidate the stored DM token if the server
// indicates that the device is unknown.
TEST_F(IntegrationTests, UnknownDMTokenInvalidated) {}

// The application should reload the enrollment token from storage on every
// registration attempt.
TEST_F(IntegrationTests, ReloadsTokens) {}

}  // namespace enterprise_companion