#include "components/policy/test_support/request_handler_for_policy.h"
#include <utility>
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_validator.h"
#include "components/policy/core/common/cloud/test/policy_builder.h"
#include "components/policy/proto/cloud_policy.pb.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/policy/test_support/client_storage.h"
#include "components/policy/test_support/embedded_policy_test_server_test_base.h"
#include "components/policy/test_support/policy_storage.h"
#include "net/http/http_status_code.h"
#include "testing/gtest/include/gtest/gtest.h"
em;
namespace policy {
namespace {
constexpr char kDeviceId[] = …;
constexpr char kDeviceToken[] = …;
constexpr char kMachineName[] = …;
constexpr char kPolicyInvalidationTopic[] = …;
constexpr char kUsername[] = …;
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
constexpr char kPublicAccountEntityId[] = …;
constexpr char kExtensionId[] = …;
#endif
}
class RequestHandlerForPolicyTest : public EmbeddedPolicyTestServerTestBase { … };
TEST_F(RequestHandlerForPolicyTest, HandleRequest_NoDeviceToken) { … }
TEST_F(RequestHandlerForPolicyTest, HandleRequest_NoRegisteredClient) { … }
TEST_F(RequestHandlerForPolicyTest, HandleRequest_UnmatchedDeviceId) { … }
TEST_F(RequestHandlerForPolicyTest, HandleRequest_InvalidPolicyType) { … }
TEST_F(RequestHandlerForPolicyTest, HandleRequest_UnauthorizedPolicyType) { … }
TEST_F(RequestHandlerForPolicyTest, HandleRequest_Success_NoSignedPolicies) { … }
class RequestHandlerForPolicyTestWithParametrizedSignatureType
: public RequestHandlerForPolicyTest,
public testing::WithParamInterface<
em::PolicyFetchRequest::SignatureType> { … };
TEST_P(RequestHandlerForPolicyTestWithParametrizedSignatureType,
HandleRequest_Success_SignedPoliciesWithoutClientKey) { … }
TEST_P(RequestHandlerForPolicyTestWithParametrizedSignatureType,
HandleRequest_Success_SendsNewPublicKeyVerificationData) { … }
TEST_P(RequestHandlerForPolicyTestWithParametrizedSignatureType,
HandleRequest_Success_SignedPoliciesWithClientKey) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(RequestHandlerForPolicyTest,
HandleRequest_Success_UnsignedExtensionPolicies) { … }
TEST_F(RequestHandlerForPolicyTest,
HandleRequest_ExtensionPoliciesWithMissingSigningKey) { … }
TEST_P(RequestHandlerForPolicyTestWithParametrizedSignatureType,
HandleRequest_ExtensionsInPublicAccounts_SetCorrectPolicyDataUsername) { … }
#endif
INSTANTIATE_TEST_SUITE_P(…);
}