xref: /openbmc/bmcweb/http/test_stream.hpp (revision 796ba93b48f7866630a3c031fd6b01c118202953)
1 #pragma once
2 
3 #include <boost/asio/io_context.hpp>
4 #include <boost/asio/ip/tcp.hpp>
5 #include <boost/beast/_experimental/test/stream.hpp>
6 
7 namespace crow
8 {
9 
10 /*
11 A test class that simulates a socket by wrapping the beast test stream
12 
13 Additionally it adds remote_endpoint to allow testing of TCP-specific behaviors
14 */
15 struct TestStream : public boost::beast::test::stream
16 {
TestStreamcrow::TestStream17     explicit TestStream(boost::asio::io_context& io) :
18         boost::beast::test::stream(io)
19     {}
20 
21     using endpoint = boost::asio::ip::tcp::endpoint;
22     // NOLINTNEXTLINE(readability-identifier-naming)
remote_endpointcrow::TestStream23     static endpoint remote_endpoint(boost::system::error_code& ec)
24     {
25         ec = {};
26         return {};
27     }
28 };
29 
30 } // namespace crow
31