chromium/chrome/browser/policy/messaging_layer/upload/encrypted_reporting_client_unittest.cc

// Copyright 2023 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/policy/messaging_layer/upload/encrypted_reporting_client.h"

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/policy/device_management_service_configuration.h"
#include "chrome/browser/policy/messaging_layer/upload/encrypted_reporting_client.h"
#include "chrome/browser/policy/messaging_layer/upload/record_upload_request_builder.h"
#include "chrome/browser/policy/messaging_layer/util/test_request_payload.h"
#include "chrome/browser/policy/messaging_layer/util/test_response_payload.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chromeos/ash/components/system/statistics_provider.h"
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/management/scoped_management_service_override_for_testing.h"
#include "components/reporting/proto/synced/record_constants.pb.h"
#include "components/reporting/resources/resource_manager.h"
#include "components/reporting/util/encrypted_reporting_json_keys.h"
#include "components/reporting/util/status_macros.h"
#include "components/reporting/util/statusor.h"
#include "components/reporting/util/test_support_callbacks.h"
#include "content/public/test/browser_task_environment.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_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"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/system/fake_statistics_provider.h"
#include "chromeos/ash/components/system/statistics_provider.h"
#endif

ContainerEq;
ElementsAre;
Eq;
Ge;
IsEmpty;
Lt;
Property;
SizeIs;
StartsWith;
StrEq;

namespace reporting {

namespace {

constexpr char kDmToken[] =;
constexpr char kClientId[] =;
constexpr char kServerUrl[] =;

constexpr int kGenerationId =;
constexpr int kFirstSequenceId =;
constexpr char kEncryptedRecord[] =;

size_t RecordsSize(const std::vector<EncryptedRecord>& records) {}

class FakeDelegate : public EncryptedReportingClient::Delegate {};
}  // namespace

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

TEST_F(EncryptedReportingClientTest, RegularUploads) {}

TEST_F(EncryptedReportingClientTest, TimedOutUploadWithSameRecords) {}

TEST_F(EncryptedReportingClientTest, TimedOutUploadWithAddedRecord) {}

TEST_F(EncryptedReportingClientTest, KeyRequestAlone) {}

TEST_F(EncryptedReportingClientTest, ForceConfirmAndRetract) {}

TEST_F(EncryptedReportingClientTest, ServiceUnavailable) {}

TEST_F(EncryptedReportingClientTest, ServiceRejectedByRateLimiting) {}

// Verify that when the cloud policy client isn't provided, device info is not
// added to the request headers.
TEST_F(EncryptedReportingClientTest, UploadSucceedsWithoutDeviceInfo) {}

TEST_F(EncryptedReportingClientTest, IdenticalUploadRetriesThrottled) {}

TEST_F(EncryptedReportingClientTest, UploadsSequenceThrottled) {}

TEST_F(EncryptedReportingClientTest, SecurityUploadsSequenceNotThrottled) {}

TEST_F(EncryptedReportingClientTest, FailedUploadsSequenceThrottled) {}
}  // namespace reporting