#include "chrome/browser/policy/messaging_layer/upload/record_upload_request_builder.h"
#include <cstdint>
#include <string>
#include <string_view>
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/token.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/policy/messaging_layer/upload/encrypted_reporting_client.h"
#include "chrome/browser/policy/messaging_layer/upload/record_handler_impl.h"
#include "chrome/browser/policy/messaging_layer/util/test_request_payload.h"
#include "components/policy/core/common/management/management_service.h"
#include "components/policy/core/common/management/scoped_management_service_override_for_testing.h"
#include "components/reporting/resources/resource_manager.h"
#include "components/reporting/util/encrypted_reporting_json_keys.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
AllOf;
Eq;
Lt;
namespace reporting {
namespace {
constexpr int64_t kGenerationId = …;
constexpr Priority kPriority = …;
constexpr char kEncryptionKey[] = …;
constexpr int64_t kPublicKeyId = …;
constexpr CompressionInformation::CompressionAlgorithm kCompressionAlgorithm = …;
class RecordUploadRequestBuilderTest
: public ::testing::TestWithParam<
::testing::tuple<bool ,
bool >> { … };
#if !BUILDFLAG(IS_CHROMEOS)
TEST_F(RecordUploadRequestBuilderTest,
GenerationGuidNotRequiredForManagedBrowsersOnNonChromeOSDevices) { … }
#endif
#if BUILDFLAG(IS_CHROMEOS)
TEST_F(RecordUploadRequestBuilderTest,
GenerationGuidRequiredForUnmanagedChromeOSDevices) {
policy::ScopedManagementServiceOverrideForTesting scoped_management_service =
policy::ScopedManagementServiceOverrideForTesting(
policy::ManagementServiceFactory::GetForPlatform(),
policy::EnterpriseManagementAuthority::NONE);
ASSERT_THAT(
policy::ManagementServiceFactory::GetForPlatform()->IsBrowserManaged(),
Eq(false));
EXPECT_THAT(EncryptedReportingClient::GenerationGuidIsRequired(), Eq(true));
SequenceInformation sequence_info;
sequence_info.set_generation_id(12345678);
sequence_info.set_priority(IMMEDIATE);
sequence_info.set_sequencing_id(0);
EXPECT_THAT(SequenceInformationDictionaryBuilder(
sequence_info, true)
.Build(),
Eq(std::nullopt));
}
#endif
TEST_P(RecordUploadRequestBuilderTest, AcceptEncryptedRecordsList) { … }
TEST_P(RecordUploadRequestBuilderTest, BreakListOnSingleBadRecord) { … }
TEST_P(RecordUploadRequestBuilderTest, DenyPoorlyFormedEncryptedRecords) { … }
TEST_P(RecordUploadRequestBuilderTest, AcceptRequestId) { … }
TEST_P(RecordUploadRequestBuilderTest, DenyRequestIdWhenBadRecordSet) { … }
TEST_P(RecordUploadRequestBuilderTest,
DontBuildCompressionRequestIfNoInformation) { … }
TEST_P(RecordUploadRequestBuilderTest, IncludeCompressionRequest) { … }
TEST_P(RecordUploadRequestBuilderTest, ConfigFileRequestExperimentEnabled) { … }
TEST_P(RecordUploadRequestBuilderTest, ConfigFileRequestExperimentDisabled) { … }
TEST_P(RecordUploadRequestBuilderTest, ClientAutomatedTestExperimentEnabled) { … }
TEST_P(RecordUploadRequestBuilderTest, ClientAutomatedTestExperimentDisabled) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}