Fix HTTP unit tests (broken with new Boost versions)

This commit is contained in:
Lee *!* Clagett 2025-02-25 18:49:53 -05:00
parent 8d6aff9590
commit 665316708c

View file

@ -125,9 +125,12 @@ TEST(http_server, response_soft_limit)
{ {
dummy::response payload{}; dummy::response payload{};
boost::beast::flat_buffer buffer; boost::beast::flat_buffer buffer;
http::response<http::basic_string_body<char>> res; http::response_parser<http::basic_string_body<char>> parser;
http::read(stream, buffer, res, error); parser.body_limit(payload_size + 1024);
http::read(stream, buffer, parser, error);
EXPECT_FALSE(bool(error)); EXPECT_FALSE(bool(error));
ASSERT_TRUE(parser.is_done());
const auto res = parser.release();
EXPECT_EQ(200u, res.result_int()); EXPECT_EQ(200u, res.result_int());
EXPECT_TRUE(epee::serialization::load_t_from_binary(payload, res.body())); EXPECT_TRUE(epee::serialization::load_t_from_binary(payload, res.body()));
EXPECT_EQ(payload_size, std::count(payload.payload.begin(), payload.payload.end(), 'f')); EXPECT_EQ(payload_size, std::count(payload.payload.begin(), payload.payload.end(), 'f'));
@ -169,12 +172,13 @@ TEST(http_server, private_ip_limit)
http::write(streams.back(), req, error); http::write(streams.back(), req, error);
EXPECT_FALSE(bool(error)); EXPECT_FALSE(bool(error));
dummy::response payload{};
boost::beast::flat_buffer buffer; boost::beast::flat_buffer buffer;
http::response<http::basic_string_body<char>> res; http::response_parser<http::basic_string_body<char>> parser;
parser.body_limit(payload_size + 1024);
http::read(streams.back(), buffer, res, error); http::read(streams.back(), buffer, parser, error);
EXPECT_FALSE(bool(error)); EXPECT_FALSE(bool(error));
EXPECT_TRUE(parser.is_done());
} }
boost::asio::ip::tcp::socket stream{context}; boost::asio::ip::tcp::socket stream{context};
@ -188,12 +192,12 @@ TEST(http_server, private_ip_limit)
http::write(stream, req, error); http::write(stream, req, error);
failed |= bool(error); failed |= bool(error);
{ {
dummy::response payload{};
boost::beast::flat_buffer buffer; boost::beast::flat_buffer buffer;
http::response<http::basic_string_body<char>> res; http::response_parser<http::basic_string_body<char>> parser;
parser.body_limit(payload_size + 1024);
// make sure server ran async_accept code // make sure server ran async_accept code
http::read(stream, buffer, res, error); http::read(stream, buffer, parser, error);
} }
failed |= bool(error); failed |= bool(error);
EXPECT_TRUE(failed); EXPECT_TRUE(failed);