chromium/components/policy/test_support/BUILD.gn

# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//third_party/cast_core/public/src/proto/proto.gni")

static_library("test_support") {
  testonly = true

  sources = [
    "client_storage.cc",
    "client_storage.h",
    "embedded_policy_test_server.cc",
    "embedded_policy_test_server.h",
    "policy_storage.cc",
    "policy_storage.h",
    "remote_commands_result_waiter.cc",
    "remote_commands_result_waiter.h",
    "remote_commands_state.cc",
    "remote_commands_state.h",
    "request_handler_for_api_authorization.cc",
    "request_handler_for_api_authorization.h",
    "request_handler_for_auto_enrollment.cc",
    "request_handler_for_auto_enrollment.h",
    "request_handler_for_cert_upload.cc",
    "request_handler_for_cert_upload.h",
    "request_handler_for_check_android_management.cc",
    "request_handler_for_check_android_management.h",
    "request_handler_for_check_user_account.cc",
    "request_handler_for_check_user_account.h",
    "request_handler_for_chrome_desktop_report.cc",
    "request_handler_for_chrome_desktop_report.h",
    "request_handler_for_client_cert_provisioning.cc",
    "request_handler_for_client_cert_provisioning.h",
    "request_handler_for_device_attribute_update.cc",
    "request_handler_for_device_attribute_update.h",
    "request_handler_for_device_attribute_update_permission.cc",
    "request_handler_for_device_attribute_update_permission.h",
    "request_handler_for_device_initial_enrollment_state.cc",
    "request_handler_for_device_initial_enrollment_state.h",
    "request_handler_for_device_state_retrieval.cc",
    "request_handler_for_device_state_retrieval.h",
    "request_handler_for_policy.cc",
    "request_handler_for_policy.h",
    "request_handler_for_register_browser.cc",
    "request_handler_for_register_browser.h",
    "request_handler_for_register_cert_based.cc",
    "request_handler_for_register_cert_based.h",
    "request_handler_for_register_device_and_user.cc",
    "request_handler_for_register_device_and_user.h",
    "request_handler_for_remote_commands.cc",
    "request_handler_for_remote_commands.h",
    "request_handler_for_status_upload.cc",
    "request_handler_for_status_upload.h",
    "request_handler_for_unregister.cc",
    "request_handler_for_unregister.h",
    "request_handler_for_upload_euicc_info.cc",
    "request_handler_for_upload_euicc_info.h",
    "signature_provider.cc",
    "signature_provider.h",
    "test_server_helpers.cc",
    "test_server_helpers.h",
  ]
  if (is_chromeos) {
    sources += [
      "fake_dmserver.cc",
      "fake_dmserver.h",
      "request_handler_for_psm_auto_enrollment.cc",
      "request_handler_for_psm_auto_enrollment.h",
    ]
  }

  public_deps = [ "//net:test_support" ]
  deps = [
    "//base",
    "//components/policy/core/common:common_constants",
    "//components/policy/core/common:test_support",
    "//components/policy/proto",
    "//crypto",
    "//google_apis:google_apis",
    "//net",
    "//net:test_support",
    "//third_party/private_membership:private_membership_proto",
    "//third_party/re2:re2",
  ]

  if (is_chromeos) {
    public_deps += [ "//third_party/private_membership" ]
    deps += [
      ":remote_commands_service_castcore",
      "//chromecast/cast_core/grpc:grpc",
    ]
    data = [
      # TODO(crbug.com/40248354): Script should create binarypb from textpb.
      # Required for policy/enrollment/psm/rlwe_test_support.cc
      "//third_party/private_membership/src/internal/testing/regression_test_data/test_data.binarypb",
    ]
  }
}

if (is_chromeos) {
  cast_core_grpc_library("remote_commands_service") {
    testonly = true
    sources = [ "remote_commands_service.proto" ]
    deps = [ "//third_party/private_membership:private_membership_proto" ]
    extra_configs =
        [ "//third_party/private_membership:private_membership_config" ]
    import_dirs = [
      "//components/policy/proto",
      "//third_party/private_membership/src",
      "//third_party/shell-encryption/src",
    ]
    proto_deps = [ "//components/policy/proto" ]
    generate_castcore_stubs = true
  }

  executable("fake_dmserver") {
    testonly = true
    output_name = "fake_dmserver"
    sources = [ "fake_dmserver_main.cc" ]
    deps = [
      ":test_support",
      "//base",
      "//third_party/abseil-cpp:absl",
    ]
  }
}

source_set("unittests") {
  testonly = true

  sources = [
    "client_storage_unittest.cc",
    "embedded_policy_test_server_test_base.cc",
    "embedded_policy_test_server_test_base.h",
    "embedded_policy_test_server_unittest.cc",
    "policy_storage_unittest.cc",
    "remote_commands_state_unittest.cc",
    "request_handler_for_api_authorization_unittest.cc",
    "request_handler_for_auto_enrollment_unittest.cc",
    "request_handler_for_cert_upload_unittest.cc",
    "request_handler_for_check_android_management_unittest.cc",
    "request_handler_for_check_user_account_unittest.cc",
    "request_handler_for_chrome_desktop_report_unittest.cc",
    "request_handler_for_client_cert_provisioning_unittest.cc",
    "request_handler_for_device_attribute_update_permission_unittest.cc",
    "request_handler_for_device_attribute_update_unittest.cc",
    "request_handler_for_device_initial_enrollment_state_unittest.cc",
    "request_handler_for_device_state_retrieval_unittest.cc",
    "request_handler_for_policy_unittest.cc",
    "request_handler_for_register_browser_unittest.cc",
    "request_handler_for_register_cert_based_unittest.cc",
    "request_handler_for_register_device_and_user_unittest.cc",
    "request_handler_for_remote_commands_unittest.cc",
    "request_handler_for_status_upload_unittest.cc",
    "request_handler_for_unregister_unittest.cc",
    "request_handler_for_upload_euicc_info_unittest.cc",
    "signature_provider_unittest.cc",
  ]

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

  deps = [
    ":test_support",
    "//components/policy/core/common:common_constants",
    "//components/policy/core/common:test_support",
    "//components/policy/proto",
    "//services/network:test_support",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//third_party/abseil-cpp:absl",
  ]
}