#include "components/enterprise/client_certificates/core/key_upload_client.h"
#include <string_view>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.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/cloud_management_delegate.h"
#include "components/enterprise/client_certificates/core/dm_server_client.h"
#include "components/enterprise/client_certificates/core/mock_cloud_management_delegate.h"
#include "components/enterprise/client_certificates/core/mock_private_key.h"
#include "components/enterprise/client_certificates/core/private_key.h"
#include "components/enterprise/client_certificates/core/upload_client_error.h"
#include "crypto/signature_verifier.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 {
BPKUR;
RunOnceCallback;
_;
Return;
StrictMock;
namespace {
constexpr int kSuccessCode = …;
constexpr int kDeviceIdConflictCode = …;
constexpr std::string_view kFakeSignature = …;
constexpr std::string_view kFakeSpki = …;
constexpr std::string kFakeDMToken = …;
std::vector<uint8_t> ToBytes(std::string_view str) { … }
scoped_refptr<MockPrivateKey> CreateMockedKey() { … }
enterprise_management::DeviceManagementRequest CreateExpectedRequest(
bool provision_certificate) { … }
scoped_refptr<net::X509Certificate> LoadTestCert() { … }
MATCHER_P(EqualsProto, expected, "") { … }
}
class KeyUploadClientTest : public testing::Test { … };
TEST_F(KeyUploadClientTest, CreateCertificate_Success) { … }
TEST_F(KeyUploadClientTest, CreateCertificate_NoDMToken_Fail) { … }
TEST_F(KeyUploadClientTest, CreateCertificate_NullKey_Fail) { … }
TEST_F(KeyUploadClientTest, CreateCertificate_DMServerFailed) { … }
TEST_F(KeyUploadClientTest, CreateCertificate_NetFailed) { … }
TEST_F(KeyUploadClientTest, CreateCertificate_MalformedResponse) { … }
TEST_F(KeyUploadClientTest, KeySync_Success) { … }
TEST_F(KeyUploadClientTest, KeySync_NoDMToken) { … }
TEST_F(KeyUploadClientTest, KeySync_FailSignature_Fail) { … }
TEST_F(KeyUploadClientTest, KeySync_DMServerFailed) { … }
}