mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 11:45:53 +00:00
@@ -202,16 +202,21 @@ CustomValidator IssuerValidator =
|
||||
|
||||
CustomValidator SubscribeStreamValidator =
|
||||
CustomValidator{[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
static std::unordered_set<std::string> const validStreams = {
|
||||
"ledger", "transactions", "transactions_proposed", "book_changes", "manifests", "validations"};
|
||||
if (!value.is_array())
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotArray"}};
|
||||
|
||||
static std::unordered_set<std::string> const validStreams = {
|
||||
"ledger", "transactions", "transactions_proposed", "book_changes", "manifests", "validations"};
|
||||
|
||||
static std::unordered_set<std::string> const reportingNotSupportStreams = {"peer_status", "consensus"};
|
||||
for (auto const& v : value.as_array())
|
||||
{
|
||||
if (!v.is_string())
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "streamNotString"}};
|
||||
|
||||
if (reportingNotSupportStreams.contains(v.as_string().c_str()))
|
||||
return Error{Status{RippledError::rpcREPORTING_UNSUPPORTED}};
|
||||
|
||||
if (not validStreams.contains(v.as_string().c_str()))
|
||||
return Error{Status{RippledError::rpcSTREAM_MALFORMED}};
|
||||
}
|
||||
|
||||
@@ -126,6 +126,16 @@ generateTestValuesForParametersTest()
|
||||
SubscribeParamTestCaseBundle{"StreamsNotArray", R"({"streams": 1})", "invalidParams", "streamsNotArray"},
|
||||
SubscribeParamTestCaseBundle{"StreamNotString", R"({"streams": [1]})", "invalidParams", "streamNotString"},
|
||||
SubscribeParamTestCaseBundle{"StreamNotValid", R"({"streams": ["1"]})", "malformedStream", "Stream malformed."},
|
||||
SubscribeParamTestCaseBundle{
|
||||
"StreamPeerStatusNotSupport",
|
||||
R"({"streams": ["peer_status"]})",
|
||||
"reportingUnsupported",
|
||||
"Requested operation not supported by reporting mode server"},
|
||||
SubscribeParamTestCaseBundle{
|
||||
"StreamConsensusNotSupport",
|
||||
R"({"streams": ["consensus"]})",
|
||||
"reportingUnsupported",
|
||||
"Requested operation not supported by reporting mode server"},
|
||||
SubscribeParamTestCaseBundle{"BooksNotArray", R"({"books": "1"})", "invalidParams", "booksNotArray"},
|
||||
SubscribeParamTestCaseBundle{
|
||||
"BooksItemNotObject", R"({"books": ["1"]})", "invalidParams", "booksItemNotObject"},
|
||||
|
||||
Reference in New Issue
Block a user