141 auto verifyErr = [
this](
142 Json::Value const& result,
char const* error,
char const* errorMsg) {
143 BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
144 BEAST_EXPECT(result[jss::result][jss::error] == error);
145 BEAST_EXPECT(result[jss::result][jss::error_message] == errorMsg);
153 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
154 verifyErr(result,
"invalidParams",
"Missing field 'source_account'.");
159 args[jss::source_account] = 7.3;
160 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
161 verifyErr(result,
"invalidParams",
"Invalid field 'source_account', not a string.");
166 args[jss::source_account] =
"rG1QQv2nh2gr7RCZ!P8YYcBUKCCN633jCn";
167 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
168 verifyErr(result,
"actMalformed",
"Account malformed.");
174 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
175 verifyErr(result,
"invalidParams",
"Missing field 'destination_account'.");
180 args[jss::destination_account] = 7.3;
181 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
183 result,
"invalidParams",
"Invalid field 'destination_account', not a string.");
188 args[jss::destination_account] =
"rP6P9ypfAmc!pw8SZHNwM4nvZHFXDraQas";
189 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
190 verifyErr(result,
"actMalformed",
"Account malformed.");
195 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
197 result,
"invalidParams",
"Invalid field 'ledger_index', not string or number.");
202 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
203 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
208 args[jss::ledger_index] = 17;
209 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
210 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
215 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
216 verifyErr(result,
"srcActNotFound",
"Source account not found.");
223 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
224 verifyErr(result,
"dstActNotFound",
"Destination account not found.");
231 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
245 BEAST_EXPECT(result[jss::status] ==
authorized ? jss::success : jss::error);
246 if (result.
isMember(jss::deposit_authorized))
247 BEAST_EXPECT(result[jss::deposit_authorized] ==
authorized);
251 result.
isMember(jss::deposit_authorized) &&
252 (result[jss::deposit_authorized] ==
true));
255 BEAST_EXPECT(result.
isMember(jss::error) == !error.empty());
257 BEAST_EXPECT(result[jss::error].asString() == error);
261 BEAST_EXPECT(result[jss::source_account] == src.
human());
262 BEAST_EXPECT(result[jss::destination_account] == dst.
human());
264 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
265 BEAST_EXPECT(result[jss::credentials][i] == credentialIDs[i]);
269 BEAST_EXPECT(result[jss::request].isObject());
271 auto const& request = result[jss::request];
272 BEAST_EXPECT(request[jss::command] == jss::deposit_authorized);
273 BEAST_EXPECT(request[jss::source_account] == src.
human());
274 BEAST_EXPECT(request[jss::destination_account] == dst.
human());
276 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
277 BEAST_EXPECT(request[jss::credentials][i] == credentialIDs[i]);
288 char const credType[] =
"abcde";
296 env.
fund(
XRP(1000), alice, becky, carol, diana);
304 std::string const credIdx = jv[jss::result][jss::index].asString();
307 env(
fset(becky, asfDepositAuth));
315 testcase(
"deposit_authorized with credentials failure: empty array.");
320 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
326 "deposit_authorized with credentials failure: not a string "
331 args[jss::credentials].append(1);
332 args[jss::credentials].append(3);
334 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
340 "deposit_authorized with credentials failure: not a hex string "
345 args[jss::credentials].append(
"hello world");
347 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
349 jv[jss::result], alice, becky,
false, {
"hello world"},
"invalidParams");
354 "deposit_authorized with credentials failure: not a credential "
361 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
364 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
370 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
377 "deposit_authorized with credentials not authorized: "
378 "credential not accepted");
379 auto const jv = env.
rpc(
381 "deposit_authorized",
382 depositAuthArgs(alice, becky,
"validated", {credIdx}).toStyledString());
384 jv[jss::result], alice, becky,
false, {credIdx},
"badCredentials");
392 testcase(
"deposit_authorized with duplicates in credentials");
393 auto const jv = env.
rpc(
395 "deposit_authorized",
396 depositAuthArgs(alice, becky,
"validated", {credIdx, credIdx}).toStyledString());
398 jv[jss::result], alice, becky,
false, {credIdx, credIdx},
"badCredentials");
403 "18004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
404 "28004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
405 "38004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
406 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
407 "58004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
408 "68004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
409 "78004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
410 "88004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
411 "98004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288BE4",
415 testcase(
"deposit_authorized too long credentials");
416 auto const jv = env.
rpc(
418 "deposit_authorized",
421 jv[jss::result], alice, becky,
false, credIds,
"invalidParams");
425 testcase(
"deposit_authorized with credentials");
426 auto const jv = env.
rpc(
428 "deposit_authorized",
429 depositAuthArgs(alice, becky,
"validated", {credIdx}).toStyledString());
442 std::string const credBecky = jv[jss::result][jss::index].asString();
444 testcase(
"deposit_authorized account without preauth");
447 "deposit_authorized",
448 depositAuthArgs(becky, alice,
"validated", {credBecky}).toStyledString());
460 std::string const credDiana = jv[jss::result][jss::index].asString();
465 "deposit_authorized",
466 depositAuthArgs(becky, alice,
"validated", {credDiana}).toStyledString());
468 jv[jss::result], becky, alice,
false, {credDiana},
"badCredentials");
472 testcase(
"deposit_authorized with expired credentials");
475 char const credType2[] =
"random";
477 env.
current()->header().parentCloseTime.time_since_epoch().count() + 40;
481 jv[sfExpiration.jsonName] = x;
487 std::string const credIdx2 = jv[jss::result][jss::index].asString();
490 env(
fset(becky, asfDepositAuth));
501 "deposit_authorized",
502 depositAuthArgs(alice, becky,
"validated", {credIdx2}).toStyledString());
513 "deposit_authorized",
514 depositAuthArgs(alice, becky,
"validated", {credIdx2}).toStyledString());
517 jv[jss::result], alice, becky,
false, {credIdx2},
"badCredentials");