diff --git a/src/rpc/common/Validators.cpp b/src/rpc/common/Validators.cpp index 47ea3e413..2597ea61a 100644 --- a/src/rpc/common/Validators.cpp +++ b/src/rpc/common/Validators.cpp @@ -258,7 +258,7 @@ CustomValidator CustomValidators::CurrencyIssueValidator = CustomValidator CustomValidators::CredentialTypeValidator = CustomValidator{[](boost::json::value const& value, std::string_view key) -> MaybeError { if (not value.is_string()) - return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + " NotString"}}; + return Error{Status{ClioError::rpcMALFORMED_AUTHORIZED_CREDENTIALS, std::string(key) + " NotString"}}; auto const& credTypeHex = ripple::strViewUnHex(value.as_string()); if (!credTypeHex.has_value()) @@ -302,14 +302,18 @@ CustomValidator CustomValidators::AuthorizeCredentialValidator = auto const& obj = credObj.as_object(); if (!obj.contains("issuer")) - return Error{Status{ClioError::rpcMALFORMED_REQUEST, "Field 'Issuer' is required but missing."}}; + return Error{ + Status{ClioError::rpcMALFORMED_AUTHORIZED_CREDENTIALS, "Field 'Issuer' is required but missing."} + }; - if (auto const err = IssuerValidator.verify(credObj, "issuer"); !err) - return err; + // don't want to change issuer error message to be about credentials + if (!IssuerValidator.verify(credObj, "issuer")) + return Error{Status{ClioError::rpcMALFORMED_AUTHORIZED_CREDENTIALS, "issuer NotString"}}; if (!obj.contains("credential_type")) { - return Error{Status{ClioError::rpcMALFORMED_REQUEST, "Field 'CredentialType' is required but missing."} - }; + return Error{Status{ + ClioError::rpcMALFORMED_AUTHORIZED_CREDENTIALS, "Field 'CredentialType' is required but missing." + }}; } if (auto const err = CredentialTypeValidator.verify(credObj, "credential_type"); !err) diff --git a/tests/unit/rpc/handlers/LedgerEntryTests.cpp b/tests/unit/rpc/handlers/LedgerEntryTests.cpp index f8528cef9..82d1396e7 100644 --- a/tests/unit/rpc/handlers/LedgerEntryTests.cpp +++ b/tests/unit/rpc/handlers/LedgerEntryTests.cpp @@ -292,7 +292,7 @@ generateTestValuesForParametersTest() ACCOUNT, ACCOUNT2 ), - "malformedRequest", + "malformedAuthorizedCredentials", "Field 'CredentialType' is required but missing." }, @@ -312,10 +312,31 @@ generateTestValuesForParametersTest() ACCOUNT, CREDENTIALTYPE ), - "malformedRequest", + "malformedAuthorizedCredentials", "Field 'Issuer' is required but missing." }, + ParamTestCaseBundle{ + "DepositPreauthAuthorizeCredentialsIncorrectIssuerType", + fmt::format( + R"({{ + "deposit_preauth": {{ + "owner": "{}", + "authorized_credentials": [ + {{ + "issuer": 123, + "credential_type": "{}" + }} + ] + }} + }})", + ACCOUNT, + CREDENTIALTYPE + ), + "malformedAuthorizedCredentials", + "issuer NotString" + }, + ParamTestCaseBundle{ "DepositPreauthAuthorizeCredentialsIncorrectCredentialType", fmt::format( @@ -333,7 +354,7 @@ generateTestValuesForParametersTest() ACCOUNT, ACCOUNT2 ), - "invalidParams", + "malformedAuthorizedCredentials", "credential_type NotString" },