request_handler_for_remote_commands_unittest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/policy/test_support/request_handler_for_remote_commands.h"
  5. #include <utility>
  6. #include "components/policy/core/common/cloud/cloud_policy_constants.h"
  7. #include "components/policy/test_support/embedded_policy_test_server_test_base.h"
  8. #include "components/policy/test_support/policy_storage.h"
  9. #include "net/http/http_status_code.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. namespace policy {
  12. namespace {
  13. constexpr char kDeviceId[] = "fake_device_id";
  14. } // namespace
  15. class RequestHandlerForRemoteCommandsTest
  16. : public EmbeddedPolicyTestServerTestBase {
  17. public:
  18. RequestHandlerForRemoteCommandsTest() = default;
  19. ~RequestHandlerForRemoteCommandsTest() override = default;
  20. void SetUp() override {
  21. EmbeddedPolicyTestServerTestBase::SetUp();
  22. SetRequestTypeParam(dm_protocol::kValueRequestRemoteCommands);
  23. SetAppType(dm_protocol::kValueAppType);
  24. SetDeviceIdParam(kDeviceId);
  25. SetDeviceType(dm_protocol::kValueDeviceType);
  26. }
  27. };
  28. TEST_F(RequestHandlerForRemoteCommandsTest, HandleRequest) {
  29. StartRequestAndWait();
  30. EXPECT_EQ(GetResponseCode(), net::HTTP_OK);
  31. ASSERT_TRUE(HasResponseBody());
  32. auto response = GetDeviceManagementResponse();
  33. EXPECT_TRUE(response.has_remote_command_response());
  34. }
  35. } // namespace policy