MCPcopy Create free account
hub / github.com/apache/brpc / TestHttpAuth

Function TestHttpAuth

test/brpc_server_unittest.cpp:2022–2038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2020}
2021
2022void TestHttpAuth(const butil::EndPoint& ep,
2023 brpc::Controller& cntl,
2024 int status_code, bool failed) {
2025 brpc::Channel chan;
2026 brpc::ChannelOptions copt;
2027 copt.max_retry = 0;
2028 copt.protocol = "http";
2029 ASSERT_EQ(0, chan.Init(ep, &copt));
2030
2031 cntl.http_request().uri() = "/EchoService/Echo";
2032 cntl.request_attachment().append(R"({"message": "hello"})");
2033 cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
2034 test::EchoService_Stub stub(&chan);
2035 chan.CallMethod(NULL, &cntl, NULL, NULL, NULL);
2036 ASSERT_EQ(cntl.Failed(), failed) << cntl.ErrorText();
2037 ASSERT_EQ(cntl.http_response().status_code(), status_code);
2038}
2039
2040TEST_F(ServerTest, auth) {
2041 butil::EndPoint ep;

Callers 1

TEST_FFunction · 0.85

Calls 7

ErrorTextMethod · 0.80
status_codeMethod · 0.80
InitMethod · 0.45
appendMethod · 0.45
set_methodMethod · 0.45
CallMethodMethod · 0.45
FailedMethod · 0.45

Tested by

no test coverage detected