mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Convert code to use boost::beast
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include <ripple/protocol/SecretKey.h>
|
||||
#include <ripple/protocol/Sign.h>
|
||||
#include <ripple/protocol/STExchange.h>
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/utility/in_place_factory.hpp>
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
Serializer s;
|
||||
st.add(s);
|
||||
|
||||
return beast::detail::base64_encode (std::string(
|
||||
return boost::beast::detail::base64_encode (std::string(
|
||||
static_cast<char const*> (s.data()), s.size()));
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
Serializer s;
|
||||
st.add(s);
|
||||
|
||||
return beast::detail::base64_encode (std::string(
|
||||
return boost::beast::detail::base64_encode (std::string(
|
||||
static_cast<char const*> (s.data()), s.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
derivePublicKey(KeyType::secp256k1, tokenSecretKey);
|
||||
|
||||
auto const m = Manifest::make_Manifest(
|
||||
beast::detail::base64_decode(tokenManifest));
|
||||
boost::beast::detail::base64_decode(tokenManifest));
|
||||
BEAST_EXPECT(m);
|
||||
NodeID const tokenNodeID = calcNodeID(m->masterKey);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
#include <ripple/basics/Slice.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/app/misc/ValidatorList.h>
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
derivePublicKey(KeyType::ed25519, secret);
|
||||
auto const signingKeys = randomKeyPair(KeyType::secp256k1);
|
||||
return { masterPublic, signingKeys.first,
|
||||
beast::detail::base64_encode(makeManifestString (
|
||||
boost::beast::detail::base64_encode(makeManifestString (
|
||||
masterPublic, secret, signingKeys.first, signingKeys.second, 1)) };
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
|
||||
data.pop_back();
|
||||
data += "]}";
|
||||
return beast::detail::base64_encode(data);
|
||||
return boost::beast::detail::base64_encode(data);
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
std::string const& blob,
|
||||
std::pair<PublicKey, SecretKey> const& keys)
|
||||
{
|
||||
auto const data = beast::detail::base64_decode (blob);
|
||||
auto const data = boost::beast::detail::base64_decode (blob);
|
||||
return strHex(sign(
|
||||
keys.first, keys.second, makeSlice(data)));
|
||||
}
|
||||
@@ -374,7 +374,7 @@ private:
|
||||
auto const publisherPublic =
|
||||
derivePublicKey(KeyType::ed25519, publisherSecret);
|
||||
auto const pubSigningKeys1 = randomKeyPair(KeyType::secp256k1);
|
||||
auto const manifest1 = beast::detail::base64_encode(makeManifestString (
|
||||
auto const manifest1 = boost::beast::detail::base64_encode(makeManifestString (
|
||||
publisherPublic, publisherSecret,
|
||||
pubSigningKeys1.first, pubSigningKeys1.second, 1));
|
||||
|
||||
@@ -425,7 +425,7 @@ private:
|
||||
}
|
||||
|
||||
// do not use list from untrusted publisher
|
||||
auto const untrustedManifest = beast::detail::base64_encode(
|
||||
auto const untrustedManifest = boost::beast::detail::base64_encode(
|
||||
makeManifestString (
|
||||
randomMasterKey(), publisherSecret,
|
||||
pubSigningKeys1.first, pubSigningKeys1.second, 1));
|
||||
@@ -472,7 +472,7 @@ private:
|
||||
|
||||
// apply list with new publisher key updated by manifest
|
||||
auto const pubSigningKeys2 = randomKeyPair(KeyType::secp256k1);
|
||||
auto manifest2 = beast::detail::base64_encode(makeManifestString (
|
||||
auto manifest2 = boost::beast::detail::base64_encode(makeManifestString (
|
||||
publisherPublic, publisherSecret,
|
||||
pubSigningKeys2.first, pubSigningKeys2.second, 2));
|
||||
|
||||
@@ -496,7 +496,7 @@ private:
|
||||
// do not apply list with revoked publisher key
|
||||
// applied list is removed due to revoked publisher key
|
||||
auto const signingKeysMax = randomKeyPair(KeyType::secp256k1);
|
||||
auto maxManifest = beast::detail::base64_encode(makeManifestString (
|
||||
auto maxManifest = boost::beast::detail::base64_encode(makeManifestString (
|
||||
publisherPublic, publisherSecret,
|
||||
pubSigningKeys2.first, pubSigningKeys2.second,
|
||||
std::numeric_limits<std::uint32_t>::max ()));
|
||||
@@ -792,7 +792,7 @@ private:
|
||||
std::vector<std::string> emptyCfgKeys;
|
||||
auto const publisherKeys = randomKeyPair(KeyType::secp256k1);
|
||||
auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1);
|
||||
auto const manifest = beast::detail::base64_encode (
|
||||
auto const manifest = boost::beast::detail::base64_encode (
|
||||
makeManifestString (
|
||||
publisherKeys.first, publisherKeys.second,
|
||||
pubSigningKeys.first, pubSigningKeys.second, 1));
|
||||
@@ -963,7 +963,7 @@ private:
|
||||
auto const publisherPublic =
|
||||
derivePublicKey(KeyType::ed25519, publisherSecret);
|
||||
auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1);
|
||||
auto const manifest = beast::detail::base64_encode(makeManifestString (
|
||||
auto const manifest = boost::beast::detail::base64_encode(makeManifestString (
|
||||
publisherPublic, publisherSecret,
|
||||
pubSigningKeys.first, pubSigningKeys.second, 1));
|
||||
|
||||
@@ -1073,7 +1073,7 @@ private:
|
||||
auto const publisherPublic =
|
||||
derivePublicKey(KeyType::ed25519, publisherSecret);
|
||||
auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1);
|
||||
auto const manifest = beast::detail::base64_encode(makeManifestString (
|
||||
auto const manifest = boost::beast::detail::base64_encode(makeManifestString (
|
||||
publisherPublic, publisherSecret,
|
||||
pubSigningKeys.first, pubSigningKeys.second, 1));
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <ripple/app/misc/ValidatorSite.h>
|
||||
#include <ripple/basics/Slice.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
@@ -29,6 +28,7 @@
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/TrustedPublisherServer.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
Serializer s;
|
||||
st.add(s);
|
||||
|
||||
return beast::detail::base64_encode (std::string(
|
||||
return boost::beast::detail::base64_encode (std::string(
|
||||
static_cast<char const*> (s.data()), s.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <ripple/protocol/STAmount.h>
|
||||
#include <ripple/protocol/STObject.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
@@ -713,7 +713,7 @@ protected:
|
||||
FN const&... fN)
|
||||
{
|
||||
maybe_invoke(stx, f,
|
||||
beast::detail::is_invocable<F,
|
||||
boost::beast::detail::is_invocable<F,
|
||||
void(Env&, STTx const&)>());
|
||||
invoke(stx, fN...);
|
||||
}
|
||||
@@ -747,7 +747,7 @@ protected:
|
||||
FN const&... fN)
|
||||
{
|
||||
maybe_invoke(jt, f,
|
||||
beast::detail::is_invocable<F,
|
||||
boost::beast::detail::is_invocable<F,
|
||||
void(Env&, JTx&)>());
|
||||
invoke(jt, fN...);
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
#ifndef RIPPLE_TEST_TRUSTED_PUBLISHER_SERVER_H_INCLUDED
|
||||
#define RIPPLE_TEST_TRUSTED_PUBLISHER_SERVER_H_INCLUDED
|
||||
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <ripple/protocol/PublicKey.h>
|
||||
#include <ripple/protocol/SecretKey.h>
|
||||
#include <ripple/protocol/Sign.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <beast/http.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
@@ -37,8 +36,8 @@ class TrustedPublisherServer
|
||||
using address_type = boost::asio::ip::address;
|
||||
using socket_type = boost::asio::ip::tcp::socket;
|
||||
|
||||
using req_type = beast::http::request<beast::http::string_body>;
|
||||
using resp_type = beast::http::response<beast::http::string_body>;
|
||||
using req_type = boost::beast::http::request<boost::beast::http::string_body>;
|
||||
using resp_type = boost::beast::http::response<boost::beast::http::string_body>;
|
||||
using error_code = boost::system::error_code;
|
||||
|
||||
socket_type sock_;
|
||||
@@ -78,7 +77,7 @@ public:
|
||||
}
|
||||
data.pop_back();
|
||||
data += "]}";
|
||||
std::string blob = beast::detail::base64_encode(data);
|
||||
std::string blob = boost::beast::detail::base64_encode(data);
|
||||
|
||||
list_ = "{\"blob\":\"" + blob + "\"";
|
||||
|
||||
@@ -155,35 +154,35 @@ private:
|
||||
do_peer(int id, socket_type&& sock0)
|
||||
{
|
||||
socket_type sock(std::move(sock0));
|
||||
beast::multi_buffer sb;
|
||||
boost::beast::multi_buffer sb;
|
||||
error_code ec;
|
||||
for (;;)
|
||||
{
|
||||
req_type req;
|
||||
beast::http::read(sock, sb, req, ec);
|
||||
boost::beast::http::read(sock, sb, req, ec);
|
||||
if (ec)
|
||||
break;
|
||||
auto path = req.target().to_string();
|
||||
if (path != "/validators")
|
||||
{
|
||||
resp_type res;
|
||||
res.result(beast::http::status::not_found);
|
||||
res.version = req.version;
|
||||
res.result(boost::beast::http::status::not_found);
|
||||
res.version(req.version());
|
||||
res.insert("Server", "TrustedPublisherServer");
|
||||
res.insert("Content-Type", "text/html");
|
||||
res.body = "The file '" + path + "' was not found";
|
||||
res.body() = "The file '" + path + "' was not found";
|
||||
res.prepare_payload();
|
||||
write(sock, res, ec);
|
||||
if (ec)
|
||||
break;
|
||||
}
|
||||
resp_type res;
|
||||
res.result(beast::http::status::ok);
|
||||
res.version = req.version;
|
||||
res.result(boost::beast::http::status::ok);
|
||||
res.version(req.version());
|
||||
res.insert("Server", "TrustedPublisherServer");
|
||||
res.insert("Content-Type", "application/json");
|
||||
|
||||
res.body = list_;
|
||||
res.body() = list_;
|
||||
try
|
||||
{
|
||||
res.prepare_payload();
|
||||
@@ -191,11 +190,11 @@ private:
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
res = {};
|
||||
res.result(beast::http::status::internal_server_error);
|
||||
res.version = req.version;
|
||||
res.result(boost::beast::http::status::internal_server_error);
|
||||
res.version(req.version());
|
||||
res.insert("Server", "TrustedPublisherServer");
|
||||
res.insert("Content-Type", "text/html");
|
||||
res.body = std::string{"An internal error occurred"} + e.what();
|
||||
res.body() = std::string{"An internal error occurred"} + e.what();
|
||||
res.prepare_payload();
|
||||
}
|
||||
write(sock, res, ec);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <test/jtx/WSClient.h>
|
||||
#include <test/jtx.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <beast/core/handler_alloc.hpp>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/dynamic_body.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/beast/http/dynamic_body.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <string>
|
||||
|
||||
@@ -73,8 +73,8 @@ class JSONRPCClient : public AbstractClient
|
||||
boost::asio::ip::tcp::endpoint ep_;
|
||||
boost::asio::io_service ios_;
|
||||
boost::asio::ip::tcp::socket stream_;
|
||||
beast::multi_buffer bin_;
|
||||
beast::multi_buffer bout_;
|
||||
boost::beast::multi_buffer bin_;
|
||||
boost::beast::multi_buffer bout_;
|
||||
unsigned rpc_version_;
|
||||
|
||||
public:
|
||||
@@ -103,14 +103,14 @@ public:
|
||||
invoke(std::string const& cmd,
|
||||
Json::Value const& params) override
|
||||
{
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
using namespace boost::asio;
|
||||
using namespace std::string_literals;
|
||||
|
||||
request<string_body> req;
|
||||
req.method(beast::http::verb::post);
|
||||
req.method(boost::beast::http::verb::post);
|
||||
req.target("/");
|
||||
req.version = 11;
|
||||
req.version(11);
|
||||
req.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
req.insert("Host", ep_);
|
||||
{
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
Json::Value& ja = jr[jss::params] = Json::arrayValue;
|
||||
ja.append(params);
|
||||
}
|
||||
req.body = to_string(jr);
|
||||
req.body() = to_string(jr);
|
||||
}
|
||||
req.prepare_payload();
|
||||
write(stream_, req);
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
|
||||
Json::Reader jr;
|
||||
Json::Value jv;
|
||||
jr.parse(buffer_string(res.body.data()), jv);
|
||||
jr.parse(buffer_string(res.body().data()), jv);
|
||||
if(jv["result"].isMember("error"))
|
||||
jv["error"] = jv["result"]["error"];
|
||||
if(jv["result"].isMember("status"))
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
|
||||
#include <condition_variable>
|
||||
|
||||
@@ -92,8 +92,8 @@ class WSClientImpl : public WSClient
|
||||
boost::asio::io_service::strand strand_;
|
||||
std::thread thread_;
|
||||
boost::asio::ip::tcp::socket stream_;
|
||||
beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
|
||||
beast::multi_buffer rb_;
|
||||
boost::beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
|
||||
boost::beast::multi_buffer rb_;
|
||||
|
||||
bool peerClosed_ = false;
|
||||
|
||||
@@ -109,13 +109,17 @@ class WSClientImpl : public WSClient
|
||||
|
||||
unsigned rpc_version_;
|
||||
|
||||
void cleanup()
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
ios_.post(strand_.wrap([this] {
|
||||
error_code ec;
|
||||
if (!peerClosed_)
|
||||
ws_.close({}, ec);
|
||||
stream_.close(ec);
|
||||
{
|
||||
ws_.async_close({}, strand_.wrap([&](error_code ec) {
|
||||
stream_.cancel(ec);
|
||||
}));
|
||||
}
|
||||
}));
|
||||
work_ = boost::none;
|
||||
thread_.join();
|
||||
@@ -173,7 +177,7 @@ public:
|
||||
else
|
||||
jp[jss::command] = cmd;
|
||||
auto const s = to_string(jp);
|
||||
ws_.write_frame(true, buffer(s));
|
||||
ws_.write_some(true, buffer(s));
|
||||
}
|
||||
|
||||
auto jv = findMsg(5s,
|
||||
@@ -259,7 +263,7 @@ private:
|
||||
{
|
||||
if(ec)
|
||||
{
|
||||
if(ec == beast::websocket::error::closed)
|
||||
if(ec == boost::beast::websocket::error::closed)
|
||||
peerClosed_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <nudb/create.hpp>
|
||||
#include <nudb/detail/format.hpp>
|
||||
#include <nudb/xxhasher.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -257,7 +257,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
std::map <std::string, std::string, beast::iless>
|
||||
std::map <std::string, std::string, boost::beast::iless>
|
||||
parse_args(std::string const& s)
|
||||
{
|
||||
// <key> '=' <value>
|
||||
@@ -273,7 +273,7 @@ parse_args(std::string const& s)
|
||||
, boost::regex_constants::optimize
|
||||
);
|
||||
std::map <std::string,
|
||||
std::string, beast::iless> map;
|
||||
std::string, boost::beast::iless> map;
|
||||
auto const v = beast::rfc2616::split(
|
||||
s.begin(), s.end(), ',');
|
||||
for (auto const& kv : v)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/protocol/Sign.h>
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/TrustedPublisherServer.h>
|
||||
|
||||
@@ -75,7 +75,7 @@ class ValidatorRPC_test : public beast::unit_test::suite
|
||||
Serializer s;
|
||||
st.add(s);
|
||||
|
||||
return beast::detail::base64_encode(
|
||||
return boost::beast::detail::base64_encode(
|
||||
std::string(static_cast<char const*>(s.data()), s.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
#include <test/jtx/JSONRPCClient.h>
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <beast/http.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/websocket/detail/mask.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/websocket/detail/mask.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@@ -41,7 +41,7 @@ namespace test {
|
||||
class ServerStatus_test :
|
||||
public beast::unit_test::suite, public beast::test::enable_yield_to
|
||||
{
|
||||
class myFields : public beast::http::fields {};
|
||||
class myFields : public boost::beast::http::fields {};
|
||||
|
||||
auto makeConfig(
|
||||
std::string const& proto,
|
||||
@@ -87,21 +87,21 @@ class ServerStatus_test :
|
||||
uint16_t port)
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
request<string_body> req;
|
||||
|
||||
req.target("/");
|
||||
req.version = 11;
|
||||
req.version(11);
|
||||
req.insert("Host", host + ":" + std::to_string(port));
|
||||
req.insert("User-Agent", "test");
|
||||
req.method(beast::http::verb::get);
|
||||
req.method(boost::beast::http::verb::get);
|
||||
req.insert("Upgrade", "websocket");
|
||||
beast::websocket::detail::maskgen maskgen;
|
||||
beast::websocket::detail::sec_ws_key_type key;
|
||||
beast::websocket::detail::make_sec_ws_key(key, maskgen);
|
||||
boost::beast::websocket::detail::maskgen maskgen;
|
||||
boost::beast::websocket::detail::sec_ws_key_type key;
|
||||
boost::beast::websocket::detail::make_sec_ws_key(key, maskgen);
|
||||
req.insert("Sec-WebSocket-Key", key);
|
||||
req.insert("Sec-WebSocket-Version", "13");
|
||||
req.insert(beast::http::field::connection, "upgrade");
|
||||
req.insert(boost::beast::http::field::connection, "upgrade");
|
||||
return req;
|
||||
}
|
||||
|
||||
@@ -112,24 +112,24 @@ class ServerStatus_test :
|
||||
myFields const& fields)
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
request<string_body> req;
|
||||
|
||||
req.target("/");
|
||||
req.version = 11;
|
||||
req.version(11);
|
||||
for(auto const& f : fields)
|
||||
req.insert(f.name(), f.value());
|
||||
req.insert("Host", host + ":" + std::to_string(port));
|
||||
req.insert("User-Agent", "test");
|
||||
if(body.empty())
|
||||
{
|
||||
req.method(beast::http::verb::get);
|
||||
req.method(boost::beast::http::verb::get);
|
||||
}
|
||||
else
|
||||
{
|
||||
req.method(beast::http::verb::post);
|
||||
req.method(boost::beast::http::verb::post);
|
||||
req.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
req.body = body;
|
||||
req.body() = body;
|
||||
}
|
||||
req.prepare_payload();
|
||||
|
||||
@@ -139,18 +139,18 @@ class ServerStatus_test :
|
||||
void
|
||||
doRequest(
|
||||
boost::asio::yield_context& yield,
|
||||
beast::http::request<beast::http::string_body>&& req,
|
||||
boost::beast::http::request<boost::beast::http::string_body>&& req,
|
||||
std::string const& host,
|
||||
uint16_t port,
|
||||
bool secure,
|
||||
beast::http::response<beast::http::string_body>& resp,
|
||||
boost::beast::http::response<boost::beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
io_service& ios = get_io_service();
|
||||
ip::tcp::resolver r{ios};
|
||||
beast::multi_buffer sb;
|
||||
boost::beast::multi_buffer sb;
|
||||
|
||||
auto it =
|
||||
r.async_resolve(
|
||||
@@ -169,7 +169,7 @@ class ServerStatus_test :
|
||||
ss.async_handshake(ssl::stream_base::client, yield[ec]);
|
||||
if(ec)
|
||||
return;
|
||||
beast::http::async_write(ss, req, yield[ec]);
|
||||
boost::beast::http::async_write(ss, req, yield[ec]);
|
||||
if(ec)
|
||||
return;
|
||||
async_read(ss, sb, resp, yield[ec]);
|
||||
@@ -182,7 +182,7 @@ class ServerStatus_test :
|
||||
async_connect(sock, it, yield[ec]);
|
||||
if(ec)
|
||||
return;
|
||||
beast::http::async_write(sock, req, yield[ec]);
|
||||
boost::beast::http::async_write(sock, req, yield[ec]);
|
||||
if(ec)
|
||||
return;
|
||||
async_read(sock, sb, resp, yield[ec]);
|
||||
@@ -198,7 +198,7 @@ class ServerStatus_test :
|
||||
test::jtx::Env& env,
|
||||
boost::asio::yield_context& yield,
|
||||
bool secure,
|
||||
beast::http::response<beast::http::string_body>& resp,
|
||||
boost::beast::http::response<boost::beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
auto const port = env.app().config()["port_ws"].
|
||||
@@ -221,7 +221,7 @@ class ServerStatus_test :
|
||||
test::jtx::Env& env,
|
||||
boost::asio::yield_context& yield,
|
||||
bool secure,
|
||||
beast::http::response<beast::http::string_body>& resp,
|
||||
boost::beast::http::response<boost::beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec,
|
||||
std::string const& body = "",
|
||||
myFields const& fields = {})
|
||||
@@ -383,21 +383,21 @@ class ServerStatus_test :
|
||||
//non-secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
doWSRequest(env, yield, false, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::unauthorized);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::unauthorized);
|
||||
}
|
||||
|
||||
//secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
doWSRequest(env, yield, true, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::unauthorized);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::unauthorized);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,21 +416,21 @@ class ServerStatus_test :
|
||||
//non-secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
doHTTPRequest(env, yield, false, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::ok);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::ok);
|
||||
}
|
||||
|
||||
//secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
doHTTPRequest(env, yield, true, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::ok);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::ok);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ class ServerStatus_test :
|
||||
testcase("Partial WS upgrade request");
|
||||
using namespace jtx;
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
Env env {*this, envconfig([](std::unique_ptr<Config> cfg)
|
||||
{
|
||||
cfg->section("port_ws").set("protocol", "ws2");
|
||||
@@ -462,7 +462,7 @@ class ServerStatus_test :
|
||||
|
||||
io_service& ios = get_io_service();
|
||||
ip::tcp::resolver r{ios};
|
||||
beast::multi_buffer sb;
|
||||
boost::beast::multi_buffer sb;
|
||||
|
||||
auto it =
|
||||
r.async_resolve(
|
||||
@@ -497,7 +497,7 @@ class ServerStatus_test :
|
||||
using namespace jtx;
|
||||
Env env {*this, makeConfig(server_protocol)};
|
||||
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
if(boost::starts_with(client_protocol, "h"))
|
||||
{
|
||||
@@ -539,23 +539,23 @@ class ServerStatus_test :
|
||||
|
||||
Json::Value jr;
|
||||
jr[jss::method] = "server_info";
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
myFields auth;
|
||||
auth.insert("Authorization", "");
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
auth.set("Authorization", "Basic NOT-VALID");
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
auth.set("Authorization", "Basic " + beast::detail::base64_encode("me:badpass"));
|
||||
auth.set("Authorization", "Basic " + boost::beast::detail::base64_encode("me:badpass"));
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
auto const user = env.app().config().section("port_rpc").
|
||||
get<std::string>("user").value();
|
||||
@@ -565,14 +565,14 @@ class ServerStatus_test :
|
||||
// try with the correct user/pass, but not encoded
|
||||
auth.set("Authorization", "Basic " + user + ":" + pass);
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
// finally if we use the correct user/pass encoded, we should get a 200
|
||||
auth.set("Authorization", "Basic " +
|
||||
beast::detail::base64_encode(user + ":" + pass));
|
||||
boost::beast::detail::base64_encode(user + ":" + pass));
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::ok);
|
||||
BEAST_EXPECT(! resp.body.empty());
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::ok);
|
||||
BEAST_EXPECT(! resp.body().empty());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -582,7 +582,7 @@ class ServerStatus_test :
|
||||
|
||||
using namespace test::jtx;
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
Env env {*this, envconfig([&](std::unique_ptr<Config> cfg) {
|
||||
(*cfg)["port_rpc"].set("limit", to_string(limit));
|
||||
return cfg;
|
||||
@@ -606,7 +606,7 @@ class ServerStatus_test :
|
||||
ip::tcp::resolver::query{ip, to_string(port)}, yield[ec]);
|
||||
BEAST_EXPECT(! ec);
|
||||
|
||||
std::vector<std::pair<ip::tcp::socket, beast::multi_buffer>> clients;
|
||||
std::vector<std::pair<ip::tcp::socket, boost::beast::multi_buffer>> clients;
|
||||
int connectionCount {1}; //starts at 1 because the Env already has one
|
||||
//for JSONRPCCLient
|
||||
|
||||
@@ -619,7 +619,7 @@ class ServerStatus_test :
|
||||
while (connectionCount < testTo)
|
||||
{
|
||||
clients.emplace_back(
|
||||
std::make_pair(ip::tcp::socket {ios}, beast::multi_buffer{}));
|
||||
std::make_pair(ip::tcp::socket {ios}, boost::beast::multi_buffer{}));
|
||||
async_connect(clients.back().first, it, yield[ec]);
|
||||
BEAST_EXPECT(! ec);
|
||||
auto req = makeHTTPRequest(ip, port, to_string(jr), {});
|
||||
@@ -634,7 +634,7 @@ class ServerStatus_test :
|
||||
int readCount = 0;
|
||||
for (auto& c : clients)
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
async_read(c.first, c.second, resp, yield[ec]);
|
||||
++readCount;
|
||||
// expect the reads to fail for the clients that connected at or
|
||||
@@ -658,11 +658,11 @@ class ServerStatus_test :
|
||||
get<std::uint16_t>("port").value();
|
||||
auto const ip = env.app().config()["port_ws"].
|
||||
get<std::string>("ip").value();
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
doRequest(
|
||||
yield, makeWSUpgrade(ip, port), ip, port, true, resp, ec);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::switching_protocols);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::switching_protocols);
|
||||
BEAST_EXPECT(resp.find("Upgrade") != resp.end() &&
|
||||
resp["Upgrade"] == "websocket");
|
||||
BEAST_EXPECT(resp.find("Connection") != resp.end() &&
|
||||
@@ -681,14 +681,14 @@ class ServerStatus_test :
|
||||
get<std::uint16_t>("port").value();
|
||||
auto const ip = env.app().config()["port_ws"].
|
||||
get<std::string>("ip").value();
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
// body content is required here to avoid being
|
||||
// detected as a status request
|
||||
doRequest(yield,
|
||||
makeHTTPRequest(ip, port, "foo", {}), ip, port, false, resp, ec);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.body == "Forbidden\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
BEAST_EXPECT(resp.body() == "Forbidden\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -698,7 +698,7 @@ class ServerStatus_test :
|
||||
|
||||
using namespace test::jtx;
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
Env env {*this};
|
||||
|
||||
auto const port = env.app().config()["port_ws"].
|
||||
@@ -721,17 +721,17 @@ class ServerStatus_test :
|
||||
if(! BEAST_EXPECT(! ec))
|
||||
return;
|
||||
|
||||
beast::websocket::stream<boost::asio::ip::tcp::socket&> ws{sock};
|
||||
boost::beast::websocket::stream<boost::asio::ip::tcp::socket&> ws{sock};
|
||||
ws.handshake(ip + ":" + to_string(port), "/");
|
||||
|
||||
// helper lambda, used below
|
||||
auto sendAndParse = [&](std::string const& req) -> Json::Value
|
||||
{
|
||||
ws.async_write_frame(true, buffer(req), yield[ec]);
|
||||
ws.async_write_some(true, buffer(req), yield[ec]);
|
||||
if(! BEAST_EXPECT(! ec))
|
||||
return Json::objectValue;
|
||||
|
||||
beast::multi_buffer sb;
|
||||
boost::beast::multi_buffer sb;
|
||||
ws.async_read(sb, yield[ec]);
|
||||
if(! BEAST_EXPECT(! ec))
|
||||
return Json::objectValue;
|
||||
@@ -740,7 +740,7 @@ class ServerStatus_test :
|
||||
Json::Reader jr;
|
||||
if(! BEAST_EXPECT(jr.parse(
|
||||
boost::lexical_cast<std::string>(
|
||||
beast::buffers(sb.data())), resp)))
|
||||
boost::beast::buffers(sb.data())), resp)))
|
||||
return Json::objectValue;
|
||||
sb.consume(sb.size());
|
||||
return resp;
|
||||
@@ -782,7 +782,7 @@ class ServerStatus_test :
|
||||
testcase("Status request over WS and RPC with/without Amendment Block");
|
||||
using namespace jtx;
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
using namespace boost::beast::http;
|
||||
Env env {*this, validator( envconfig([](std::unique_ptr<Config> cfg)
|
||||
{
|
||||
cfg->section("port_rpc").set("protocol", "http");
|
||||
@@ -823,9 +823,9 @@ class ServerStatus_test :
|
||||
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::ok);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::ok);
|
||||
BEAST_EXPECT(
|
||||
resp.body.find("connectivity is working.") != std::string::npos);
|
||||
resp.body().find("connectivity is working.") != std::string::npos);
|
||||
|
||||
// mark the Network as Amendment Blocked, but still won't fail until
|
||||
// ELB is enabled (next step)
|
||||
@@ -855,9 +855,9 @@ class ServerStatus_test :
|
||||
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::ok);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::ok);
|
||||
BEAST_EXPECT(
|
||||
resp.body.find("connectivity is working.") != std::string::npos);
|
||||
resp.body().find("connectivity is working.") != std::string::npos);
|
||||
|
||||
env.app().config().ELB_SUPPORT = true;
|
||||
|
||||
@@ -872,11 +872,11 @@ class ServerStatus_test :
|
||||
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::internal_server_error);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::internal_server_error);
|
||||
BEAST_EXPECT(
|
||||
resp.body.find("cannot accept clients:") != std::string::npos);
|
||||
resp.body().find("cannot accept clients:") != std::string::npos);
|
||||
BEAST_EXPECT(
|
||||
resp.body.find("Server version too old") != std::string::npos);
|
||||
resp.body().find("Server version too old") != std::string::npos);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -889,103 +889,103 @@ class ServerStatus_test :
|
||||
|
||||
boost::system::error_code ec;
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
doHTTPRequest(env, yield, false, resp, ec, "{}");
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Unable to parse request: \r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Unable to parse request: \r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv;
|
||||
jv["invalid"] = 1;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Null method\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Null method\r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv(Json::arrayValue);
|
||||
jv.append("invalid");
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Unable to parse request: \r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Unable to parse request: \r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv(Json::arrayValue);
|
||||
Json::Value j;
|
||||
j["invalid"] = 1;
|
||||
jv.append(j);
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Unable to parse request: \r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Unable to parse request: \r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv;
|
||||
jv[jss::method] = "batch";
|
||||
jv[jss::params] = 2;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Malformed batch request\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Malformed batch request\r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv;
|
||||
jv[jss::method] = "batch";
|
||||
jv[jss::params] = Json::objectValue;
|
||||
jv[jss::params]["invalid"] = 3;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Malformed batch request\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Malformed batch request\r\n");
|
||||
}
|
||||
|
||||
Json::Value jv;
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::method] = Json::nullValue;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "Null method\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Null method\r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::method] = 1;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "method is not string\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "method is not string\r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::method] = "";
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "method is empty\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "method is empty\r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::method] = "some_method";
|
||||
jv[jss::params] = "params";
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "params unparseable\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "params unparseable\r\n");
|
||||
}
|
||||
|
||||
{
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::params] = Json::arrayValue;
|
||||
jv[jss::params][0u] = "not an object";
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body == "params unparseable\r\n");
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "params unparseable\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,12 +1003,12 @@ class ServerStatus_test :
|
||||
//raise the fee so that the server is considered overloaded
|
||||
env.app().getFeeTrack().raiseLocalFee();
|
||||
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
doHTTPRequest(env, yield, false, resp, ec);
|
||||
BEAST_EXPECT(resp.result() == beast::http::status::internal_server_error);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::internal_server_error);
|
||||
std::regex body {"Server cannot accept clients"};
|
||||
BEAST_EXPECT(std::regex_search(resp.body, body));
|
||||
BEAST_EXPECT(std::regex_search(resp.body(), body));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef TEST_UNIT_TEST_MULTI_RUNNER_H
|
||||
#define TEST_UNIT_TEST_MULTI_RUNNER_H
|
||||
|
||||
#include <beast/include/beast/core/static_string.hpp>
|
||||
#include <boost/beast/core/static_string.hpp>
|
||||
#include <beast/unit_test/global_suites.hpp>
|
||||
#include <beast/unit_test/runner.hpp>
|
||||
|
||||
@@ -78,7 +78,7 @@ struct suite_results
|
||||
|
||||
struct results
|
||||
{
|
||||
using static_string = beast::static_string<256>;
|
||||
using static_string = boost::beast::static_string<256>;
|
||||
// results may be stored in shared memory. Use `static_string` to ensure
|
||||
// pointers from different memory spaces do not co-mingle
|
||||
using run_time = std::pair<static_string, typename clock_type::duration>;
|
||||
|
||||
Reference in New Issue
Block a user