#include "components/enterprise/client_certificates/core/certificate_store.h"
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/pickle.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/types/expected.h"
#include "components/enterprise/client_certificates/core/client_identity.h"
#include "components/enterprise/client_certificates/core/mock_private_key.h"
#include "components/enterprise/client_certificates/core/mock_private_key_factory.h"
#include "components/enterprise/client_certificates/core/private_key.h"
#include "components/enterprise/client_certificates/core/private_key_factory.h"
#include "components/enterprise/client_certificates/core/store_error.h"
#include "components/enterprise/client_certificates/proto/client_certificates_database.pb.h"
#include "components/leveldb_proto/public/proto_database.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/leveldb_proto/public/shared_proto_database_client_list.h"
#include "components/leveldb_proto/testing/fake_db.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"
namespace client_certificates {
namespace {
constexpr char kTestIdentityName[] = …;
constexpr char kOtherTestIdentityName[] = …;
constexpr char kFakeWrappedValue[] = …;
client_certificates_pb::PrivateKey CreateFakeProtoKey() { … }
scoped_refptr<net::X509Certificate> LoadTestCert() { … }
void PersistCertificate(client_certificates_pb::ClientIdentity& identity,
scoped_refptr<net::X509Certificate> certificate) { … }
MATCHER_P(EqualsProto, expected, "") { … }
}
RunOnceCallback;
InitStatus;
ErrorIs;
ValueIs;
_;
Return;
StrictMock;
class CertificateStoreTest : public testing::Test { … };
TEST_F(CertificateStoreTest, CreatePrivateKey_Success) { … }
TEST_F(CertificateStoreTest, CreatePrivateKey_InvalidIdentityNameFail) { … }
TEST_F(CertificateStoreTest, CreatePrivateKey_DatabaseInitFail) { … }
TEST_F(CertificateStoreTest, CreatePrivateKey_GetIdentityFail) { … }
TEST_F(CertificateStoreTest, CreatePrivateKey_CreateKeyFail) { … }
TEST_F(CertificateStoreTest, CreatePrivateKey_ConflictFail) { … }
TEST_F(CertificateStoreTest, CreatePrivateKey_UpdateFail) { … }
TEST_F(CertificateStoreTest, CommitCertificate_SuccessWithPrivateKey) { … }
TEST_F(CertificateStoreTest, CommitCertificate_SuccessWithoutPrivateKey) { … }
TEST_F(CertificateStoreTest, CommitCertificate_InvalidIdentityNameFail) { … }
TEST_F(CertificateStoreTest, CommitCertificate_DatabaseInitFail) { … }
TEST_F(CertificateStoreTest, CommitCertificate_GetIdentityFail) { … }
TEST_F(CertificateStoreTest, CommitCertificate_InvalidCertificateFail) { … }
TEST_F(CertificateStoreTest, CommitCertificate_UpdateFail) { … }
TEST_F(CertificateStoreTest, CommitIdentity_SuccessWithPrivateKey) { … }
TEST_F(CertificateStoreTest, CommitIdentity_FailWithoutIdentity) { … }
TEST_F(CertificateStoreTest, CommitIdentity_InvalidTemporaryIdentityNameFail) { … }
TEST_F(CertificateStoreTest, CommitIdentity_DatabaseInitFail) { … }
TEST_F(CertificateStoreTest, CommitIdentity_GetIdentityFail) { … }
TEST_F(CertificateStoreTest, CommitIdentity_InvalidCertificateFail) { … }
TEST_F(CertificateStoreTest, CommitIdentity_InvalidFinalNameFail) { … }
TEST_F(CertificateStoreTest, CommitIdentity_UpdateFail) { … }
TEST_F(CertificateStoreTest, GetIdentity_FullIdentitySuccess) { … }
TEST_F(CertificateStoreTest, GetIdentity_OnlyPrivateKeySuccess) { … }
TEST_F(CertificateStoreTest, GetIdentity_OnlyCertificateSuccess) { … }
TEST_F(CertificateStoreTest, GetIdentity_EmptySuccess) { … }
TEST_F(CertificateStoreTest, GetIdentity_NotFoundSuccess) { … }
TEST_F(CertificateStoreTest, GetIdentity_InvalidIdentityNameFail) { … }
TEST_F(CertificateStoreTest, GetIdentity_DatabaseInitFail) { … }
TEST_F(CertificateStoreTest, GetIdentity_GetIdentityFail) { … }
TEST_F(CertificateStoreTest, GetIdentity_LoadPrivateKeyFail) { … }
}