summaryrefslogtreecommitdiffstats
path: root/chromium/components/policy/test_support/request_handler_for_policy.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/policy/test_support/request_handler_for_policy.h')
-rw-r--r--chromium/components/policy/test_support/request_handler_for_policy.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/chromium/components/policy/test_support/request_handler_for_policy.h b/chromium/components/policy/test_support/request_handler_for_policy.h
new file mode 100644
index 00000000000..e8b2594cd81
--- /dev/null
+++ b/chromium/components/policy/test_support/request_handler_for_policy.h
@@ -0,0 +1,60 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_POLICY_TEST_SUPPORT_REQUEST_HANDLER_FOR_POLICY_H_
+#define COMPONENTS_POLICY_TEST_SUPPORT_REQUEST_HANDLER_FOR_POLICY_H_
+
+#include <string>
+
+#include "components/policy/test_support/client_storage.h"
+#include "components/policy/test_support/embedded_policy_test_server.h"
+
+namespace enterprise_management {
+class DevicePolicyResponse;
+class PolicyFetchRequest;
+class PolicyFetchResponse;
+} // namespace enterprise_management
+
+namespace policy {
+
+// Handler for request type `policy`.
+class RequestHandlerForPolicy
+ : public EmbeddedPolicyTestServer::RequestHandler {
+ public:
+ RequestHandlerForPolicy(ClientStorage* client_storage,
+ PolicyStorage* policy_storage);
+ RequestHandlerForPolicy(RequestHandlerForPolicy&& handler) = delete;
+ RequestHandlerForPolicy& operator=(RequestHandlerForPolicy&& handler) =
+ delete;
+ ~RequestHandlerForPolicy() override;
+
+ // EmbeddedPolicyTestServer::RequestHandler:
+ std::string RequestType() override;
+ std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
+ const net::test_server::HttpRequest& request) override;
+
+ private:
+ // Add to |fetch_response| the policies associated with |client| according to
+ // |policy_type|. Returns true is request is well-formed, or false otherwise
+ // (in which case, |error_msg| is set with the corresponding error message).
+ bool ProcessCloudPolicy(
+ const enterprise_management::PolicyFetchRequest& fetch_request,
+ const ClientStorage::ClientInfo& client,
+ enterprise_management::PolicyFetchResponse* fetch_response,
+ std::string* error_msg);
+
+ // Add to |response| the policies associated with |client_info| for extension
+ // policy type in |fetch_request|. Returns true is request is well-formed, or
+ // false otherwise (in which case, |error_msg| is set with the corresponding
+ // error message).
+ bool ProcessCloudPolicyForExtensions(
+ const enterprise_management::PolicyFetchRequest& fetch_request,
+ const ClientStorage::ClientInfo& client_info,
+ enterprise_management::DevicePolicyResponse* response,
+ std::string* error_msg);
+};
+
+} // namespace policy
+
+#endif // COMPONENTS_POLICY_TEST_SUPPORT_REQUEST_HANDLER_FOR_POLICY_H_