#include "components/enterprise/client_certificates/core/certificate_provisioning_service.h"
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/gmock_move_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "components/enterprise/client_certificates/core/certificate_store.h"
#include "components/enterprise/client_certificates/core/client_identity.h"
#include "components/enterprise/client_certificates/core/constants.h"
#include "components/enterprise/client_certificates/core/context_delegate.h"
#include "components/enterprise/client_certificates/core/key_upload_client.h"
#include "components/enterprise/client_certificates/core/metrics_util.h"
#include "components/enterprise/client_certificates/core/mock_certificate_store.h"
#include "components/enterprise/client_certificates/core/mock_key_upload_client.h"
#include "components/enterprise/client_certificates/core/mock_private_key.h"
#include "components/enterprise/client_certificates/core/prefs.h"
#include "components/enterprise/client_certificates/core/private_key.h"
#include "components/enterprise/client_certificates/core/store_error.h"
#include "components/prefs/testing_pref_service.h"
#include "net/cert/x509_certificate.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
RunOnceCallback;
_;
StrictMock;
namespace client_certificates {
namespace {
constexpr int kSuccessUploadCode = …;
scoped_refptr<net::X509Certificate> LoadTestCert() { … }
scoped_refptr<net::X509Certificate> LoadOtherTestCert() { … }
class MockContextDelegate : public ContextDelegate { … };
}
class CertificateProvisioningServiceTest : public testing::Test { … };
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_ProvisionsIdentity) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithoutPref_Empty_ProvisionsIdentity) { … }
TEST_F(CertificateProvisioningServiceTest,
Created_PolicyDisabled_NothingHappens) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_ExistingIdentityLoaded) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_ExistingIdentity_NoCertificate) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_GetIdentityFails) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_CreateKeyFails) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_CreateCertificateFails) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_CreateCertificateSucceeds_NoCert) { … }
TEST_F(CertificateProvisioningServiceTest, ConflictTemporaryKey_Resolves) { … }
TEST_F(CertificateProvisioningServiceTest, ConflictTemporaryKey_FailsLoad) { … }
TEST_F(CertificateProvisioningServiceTest, ConflictTemporaryKey_LoadEmpty) { … }
TEST_F(CertificateProvisioningServiceTest,
ConflictTemporaryKey_LoadNoPrivateKey) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_CommitIdentityFails) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_ExistingIdentity_CommitCertificateFails) { … }
TEST_F(CertificateProvisioningServiceTest,
CreatedWithPref_Empty_ProvisionsIdentity_RenewsExpiredCert) { … }
TEST_F(
CertificateProvisioningServiceTest,
CreatedWithPref_Empty_ProvisionsIdentity_RenewsExpiredCert_FailsDownload) { … }
TEST_F(CertificateProvisioningServiceTest, ConcurrentGetManagedIdentityCalls) { … }
}