summaryrefslogtreecommitdiff
path: root/chromium/components/policy/test_support/failing_request_handler_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/policy/test_support/failing_request_handler_unittest.cc')
-rw-r--r--chromium/components/policy/test_support/failing_request_handler_unittest.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/chromium/components/policy/test_support/failing_request_handler_unittest.cc b/chromium/components/policy/test_support/failing_request_handler_unittest.cc
new file mode 100644
index 00000000000..373352bfc7a
--- /dev/null
+++ b/chromium/components/policy/test_support/failing_request_handler_unittest.cc
@@ -0,0 +1,47 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/policy/test_support/failing_request_handler.h"
+
+#include <utility>
+
+#include "components/policy/core/common/cloud/cloud_policy_constants.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"
+
+namespace policy {
+
+namespace {
+
+constexpr char kDeviceId[] = "fake_device_id";
+
+} // namespace
+
+class FailingRequestHandlerTest : public EmbeddedPolicyTestServerTestBase {
+ public:
+ FailingRequestHandlerTest() = default;
+ ~FailingRequestHandlerTest() override = default;
+
+ void SetUp() override {
+ EmbeddedPolicyTestServerTestBase::SetUp();
+
+ SetRequestTypeParam(dm_protocol::kValueRequestRegister);
+ SetAppType(dm_protocol::kValueAppType);
+ SetDeviceIdParam(kDeviceId);
+ SetDeviceType(dm_protocol::kValueDeviceType);
+ }
+};
+
+TEST_F(FailingRequestHandlerTest, HandleRequest) {
+ test_server()->ConfigureRequestError(dm_protocol::kValueRequestRegister,
+ net::HTTP_METHOD_NOT_ALLOWED);
+
+ StartRequestAndWait();
+
+ EXPECT_EQ(GetResponseCode(), net::HTTP_METHOD_NOT_ALLOWED);
+}
+
+} // namespace policy