| 2020 | } |
| 2021 | |
| 2022 | void 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 | |
| 2040 | TEST_F(ServerTest, auth) { |
| 2041 | butil::EndPoint ep; |
no test coverage detected