#include "chrome/enterprise_companion/dm_client.h"
#include <memory>
#include <string>
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "chrome/enterprise_companion/device_management_storage/dm_storage.h"
#include "chrome/enterprise_companion/enterprise_companion_status.h"
#include "chrome/enterprise_companion/event_logger.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_validator.h"
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/cloud/mock_device_management_service.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace enterprise_companion {
namespace {
constexpr char kFakeDeviceId[] = …;
constexpr char kFakeEnrollmentToken[] = …;
constexpr char kFakeDMToken[] = …;
constexpr char kPolicyType1[] = …;
constexpr char kPolicyValue1[] = …;
constexpr char kPolicyType2[] = …;
constexpr char kPolicyValue2[] = …;
constexpr char kPublicKey1[] = …;
constexpr char kPolicyValue3[] = …;
constexpr int kPublicKey1Version = …;
constexpr int kTimestamp1 = …;
constexpr int kTimestamp2 = …;
ElementsAre;
class TestDMStorage final : public device_management_storage::DMStorage { … };
class MockCloudPolicyClient : public policy::MockCloudPolicyClient { … };
class TestTokenService
: public device_management_storage::TokenServiceInterface { … };
class TestEventLogger : public EventLogger { … };
}
class DMClientTest : public ::testing::Test { … };
TEST_F(DMClientTest, RegisterDeviceSuccess) { … }
TEST_F(DMClientTest, RegisterDeviceFailure) { … }
TEST_F(DMClientTest, RegistrationRemovesPolicies) { … }
TEST_F(DMClientTest, RegistrationSkippedNoEnrollmentToken) { … }
TEST_F(DMClientTest, RegistrationSkippedAlreadyManaged) { … }
TEST_F(DMClientTest, PoliciesPersistedThroughSkippedRegistration) { … }
TEST_F(DMClientTest, FetchPoliciesFailsIfNotRegistered) { … }
TEST_F(DMClientTest, FetchPoliciesFailsIfDMStorageCannotPersist) { … }
TEST_F(DMClientTest, FetchPoliciesFailsIfCloudPolicyClientFails) { … }
TEST_F(DMClientTest, FetchPoliciesFailsIfFetchResultInvalid) { … }
TEST_F(DMClientTest, FetchPoliciesFailsIfResultCannotBePersisted) { … }
TEST_F(DMClientTest, FetchPoliciesSuccess) { … }
TEST_F(DMClientTest, FetchPoliciesOverwrite) { … }
TEST_F(DMClientTest, FetchPoliciesReset) { … }
TEST_F(DMClientTest, FetchPoliciesInvalidation) { … }
}