mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 06:40:53 +00:00
fix: Validate account/ident type in gateway_balances (#7655)
This commit is contained in:
committed by
GitHub
parent
c74724a719
commit
d43e5acaa7
@@ -176,6 +176,45 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
testGWBInvalidAccount(FeatureBitset features)
|
||||
{
|
||||
testcase("Gateway Balances with non-string account/ident");
|
||||
using namespace std::chrono_literals;
|
||||
using namespace jtx;
|
||||
Env env(*this, features);
|
||||
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
env.close();
|
||||
|
||||
auto wsc = makeWSClient(env.app().config());
|
||||
|
||||
// A non-string "account" must be rejected cleanly with invalidParams
|
||||
// rather than throwing a Json::LogicError that surfaces as internal.
|
||||
json::Value qry;
|
||||
qry[jss::account] = 42;
|
||||
qry[jss::hotwallet] = alice.human();
|
||||
|
||||
forAllApiVersions([&, this](unsigned apiVersion) {
|
||||
qry[jss::api_version] = apiVersion;
|
||||
auto jv = wsc->invoke("gateway_balances", qry);
|
||||
expect(jv[jss::status] == "error");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error] == "invalidParams");
|
||||
});
|
||||
|
||||
// The same applies to a non-string "ident".
|
||||
json::Value qry2;
|
||||
qry2[jss::ident] = 42;
|
||||
|
||||
forAllApiVersions([&, this](unsigned apiVersion) {
|
||||
qry2[jss::api_version] = apiVersion;
|
||||
auto jv = wsc->invoke("gateway_balances", qry2);
|
||||
expect(jv[jss::status] == "error");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error] == "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
testGWBOverflow()
|
||||
{
|
||||
@@ -280,6 +319,7 @@ public:
|
||||
{
|
||||
testGWB(feature);
|
||||
testGWBApiVersions(feature);
|
||||
testGWBInvalidAccount(feature);
|
||||
}
|
||||
testGWBWithMPT();
|
||||
testGWBOverflow();
|
||||
|
||||
Reference in New Issue
Block a user