request_handler_for_chrome_desktop_report_unittest.cc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_chrome_desktop_report.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 "net/http/http_status_code.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. namespace em = enterprise_management;
  11. namespace policy {
  12. namespace {
  13. constexpr char kDeviceId[] = "fake_device_id";
  14. } // namespace
  15. class RequestHandlerForChromeDesktopReportTest
  16. : public EmbeddedPolicyTestServerTestBase {
  17. protected:
  18. RequestHandlerForChromeDesktopReportTest() = default;
  19. ~RequestHandlerForChromeDesktopReportTest() override = default;
  20. void SetUp() override {
  21. EmbeddedPolicyTestServerTestBase::SetUp();
  22. SetRequestTypeParam(dm_protocol::kValueRequestChromeDesktopReport);
  23. SetAppType(dm_protocol::kValueAppType);
  24. SetDeviceIdParam(kDeviceId);
  25. SetDeviceType(dm_protocol::kValueDeviceType);
  26. }
  27. };
  28. TEST_F(RequestHandlerForChromeDesktopReportTest, HandleRequest_Success) {
  29. StartRequestAndWait();
  30. EXPECT_EQ(GetResponseCode(), net::HTTP_OK);
  31. ASSERT_TRUE(HasResponseBody());
  32. auto response = GetDeviceManagementResponse();
  33. EXPECT_TRUE(response.has_chrome_desktop_report_response());
  34. }
  35. } // namespace policy