Skip to content

Commit

Permalink
Add the C++ fake_dmserver to replace python server
Browse files Browse the repository at this point in the history
Replace the old python policy test server and use proto messages
directly to set the policies.

Bug: b/215330111
Change-Id: Iedbebe93031c738f82f5dd4a54a13e5802cab92f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3436546
Reviewed-by: Sergiy Belozorov <sergiyb@chromium.org>
Reviewed-by: Roman Sorokin <rsorokin@chromium.org>
Commit-Queue: Mohamed Omar <mohamedaomar@google.com>
Reviewed-by: Victor-Gabriel Savu <vsavu@google.com>
Cr-Commit-Position: refs/heads/main@{#1030970}
  • Loading branch information
Mohamed Omar authored and Chromium LUCI CQ committed Aug 3, 2022
1 parent 23d82fe commit 14e2f3d
Show file tree
Hide file tree
Showing 6 changed files with 1,043 additions and 3 deletions.
27 changes: 27 additions & 0 deletions components/policy/test_support/BUILD.gn
Expand Up @@ -51,6 +51,12 @@ static_library("test_support") {
"test_server_helpers.cc",
"test_server_helpers.h",
]
if (is_chromeos) {
sources += [
"fake_dmserver.cc",
"fake_dmserver.h",
]
}

public_deps = [ "//net:test_support" ]
deps = [
Expand All @@ -66,6 +72,23 @@ static_library("test_support") {
]
}

if (is_chromeos) {
executable("fake_dmserver") {
testonly = true
output_name = "fake_dmserver"
sources = [ "fake_dmserver_main.cc" ]
public_deps = [ "//net:test_support" ]
deps = [
":test_support",
"//base",
"//google_apis:google_apis",
"//net",
"//third_party/private_membership:private_membership_proto",
"//third_party/re2:re2",
]
}
}

source_set("unittests") {
testonly = true

Expand Down Expand Up @@ -95,6 +118,10 @@ source_set("unittests") {
"signature_provider_unittest.cc",
]

if (is_chromeos) {
sources += [ "fake_dmserver_unittest.cc" ]
}

deps = [
":test_support",
"//components/policy/core/common:common_constants",
Expand Down
7 changes: 4 additions & 3 deletions components/policy/test_support/embedded_policy_test_server.h
Expand Up @@ -68,7 +68,7 @@ class EmbeddedPolicyTestServer {
virtual ~EmbeddedPolicyTestServer();

// Initializes and waits until the server is ready to accept requests.
bool Start();
virtual bool Start();

ClientStorage* client_storage() const { return client_storage_.get(); }

Expand Down Expand Up @@ -100,11 +100,12 @@ class EmbeddedPolicyTestServer {
const std::string& raw_policy);
#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

private:
protected:
// Default request handler.
std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
virtual std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
const net::test_server::HttpRequest& request);

private:
// Request handler for external policy data.
std::unique_ptr<net::test_server::HttpResponse>
HandleExternalPolicyDataRequest(const GURL& request);
Expand Down

0 comments on commit 14e2f3d

Please sign in to comment.