Commit fb699070 authored by Mahmoud Gawad's avatar Mahmoud Gawad Committed by Commit Bot

wilco_dtc_supportd: add support for HTTP PATCH

Add HTTP PATCH Mojo API support in wilco_dtc_supportd.mojom.

Add the HTTP PATCH method to the list of supported HTTP methods in
wilco_dtc_supportd mojo client. This enables the requester
(wilco_dtc_supportd daemon) to make HTTP PATCH requests instead of
receiving errors.

BUG=b:159097923
TEST=Added unit test for Patch method (PASS)

Change-Id: I1000067f5c3658f80c6046e4ffea9871d49d557d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247030Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Reviewed-by: default avatarMattias Nissler <mnissler@chromium.org>
Commit-Queue: Mahmoud Gawad <mgawad@google.com>
Cr-Commit-Position: refs/heads/master@{#779820}
parent 4795f8cd
......@@ -49,6 +49,9 @@ std::string GetHttpMethod(
return "POST";
case wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestHttpMethod::kPut:
return "PUT";
case wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestHttpMethod::
kPatch:
return "PATCH";
}
return "";
}
......
......@@ -271,6 +271,26 @@ TEST_F(WilcoDtcSupportdWebRequestServiceTest, HttpMethodPutEmptyBody) {
EXPECT_EQ(request_result->response_body, "");
}
TEST_F(WilcoDtcSupportdWebRequestServiceTest, HttpMethodPatchEmptyBody) {
std::unique_ptr<WebRequestResult> request_result;
base::RunLoop run_loop;
StartWebRequest(
wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestHttpMethod::kPatch,
kFakeUrl, {} /* headers */, "" /* request_body */, &request_result,
&run_loop);
EXPECT_FALSE(request_result);
InjectNetworkResponse(kFakeUrl,
std::make_unique<net::HttpStatusCode>(net::HTTP_OK),
net::OK, "" /* response_body */);
run_loop.Run();
ASSERT_TRUE(request_result);
EXPECT_EQ(request_result->status,
wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestStatus::kOk);
EXPECT_EQ(request_result->http_status, net::HTTP_OK);
EXPECT_EQ(request_result->response_body, "");
}
TEST_F(WilcoDtcSupportdWebRequestServiceTest, ResponseCodeParsingError) {
std::unique_ptr<WebRequestResult> request_result;
base::RunLoop run_loop;
......
......@@ -18,6 +18,7 @@ enum WilcoDtcSupportdWebRequestHttpMethod {
kHead,
kPost,
kPut,
kPatch,
};
[Extensible]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment