chromium/components/policy/core/common/cloud/test/policy_builder.h

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

#ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_TEST_POLICY_BUILDER_H_
#define COMPONENTS_POLICY_CORE_COMMON_CLOUD_TEST_POLICY_BUILDER_H_

#include <stdint.h>

#include <memory>
#include <string>
#include <vector>

#include "base/check.h"
#include "base/compiler_specific.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/account_id/account_id.h"
#include "components/policy/proto/cloud_policy.pb.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "crypto/rsa_private_key.h"

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#include "components/policy/proto/chrome_extension_policy.pb.h"
#endif

namespace enterprise_management {
class CloudPolicySettings;
}  // namespace enterprise_management

namespace policy {

extern const uint8_t kVerificationPrivateKey[1218];

// A helper class for testing that provides a straightforward interface for
// constructing policy blobs for use in testing. NB: This uses fake data and
// hard-coded signing keys by default, so should not be used in production code.
// The signatures are generated based on different key than used in production,
// so any test using this class needs to add the command line flag
// switches::kPolicyVerificationKey to change the verification key if they
// wish the signatures provided by this class to pass validation.
class PolicyBuilder {};

// Type-parameterized PolicyBuilder extension that allows for building policy
// blobs carrying protobuf payloads.
template <typename PayloadProto>
class TypedPolicyBuilder : public PolicyBuilder {};

// PolicyBuilder extension that allows for building policy blobs carrying string
// payloads.
class StringPolicyBuilder : public PolicyBuilder {};

UserPolicyBuilder;

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
ComponentCloudPolicyBuilder;
#endif

#if BUILDFLAG(IS_CHROMEOS_ASH)
using ComponentActiveDirectoryPolicyBuilder = StringPolicyBuilder;
#endif

}  // namespace policy

#endif  // COMPONENTS_POLICY_CORE_COMMON_CLOUD_TEST_POLICY_BUILDER_H_