request_handler_for_device_attribute_update_unittest.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "base/strings/strcat.h"
  5. #include "components/policy/core/common/cloud/cloud_policy_constants.h"
  6. #include "components/policy/test_support/client_storage.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 "components/policy/test_support/request_handler_for_register_browser.h"
  10. #include "device_management_backend.pb.h"
  11. #include "net/http/http_status_code.h"
  12. #include "testing/gmock/include/gmock/gmock.h"
  13. #include "testing/gtest/include/gtest/gtest.h"
  14. namespace em = enterprise_management;
  15. namespace policy {
  16. namespace {
  17. constexpr char kDeviceId[] = "fake_device_id";
  18. } // namespace
  19. class RequestHandlerForDeviceAttributeUpdateTest
  20. : public EmbeddedPolicyTestServerTestBase {
  21. protected:
  22. RequestHandlerForDeviceAttributeUpdateTest() = default;
  23. ~RequestHandlerForDeviceAttributeUpdateTest() override = default;
  24. void SetUp() override {
  25. EmbeddedPolicyTestServerTestBase::SetUp();
  26. SetRequestTypeParam(dm_protocol::kValueRequestDeviceAttributeUpdate);
  27. SetAppType(dm_protocol::kValueAppType);
  28. SetDeviceIdParam(kDeviceId);
  29. SetDeviceType(dm_protocol::kValueDeviceType);
  30. }
  31. };
  32. TEST_F(RequestHandlerForDeviceAttributeUpdateTest, HandleRequest) {
  33. em::DeviceManagementRequest device_management_request;
  34. SetPayload(device_management_request);
  35. StartRequestAndWait();
  36. EXPECT_EQ(GetResponseCode(), net::HTTP_OK);
  37. ASSERT_TRUE(HasResponseBody());
  38. auto response = GetDeviceManagementResponse();
  39. EXPECT_EQ(response.device_attribute_update_response().result(),
  40. em::DeviceAttributeUpdateResponse::ATTRIBUTE_UPDATE_SUCCESS);
  41. }
  42. } // namespace policy