mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-31 02:50:24 +00:00
refactor: Enable clang-tidy readability-identifier-naming check (#6571)
This commit is contained in:
@@ -46,26 +46,26 @@
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
class ServerStatus_test : public beast::unit_test::suite, public beast::test::enable_yield_to
|
||||
class ServerStatus_test : public beast::unit_test::Suite, public beast::test::EnableYieldTo
|
||||
{
|
||||
class myFields : public boost::beast::http::fields
|
||||
class MyFields : public boost::beast::http::fields
|
||||
{
|
||||
};
|
||||
|
||||
static auto
|
||||
makeConfig(std::string const& proto, bool admin = true, bool credentials = false)
|
||||
{
|
||||
auto const section_name = boost::starts_with(proto, "h") ? "port_rpc" : "port_ws";
|
||||
auto const sectionName = boost::starts_with(proto, "h") ? "port_rpc" : "port_ws";
|
||||
auto p = jtx::envconfig();
|
||||
|
||||
p->overwrite(section_name, "protocol", proto);
|
||||
p->overwrite(sectionName, "protocol", proto);
|
||||
if (!admin)
|
||||
p->overwrite(section_name, "admin", "");
|
||||
p->overwrite(sectionName, "admin", "");
|
||||
|
||||
if (credentials)
|
||||
{
|
||||
(*p)[section_name].set("admin_password", "p");
|
||||
(*p)[section_name].set("admin_user", "u");
|
||||
(*p)[sectionName].set("admin_password", "p");
|
||||
(*p)[sectionName].set("admin_user", "u");
|
||||
}
|
||||
|
||||
p->overwrite(
|
||||
@@ -109,7 +109,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
std::array<std::uint8_t, 16> key{};
|
||||
for (auto& v : key)
|
||||
v = d(e);
|
||||
req.insert("Sec-WebSocket-Key", base64_encode(key.data(), key.size()));
|
||||
req.insert("Sec-WebSocket-Key", base64Encode(key.data(), key.size()));
|
||||
};
|
||||
req.insert("Sec-WebSocket-Version", "13");
|
||||
req.insert(boost::beast::http::field::connection, "upgrade");
|
||||
@@ -121,7 +121,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
std::string const& host,
|
||||
uint16_t port,
|
||||
std::string const& body,
|
||||
myFields const& fields)
|
||||
MyFields const& fields)
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace boost::beast::http;
|
||||
@@ -160,7 +160,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace boost::beast::http;
|
||||
io_context& ios = get_io_context();
|
||||
io_context& ios = getIoContext();
|
||||
ip::tcp::resolver r{ios};
|
||||
boost::beast::multi_buffer sb;
|
||||
|
||||
@@ -227,7 +227,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
boost::beast::http::response<boost::beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec,
|
||||
std::string const& body = "",
|
||||
myFields const& fields = {})
|
||||
MyFields const& fields = {})
|
||||
{
|
||||
auto const port = env.app().config()["port_rpc"].get<std::uint16_t>("port");
|
||||
auto const ip = env.app().config()["port_rpc"].get<std::string>("ip");
|
||||
@@ -244,16 +244,16 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
std::string const& password,
|
||||
bool subobject = false)
|
||||
{
|
||||
Json::Value jrr;
|
||||
json::Value jrr;
|
||||
|
||||
Json::Value jp = Json::objectValue;
|
||||
json::Value jp = json::ObjectValue;
|
||||
if (!user.empty())
|
||||
{
|
||||
jp["admin_user"] = user;
|
||||
if (subobject)
|
||||
{
|
||||
// special case of bad password..passed as object
|
||||
Json::Value jpi = Json::objectValue;
|
||||
json::Value jpi = json::ObjectValue;
|
||||
jpi["admin_password"] = password;
|
||||
jp["admin_password"] = jpi;
|
||||
}
|
||||
@@ -290,8 +290,8 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
using namespace jtx;
|
||||
Env env{*this, makeConfig(proto, admin, credentials)};
|
||||
|
||||
Json::Value jrr;
|
||||
auto const proto_ws = boost::starts_with(proto, "w");
|
||||
json::Value jrr;
|
||||
auto const protoWs = boost::starts_with(proto, "w");
|
||||
|
||||
// the set of checks we do are different depending
|
||||
// on how the admin config options are set
|
||||
@@ -299,43 +299,42 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
if (admin && credentials)
|
||||
{
|
||||
auto const user =
|
||||
env.app().config()[proto_ws ? "port_ws" : "port_rpc"].get<std::string>(
|
||||
"admin_user");
|
||||
env.app().config()[protoWs ? "port_ws" : "port_rpc"].get<std::string>("admin_user");
|
||||
|
||||
auto const password =
|
||||
env.app().config()[proto_ws ? "port_ws" : "port_rpc"].get<std::string>(
|
||||
env.app().config()[protoWs ? "port_ws" : "port_rpc"].get<std::string>(
|
||||
"admin_password");
|
||||
|
||||
// 1 - FAILS with wrong pass
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
jrr = makeAdminRequest(env, proto, *user, *password + "_")[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == proto_ws ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == proto_ws ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
|
||||
// 2 - FAILS with password in an object
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
jrr = makeAdminRequest(env, proto, *user, *password, true)[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == proto_ws ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == proto_ws ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
|
||||
// 3 - FAILS with wrong user
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
jrr = makeAdminRequest(env, proto, *user + "_", *password)[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == proto_ws ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == proto_ws ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
|
||||
// 4 - FAILS no credentials
|
||||
jrr = makeAdminRequest(env, proto, "", "")[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == proto_ws ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == proto_ws ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
|
||||
// 5 - SUCCEEDS with proper credentials
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
@@ -356,10 +355,10 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
{
|
||||
// 1 - FAILS - admin disabled
|
||||
jrr = makeAdminRequest(env, proto, "", "")[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == proto_ws ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == proto_ws ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,10 +445,10 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
auto req = makeWSUpgrade(*ip, *port); // NOLINT(bugprone-unchecked-optional-access)
|
||||
|
||||
// truncate the request message to near the value of the version header
|
||||
auto req_string = boost::lexical_cast<std::string>(req);
|
||||
req_string.erase(req_string.find_last_of("13"), std::string::npos);
|
||||
auto reqString = boost::lexical_cast<std::string>(req);
|
||||
reqString.erase(reqString.find_last_of("13"), std::string::npos);
|
||||
|
||||
io_context& ios = get_io_context();
|
||||
io_context& ios = getIoContext();
|
||||
ip::tcp::resolver r{ios};
|
||||
boost::beast::multi_buffer sb;
|
||||
|
||||
@@ -462,7 +461,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
async_connect(sock, it, yield[ec]);
|
||||
if (!BEAST_EXPECTS(!ec, ec.message()))
|
||||
return;
|
||||
async_write(sock, boost::asio::buffer(req_string), yield[ec]);
|
||||
async_write(sock, boost::asio::buffer(reqString), yield[ec]);
|
||||
if (!BEAST_EXPECTS(!ec, ec.message()))
|
||||
return;
|
||||
// since we've sent an incomplete request, the server will
|
||||
@@ -473,29 +472,28 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
void
|
||||
testCantConnect(
|
||||
std::string const& client_protocol,
|
||||
std::string const& server_protocol,
|
||||
std::string const& clientProtocol,
|
||||
std::string const& serverProtocol,
|
||||
boost::asio::yield_context& yield)
|
||||
{
|
||||
// The essence of this test is to have a client and server configured
|
||||
// out-of-phase with respect to ssl (secure client and insecure server
|
||||
// or vice-versa)
|
||||
testcase << "Connect fails: " << client_protocol << " client to " << server_protocol
|
||||
testcase << "Connect fails: " << clientProtocol << " client to " << serverProtocol
|
||||
<< " server";
|
||||
using namespace jtx;
|
||||
Env env{*this, makeConfig(server_protocol)};
|
||||
Env env{*this, makeConfig(serverProtocol)};
|
||||
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
if (boost::starts_with(client_protocol, "h"))
|
||||
if (boost::starts_with(clientProtocol, "h"))
|
||||
{
|
||||
doHTTPRequest(env, yield, client_protocol == "https", resp, ec);
|
||||
doHTTPRequest(env, yield, clientProtocol == "https", resp, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
}
|
||||
else
|
||||
{
|
||||
doWSRequest(
|
||||
env, yield, client_protocol == "wss" || client_protocol == "wss2", resp, ec);
|
||||
doWSRequest(env, yield, clientProtocol == "wss" || clientProtocol == "wss2", resp, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
}
|
||||
}
|
||||
@@ -515,14 +513,14 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
Json::Value jr;
|
||||
json::Value jr;
|
||||
jr[jss::method] = "server_info";
|
||||
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() == boost::beast::http::status::forbidden);
|
||||
|
||||
myFields auth;
|
||||
MyFields auth;
|
||||
auth.insert("Authorization", "");
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
@@ -531,7 +529,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
auth.set("Authorization", "Basic " + base64_encode("me:badpass"));
|
||||
auth.set("Authorization", "Basic " + base64Encode("me:badpass"));
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::forbidden);
|
||||
|
||||
@@ -547,7 +545,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
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 " + base64_encode(user + ":" + pass));
|
||||
auth.set("Authorization", "Basic " + base64Encode(user + ":" + pass));
|
||||
doHTTPRequest(env, yield, secure, resp, ec, to_string(jr), auth);
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::ok);
|
||||
BEAST_EXPECT(!resp.body().empty());
|
||||
@@ -573,10 +571,10 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
auto const ip = env.app().config()["port_rpc"].get<std::string>("ip").value();
|
||||
|
||||
boost::system::error_code ec;
|
||||
io_context& ios = get_io_context();
|
||||
io_context& ios = getIoContext();
|
||||
ip::tcp::resolver r{ios};
|
||||
|
||||
Json::Value jr;
|
||||
json::Value jr;
|
||||
jr[jss::method] = "server_info";
|
||||
|
||||
auto it = r.async_resolve(ip, std::to_string(port), yield[ec]);
|
||||
@@ -675,7 +673,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
auto const ip = env.app().config()["port_ws"].get<std::string>("ip").value();
|
||||
boost::system::error_code ec;
|
||||
|
||||
io_context& ios = get_io_context();
|
||||
io_context& ios = getIoContext();
|
||||
ip::tcp::resolver r{ios};
|
||||
|
||||
auto it = r.async_resolve(ip, std::to_string(port), yield[ec]);
|
||||
@@ -691,22 +689,22 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
ws.handshake(ip + ":" + std::to_string(port), "/");
|
||||
|
||||
// helper lambda, used below
|
||||
auto sendAndParse = [&](std::string const& req) -> Json::Value {
|
||||
auto sendAndParse = [&](std::string const& req) -> json::Value {
|
||||
ws.async_write_some(true, buffer(req), yield[ec]);
|
||||
if (!BEAST_EXPECT(!ec))
|
||||
return Json::objectValue;
|
||||
return json::ObjectValue;
|
||||
|
||||
boost::beast::multi_buffer sb;
|
||||
ws.async_read(sb, yield[ec]);
|
||||
if (!BEAST_EXPECT(!ec))
|
||||
return Json::objectValue;
|
||||
return json::ObjectValue;
|
||||
|
||||
Json::Value resp;
|
||||
Json::Reader jr;
|
||||
json::Value resp;
|
||||
json::Reader jr;
|
||||
if (!BEAST_EXPECT(jr.parse(
|
||||
boost::lexical_cast<std::string>(boost::beast::make_printable(sb.data())),
|
||||
resp)))
|
||||
return Json::objectValue;
|
||||
return json::ObjectValue;
|
||||
sb.consume(sb.size());
|
||||
return resp;
|
||||
};
|
||||
@@ -718,7 +716,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
}
|
||||
|
||||
{ // send incorrect json (method and command fields differ)
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::command] = "foo";
|
||||
jv[jss::method] = "bar";
|
||||
auto resp = sendAndParse(to_string(jv));
|
||||
@@ -727,7 +725,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
}
|
||||
|
||||
{ // send a ping (not an error)
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::command] = "ping";
|
||||
auto resp = sendAndParse(to_string(jv));
|
||||
BEAST_EXPECT(resp.isMember(jss::status) && resp[jss::status] == "success");
|
||||
@@ -776,8 +774,8 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
BEAST_EXPECT(env.app().getOPs().getConsensusInfo()["validating"] == true);
|
||||
BEAST_EXPECT(!si[jss::state].isMember(jss::warnings));
|
||||
|
||||
auto const port_ws = env.app().config()["port_ws"].get<std::uint16_t>("port");
|
||||
auto const ip_ws = env.app().config()["port_ws"].get<std::string>("ip");
|
||||
auto const portWs = env.app().config()["port_ws"].get<std::uint16_t>("port");
|
||||
auto const ipWs = env.app().config()["port_ws"].get<std::string>("ip");
|
||||
|
||||
boost::system::error_code ec;
|
||||
response<string_body> resp;
|
||||
@@ -785,11 +783,11 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
doRequest(
|
||||
yield,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
makeHTTPRequest(*ip_ws, *port_ws, "", {}),
|
||||
makeHTTPRequest(*ipWs, *portWs, "", {}),
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*ip_ws,
|
||||
*ipWs,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*port_ws,
|
||||
*portWs,
|
||||
false,
|
||||
resp,
|
||||
ec);
|
||||
@@ -814,7 +812,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
BEAST_EXPECT(
|
||||
si[jss::info].isMember(jss::warnings) && si[jss::info][jss::warnings].isArray() &&
|
||||
si[jss::info][jss::warnings].size() == 1 &&
|
||||
si[jss::info][jss::warnings][0u][jss::id].asInt() == warnRPC_UNSUPPORTED_MAJORITY);
|
||||
si[jss::info][jss::warnings][0u][jss::id].asInt() == WarnRpcUnsupportedMajority);
|
||||
|
||||
// RPC request server_state again, now unsupported majority should be
|
||||
// returned
|
||||
@@ -824,17 +822,17 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
BEAST_EXPECT(
|
||||
si[jss::state].isMember(jss::warnings) && si[jss::state][jss::warnings].isArray() &&
|
||||
si[jss::state][jss::warnings].size() == 1 &&
|
||||
si[jss::state][jss::warnings][0u][jss::id].asInt() == warnRPC_UNSUPPORTED_MAJORITY);
|
||||
si[jss::state][jss::warnings][0u][jss::id].asInt() == WarnRpcUnsupportedMajority);
|
||||
|
||||
// but status does not indicate a problem
|
||||
doRequest(
|
||||
yield,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
makeHTTPRequest(*ip_ws, *port_ws, "", {}),
|
||||
makeHTTPRequest(*ipWs, *portWs, "", {}),
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*ip_ws,
|
||||
*ipWs,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*port_ws,
|
||||
*portWs,
|
||||
false,
|
||||
resp,
|
||||
ec);
|
||||
@@ -850,11 +848,11 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
doRequest(
|
||||
yield,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
makeHTTPRequest(*ip_ws, *port_ws, "", {}),
|
||||
makeHTTPRequest(*ipWs, *portWs, "", {}),
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*ip_ws,
|
||||
*ipWs,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*port_ws,
|
||||
*portWs,
|
||||
false,
|
||||
resp,
|
||||
ec);
|
||||
@@ -904,8 +902,8 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
BEAST_EXPECT(env.app().getOPs().getConsensusInfo()["validating"] == true);
|
||||
BEAST_EXPECT(!si[jss::state].isMember(jss::warnings));
|
||||
|
||||
auto const port_ws = env.app().config()["port_ws"].get<std::uint16_t>("port");
|
||||
auto const ip_ws = env.app().config()["port_ws"].get<std::string>("ip");
|
||||
auto const portWs = env.app().config()["port_ws"].get<std::uint16_t>("port");
|
||||
auto const ipWs = env.app().config()["port_ws"].get<std::string>("ip");
|
||||
|
||||
boost::system::error_code ec;
|
||||
response<string_body> resp;
|
||||
@@ -913,11 +911,11 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
doRequest(
|
||||
yield,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
makeHTTPRequest(*ip_ws, *port_ws, "", {}),
|
||||
makeHTTPRequest(*ipWs, *portWs, "", {}),
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*ip_ws,
|
||||
*ipWs,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*port_ws,
|
||||
*portWs,
|
||||
false,
|
||||
resp,
|
||||
ec);
|
||||
@@ -944,7 +942,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
BEAST_EXPECT(
|
||||
si[jss::info].isMember(jss::warnings) && si[jss::info][jss::warnings].isArray() &&
|
||||
si[jss::info][jss::warnings].size() == 1 &&
|
||||
si[jss::info][jss::warnings][0u][jss::id].asInt() == warnRPC_AMENDMENT_BLOCKED);
|
||||
si[jss::info][jss::warnings][0u][jss::id].asInt() == WarnRpcAmendmentBlocked);
|
||||
|
||||
// RPC request server_state again, now AB should be returned
|
||||
si = env.rpc("server_state")[jss::result];
|
||||
@@ -954,18 +952,18 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
BEAST_EXPECT(
|
||||
si[jss::state].isMember(jss::warnings) && si[jss::state][jss::warnings].isArray() &&
|
||||
si[jss::state][jss::warnings].size() == 1 &&
|
||||
si[jss::state][jss::warnings][0u][jss::id].asInt() == warnRPC_AMENDMENT_BLOCKED);
|
||||
si[jss::state][jss::warnings][0u][jss::id].asInt() == WarnRpcAmendmentBlocked);
|
||||
|
||||
// but status does not indicate because it still relies on ELB
|
||||
// being enabled
|
||||
doRequest(
|
||||
yield,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
makeHTTPRequest(*ip_ws, *port_ws, "", {}),
|
||||
makeHTTPRequest(*ipWs, *portWs, "", {}),
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*ip_ws,
|
||||
*ipWs,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*port_ws,
|
||||
*portWs,
|
||||
false,
|
||||
resp,
|
||||
ec);
|
||||
@@ -980,11 +978,11 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
doRequest(
|
||||
yield,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
makeHTTPRequest(*ip_ws, *port_ws, "", {}),
|
||||
makeHTTPRequest(*ipWs, *portWs, "", {}),
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*ip_ws,
|
||||
*ipWs,
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
*port_ws,
|
||||
*portWs,
|
||||
false,
|
||||
resp,
|
||||
ec);
|
||||
@@ -1014,7 +1012,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv["invalid"] = 1;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
@@ -1023,7 +1021,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv(Json::arrayValue);
|
||||
json::Value jv(json::ArrayValue);
|
||||
jv.append("invalid");
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
@@ -1032,8 +1030,8 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv(Json::arrayValue);
|
||||
Json::Value j;
|
||||
json::Value jv(json::ArrayValue);
|
||||
json::Value j;
|
||||
j["invalid"] = 1;
|
||||
jv.append(j);
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
@@ -1043,7 +1041,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::method] = "batch";
|
||||
jv[jss::params] = 2;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
@@ -1053,19 +1051,19 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::method] = "batch";
|
||||
jv[jss::params] = Json::objectValue;
|
||||
jv[jss::params] = json::ObjectValue;
|
||||
jv[jss::params]["invalid"] = 3;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Malformed batch request\r\n");
|
||||
}
|
||||
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::method] = Json::nullValue;
|
||||
jv[jss::method] = json::NullValue;
|
||||
doHTTPRequest(env, yield, false, resp, ec, to_string(jv));
|
||||
BEAST_EXPECT(resp.result() == boost::beast::http::status::bad_request);
|
||||
BEAST_EXPECT(resp.body() == "Null method\r\n");
|
||||
@@ -1098,7 +1096,7 @@ class ServerStatus_test : public beast::unit_test::suite, public beast::test::en
|
||||
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
jv[jss::params] = Json::arrayValue;
|
||||
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() == boost::beast::http::status::bad_request);
|
||||
@@ -1139,7 +1137,7 @@ public:
|
||||
testAdminRequest(it, false, false);
|
||||
}
|
||||
|
||||
yield_to([&](boost::asio::yield_context& yield) {
|
||||
yieldTo([&](boost::asio::yield_context& yield) {
|
||||
testWSClientToHttpServer(yield);
|
||||
testStatusRequest(yield);
|
||||
testTruncatedWSUpgrade(yield);
|
||||
|
||||
Reference in New Issue
Block a user