#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/component_updater/pki_metadata_component_installer.h"
#include "base/base64.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/net/key_pinning.pb.h"
#include "components/certificate_transparency/certificate_transparency_config.pb.h"
#include "components/component_updater/component_installer.h"
#include "components/component_updater/mock_component_updater_service.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/test/browser_task_environment.h"
#include "net/base/features.h"
#include "net/cert/cert_verify_proc.h"
#include "net/http/transport_security_state.h"
#include "net/net_buildflags.h"
#include "services/cert_verifier/cert_verifier_service_factory.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/network_service_buildflags.h"
#include "services/network/public/mojom/ct_log_info.mojom.h"
#include "services/network/sct_auditing/sct_auditing_cache.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/protobuf/src/google/protobuf/repeated_field.h"
namespace component_updater {
namespace {
const char kLogSPKIBase64[] = …;
const char kLogIdBase64[] = …;
constexpr uint64_t kLogMMDSeconds = …;
const char kLogURL[] = …;
const char kLogName[] = …;
const char kLogOperatorName[] = …;
const char kLogOperatorEmail[] = …;
constexpr base::TimeDelta kCurrentOperatorStart = …;
const char kPreviousOperator1Name[] = …;
constexpr base::TimeDelta kPreviousOperator1Start = …;
const char kPreviousOperator2Name[] = …;
constexpr base::TimeDelta kPreviousOperator2Start = …;
const char kGoogleLogName[] = …;
const char kGoogleLogOperatorName[] = …;
constexpr base::TimeDelta kGoogleLogDisqualificationDate = …;
const char kPopularSCT1[] = …;
const char kPopularSCT2[] = …;
const char kPinsetName[] = …;
const char kPinsetHostName[] = …;
const bool kPinsetIncludeSubdomains = …;
const std::vector<uint8_t> kSpkiHash1 = …;
const std::vector<uint8_t> kSpkiHash2 = …;
constexpr uint64_t kMaxSupportedCTCompatibilityVersion = …;
constexpr uint64_t kMaxSupportedKPCompatibilityVersion = …;
}
class PKIMetadataComponentInstallerTest : public testing::Test { … };
TEST_F(PKIMetadataComponentInstallerTest, TestProtoBytesConversion) { … }
TEST_F(PKIMetadataComponentInstallerTest, VerifyInstallation) { … }
TEST_F(PKIMetadataComponentInstallerTest, RegisterComponent) { … }
TEST_F(PKIMetadataComponentInstallerTest, CTEnforcementKillSwitch) { … }
TEST_F(PKIMetadataComponentInstallerTest,
InstallComponentUpdatesPinningConfig) { … }
TEST_F(PKIMetadataComponentInstallerTest, InstallComponentInvalidKPProto) { … }
TEST_F(PKIMetadataComponentInstallerTest,
InstallComponentIncompatibleKPVersion) { … }
#if BUILDFLAG(IS_CT_SUPPORTED)
TEST_F(PKIMetadataComponentInstallerTest, InstallComponentUpdatesCTConfig) { … }
TEST_F(PKIMetadataComponentInstallerTest, InstallComponentInvalidCTProto) { … }
TEST_F(PKIMetadataComponentInstallerTest,
InstallComponentIncompatibleCTVersion) { … }
TEST_F(PKIMetadataComponentInstallerTest, ReconfigureWhenNotInstalled) { … }
#endif
class PKIMetadataComponentInstallerDisabledTest
: public PKIMetadataComponentInstallerTest { … };
TEST_F(PKIMetadataComponentInstallerDisabledTest,
MaybeDoNotRegisterIfFeatureDisabled) { … }
}