#include "components/policy/core/common/cloud/mock_device_management_service.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "components/policy/core/common/cloud/dm_auth.h"
#include "net/base/net_errors.h"
namespace policy {
namespace {
const char kServerUrl[] = …;
const char kUserAgent[] = …;
const char kPlatform[] = …;
std::string Serialize(
const enterprise_management::DeviceManagementResponse& response) { … }
}
MockDeviceManagementServiceConfiguration::
MockDeviceManagementServiceConfiguration()
: … { … }
MockDeviceManagementServiceConfiguration::
MockDeviceManagementServiceConfiguration(const std::string& server_url)
: … { … }
MockDeviceManagementServiceConfiguration::
~MockDeviceManagementServiceConfiguration() = default;
std::string MockDeviceManagementServiceConfiguration::GetDMServerUrl() const { … }
std::string MockDeviceManagementServiceConfiguration::GetAgentParameter()
const { … }
std::string MockDeviceManagementServiceConfiguration::GetPlatformParameter()
const { … }
std::string
MockDeviceManagementServiceConfiguration::GetRealtimeReportingServerUrl()
const { … }
std::string
MockDeviceManagementServiceConfiguration::GetEncryptedReportingServerUrl()
const { … }
std::string
MockDeviceManagementServiceConfiguration::GetReportingConnectorServerUrl(
content::BrowserContext* context) const { … }
MockJobCreationHandler::MockJobCreationHandler() = default;
MockJobCreationHandler::~MockJobCreationHandler() = default;
FakeDeviceManagementService::FakeDeviceManagementService(
MockJobCreationHandler* creation_handler)
: … { … }
FakeDeviceManagementService::FakeDeviceManagementService(
std::unique_ptr<Configuration> config,
MockJobCreationHandler* creation_handler)
: … { … }
FakeDeviceManagementService::~FakeDeviceManagementService() = default;
std::unique_ptr<DeviceManagementService::Job>
FakeDeviceManagementService::CreateJob(
std::unique_ptr<JobConfiguration> config) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::CaptureAuthData(DMAuth* auth_data) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::CaptureJobType(
DeviceManagementService::JobConfiguration::JobType* job_type) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::CapturePayload(std::string* payload) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::CaptureQueryParams(
std::map<std::string, std::string>* query_params) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::CaptureRequest(
enterprise_management::DeviceManagementRequest* request) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::CaptureTimeout(base::TimeDelta* timeout) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::SendJobResponseAsync(int net_error,
int response_code,
const std::string& response,
const std::string& mime_type,
bool was_fetched_via_proxy) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::SendJobResponseAsync(
int net_error,
int response_code,
const enterprise_management::DeviceManagementResponse& response,
const std::string& mime_type,
bool was_fetched_via_proxy) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::SendJobOKAsync(const std::string& response) { … }
FakeDeviceManagementService::JobAction
FakeDeviceManagementService::SendJobOKAsync(
const enterprise_management::DeviceManagementResponse& response) { … }
void FakeDeviceManagementService::SendJobResponseNow(
DeviceManagementService::JobForTesting* job,
int net_error,
int response_code,
const std::string& response,
const std::string& mime_type,
bool was_fetched_via_proxy) { … }
void FakeDeviceManagementService::SendJobResponseNow(
DeviceManagementService::JobForTesting* job,
int net_error,
int response_code,
const enterprise_management::DeviceManagementResponse& response,
const std::string& mime_type,
bool was_fetched_via_proxy) { … }
void FakeDeviceManagementService::SendJobOKNow(
DeviceManagementService::JobForTesting* job,
const std::string& response) { … }
void FakeDeviceManagementService::SendJobOKNow(
DeviceManagementService::JobForTesting* job,
const enterprise_management::DeviceManagementResponse& response) { … }
FakeJobConfiguration::FakeJobConfiguration(
DMServerJobConfiguration::CreateParams params,
FakeCallback callback,
RetryCallback retry_callback,
RetryCallback should_retry_callback)
: … { … }
FakeJobConfiguration::~FakeJobConfiguration() = default;
void FakeJobConfiguration::SetRequestPayload(
const std::string& request_payload) { … }
void FakeJobConfiguration::SetShouldRetryResponse(
DeviceManagementService::Job::RetryMethod method) { … }
void FakeJobConfiguration::SetTimeoutDuration(base::TimeDelta timeout) { … }
DeviceManagementService::Job::RetryMethod FakeJobConfiguration::ShouldRetry(
int response_code,
const std::string& response_body) { … }
void FakeJobConfiguration::OnBeforeRetry(int response_code,
const std::string& response_body) { … }
void FakeJobConfiguration::OnURLLoadComplete(DeviceManagementService::Job* job,
int net_error,
int response_code,
const std::string& response_body) { … }
}