#include "components/policy/test_support/embedded_policy_test_server.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/test_support/remote_commands_state.h"
#include "components/policy/test_support/request_handler_for_check_user_account.h"
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#include "components/policy/proto/chrome_extension_policy.pb.h"
#endif
#include "components/policy/test_support/client_storage.h"
#include "components/policy/test_support/policy_storage.h"
#include "components/policy/test_support/request_handler_for_api_authorization.h"
#include "components/policy/test_support/request_handler_for_auto_enrollment.h"
#include "components/policy/test_support/request_handler_for_cert_upload.h"
#include "components/policy/test_support/request_handler_for_check_android_management.h"
#include "components/policy/test_support/request_handler_for_chrome_desktop_report.h"
#include "components/policy/test_support/request_handler_for_client_cert_provisioning.h"
#include "components/policy/test_support/request_handler_for_device_attribute_update.h"
#include "components/policy/test_support/request_handler_for_device_attribute_update_permission.h"
#include "components/policy/test_support/request_handler_for_device_initial_enrollment_state.h"
#include "components/policy/test_support/request_handler_for_device_state_retrieval.h"
#include "components/policy/test_support/request_handler_for_policy.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "components/policy/test_support/request_handler_for_psm_auto_enrollment.h"
#endif
#include "components/policy/test_support/remote_commands_state.h"
#include "components/policy/test_support/request_handler_for_register_browser.h"
#include "components/policy/test_support/request_handler_for_register_cert_based.h"
#include "components/policy/test_support/request_handler_for_register_device_and_user.h"
#include "components/policy/test_support/request_handler_for_remote_commands.h"
#include "components/policy/test_support/request_handler_for_status_upload.h"
#include "components/policy/test_support/request_handler_for_unregister.h"
#include "components/policy/test_support/request_handler_for_upload_euicc_info.h"
#include "components/policy/test_support/test_server_helpers.h"
#include "crypto/sha2.h"
#include "net/base/url_util.h"
#include "net/http/http_status_code.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
EmbeddedTestServer;
HttpRequest;
HttpResponse;
namespace policy {
namespace {
const char kExternalPolicyDataPath[] = …;
const char kExternalPolicyTypeParam[] = …;
const char kExternalEntityIdParam[] = …;
std::unique_ptr<HttpResponse> LogStatusAndReturn(
GURL url,
std::unique_ptr<HttpResponse> response) { … }
}
const char kFakeDeviceToken[] = …;
const char kInvalidEnrollmentToken[] = …;
EmbeddedPolicyTestServer::RequestHandler::RequestHandler(
EmbeddedPolicyTestServer* parent)
: … { … }
EmbeddedPolicyTestServer::RequestHandler::~RequestHandler() = default;
struct EmbeddedPolicyTestServer::ServerState { … };
ClientStorage* EmbeddedPolicyTestServer::client_storage() { … }
PolicyStorage* EmbeddedPolicyTestServer::policy_storage() { … }
RemoteCommandsState* EmbeddedPolicyTestServer::remote_commands_state() { … }
EmbeddedPolicyTestServer::EmbeddedPolicyTestServer()
: … { … }
EmbeddedPolicyTestServer::~EmbeddedPolicyTestServer() = default;
bool EmbeddedPolicyTestServer::Start() { … }
GURL EmbeddedPolicyTestServer::GetServiceURL() const { … }
void EmbeddedPolicyTestServer::RegisterHandler(
std::unique_ptr<EmbeddedPolicyTestServer::RequestHandler> request_handler) { … }
void EmbeddedPolicyTestServer::ConfigureRequestError(
const std::string& request_type,
net::HttpStatusCode error_code) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void EmbeddedPolicyTestServer::UpdateExternalPolicy(
const std::string& type,
const std::string& entity_id,
const std::string& raw_policy) { … }
#endif
std::unique_ptr<HttpResponse> EmbeddedPolicyTestServer::HandleRequest(
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse>
EmbeddedPolicyTestServer::HandleExternalPolicyDataRequest(const GURL& url) { … }
void EmbeddedPolicyTestServer::ResetServerState() { … }
}