mirror of
https://github.com/XRPLF/clio.git
synced 2026-08-21 12:40:51 +00:00
chore: Merge develop into release/2.8.0 (#3186)
This commit is contained in:
@@ -363,7 +363,7 @@ CustomValidator CustomValidators::authorizeCredentialValidator =
|
||||
}
|
||||
|
||||
// don't want to change issuer error message to be about credentials
|
||||
if (!issuerValidator.verify(credObj, "issuer")) {
|
||||
if (!accountBase58Validator.verify(credObj, "issuer")) {
|
||||
return Error{
|
||||
Status{ClioError::RpcMalformedAuthorizedCredentials, "issuer NotString"}
|
||||
};
|
||||
|
||||
@@ -590,7 +590,8 @@ struct CustomValidators final {
|
||||
/**
|
||||
* @brief Provides a validator for validating credential_type.
|
||||
*
|
||||
* Used by AuthorizeCredentialValidator in deposit_preauth.
|
||||
* Used by AuthorizeCredentialValidator in deposit_preauth and by the credential
|
||||
* object lookup in ledger_entry.
|
||||
*/
|
||||
static CustomValidator credentialTypeValidator;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <boost/json/object.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <xrpl/basics/Blob.h>
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
@@ -32,6 +33,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
@@ -422,20 +424,23 @@ tag_invoke(boost::json::value_to_tag<LedgerEntryHandler::Input>, boost::json::va
|
||||
return xrpl::keylet::oracle(*account, documentId).key;
|
||||
};
|
||||
|
||||
auto const parseCredentialFromJson = [](boost::json::value const& json) {
|
||||
auto const parseCredentialFromJson =
|
||||
[](boost::json::value const& json) -> std::optional<xrpl::uint256> {
|
||||
auto const subject = util::parseBase58Wrapper<xrpl::AccountID>(
|
||||
boost::json::value_to<std::string>(json.at(JS(subject)))
|
||||
);
|
||||
auto const issuer = util::parseBase58Wrapper<xrpl::AccountID>(
|
||||
boost::json::value_to<std::string>(json.at(JS(issuer)))
|
||||
);
|
||||
auto const credType =
|
||||
auto const credTypeOpt =
|
||||
xrpl::strUnHex(boost::json::value_to<std::string>(json.at(JS(credential_type))));
|
||||
|
||||
return xrpl::keylet::credential(
|
||||
*subject, *issuer, xrpl::Slice(credType->data(), credType->size())
|
||||
)
|
||||
.key;
|
||||
return credTypeOpt.transform([&](xrpl::Blob const& credType) -> xrpl::uint256 {
|
||||
return xrpl::keylet::credential(
|
||||
*subject, *issuer, xrpl::Slice(credType.data(), credType.size())
|
||||
)
|
||||
.key;
|
||||
});
|
||||
};
|
||||
|
||||
auto const indexFieldType =
|
||||
|
||||
@@ -380,6 +380,7 @@ public:
|
||||
meta::WithCustomError{
|
||||
validation::Type<std::string>{}, Status(ClioError::RpcMalformedRequest)
|
||||
},
|
||||
validation::CustomValidators::credentialTypeValidator,
|
||||
},
|
||||
}}},
|
||||
{JS(mpt_issuance),
|
||||
|
||||
@@ -347,6 +347,27 @@ generateTestValuesForParametersTest()
|
||||
.expectedErrorMessage = "issuer NotString"
|
||||
},
|
||||
|
||||
ParamTestCaseBundle{
|
||||
.testName = "DepositPreauthAuthorizeCredentialsHexIssuer",
|
||||
.testJson = fmt::format(
|
||||
R"JSON({{
|
||||
"deposit_preauth": {{
|
||||
"owner": "{}",
|
||||
"authorized_credentials": [
|
||||
{{
|
||||
"issuer": "0000000000000000000000000000000000000002",
|
||||
"credential_type": "{}"
|
||||
}}
|
||||
]
|
||||
}}
|
||||
}})JSON",
|
||||
kAccount,
|
||||
kCredentialType
|
||||
),
|
||||
.expectedError = "malformedAuthorizedCredentials",
|
||||
.expectedErrorMessage = "issuer NotString"
|
||||
},
|
||||
|
||||
ParamTestCaseBundle{
|
||||
.testName = "DepositPreauthAuthorizeCredentialsIncorrectCredentialType",
|
||||
.testJson = fmt::format(
|
||||
|
||||
Reference in New Issue
Block a user