172 auto verifyErr = [
this](
175 char const* errorMsg) {
176 BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
177 BEAST_EXPECT(result[jss::result][jss::error] == error);
178 BEAST_EXPECT(result[jss::result][jss::error_message] == errorMsg);
187 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
189 result,
"invalidParams",
"Missing field 'source_account'.");
194 args[jss::source_account] = 7.3;
196 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
200 "Invalid field 'source_account', not a string.");
205 args[jss::source_account] =
"rG1QQv2nh2gr7RCZ!P8YYcBUKCCN633jCn";
207 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
208 verifyErr(result,
"actMalformed",
"Account malformed.");
215 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
219 "Missing field 'destination_account'.");
224 args[jss::destination_account] = 7.3;
226 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
230 "Invalid field 'destination_account', not a string.");
235 args[jss::destination_account] =
236 "rP6P9ypfAmc!pw8SZHNwM4nvZHFXDraQas";
238 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
239 verifyErr(result,
"actMalformed",
"Account malformed.");
245 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
246 verifyErr(result,
"invalidParams",
"ledgerIndexMalformed");
252 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
253 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
258 args[jss::ledger_index] = 17;
260 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
261 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
267 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
268 verifyErr(result,
"srcActNotFound",
"Source account not found.");
276 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
278 result,
"dstActNotFound",
"Destination account not found.");
286 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
301 result[jss::status] ==
authorized ? jss::success : jss::error);
302 if (result.
isMember(jss::deposit_authorized))
303 BEAST_EXPECT(result[jss::deposit_authorized] ==
authorized);
306 result.
isMember(jss::deposit_authorized) &&
307 (result[jss::deposit_authorized] ==
true));
309 BEAST_EXPECT(result.
isMember(jss::error) == !error.empty());
311 BEAST_EXPECT(result[jss::error].asString() == error);
315 BEAST_EXPECT(result[jss::source_account] == src.
human());
316 BEAST_EXPECT(result[jss::destination_account] == dst.
human());
318 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
319 BEAST_EXPECT(result[jss::credentials][i] == credentialIDs[i]);
323 BEAST_EXPECT(result[jss::request].isObject());
325 auto const& request = result[jss::request];
326 BEAST_EXPECT(request[jss::command] == jss::deposit_authorized);
327 BEAST_EXPECT(request[jss::source_account] == src.
human());
328 BEAST_EXPECT(request[jss::destination_account] == dst.
human());
330 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
331 BEAST_EXPECT(request[jss::credentials][i] == credentialIDs[i]);
342 char const credType[] =
"abcde";
350 env.
fund(
XRP(1000), alice, becky, carol, diana);
358 std::string const credIdx = jv[jss::result][jss::index].asString();
370 "deposit_authorized with credentials failure: empty array.");
376 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
378 jv[jss::result], alice, becky,
false, {},
"invalidParams");
383 "deposit_authorized with credentials failure: not a string "
388 args[jss::credentials].append(1);
389 args[jss::credentials].append(3);
392 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
394 jv[jss::result], alice, becky,
false, {},
"invalidParams");
399 "deposit_authorized with credentials failure: not a hex string "
404 args[jss::credentials].append(
"hello world");
407 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
419 "deposit_authorized with credentials failure: not a credential "
426 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
430 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
436 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
443 "deposit_authorized with credentials not authorized: "
444 "credential not accepted");
445 auto const jv = env.
rpc(
447 "deposit_authorized",
464 testcase(
"deposit_authorized with duplicates in credentials");
465 auto const jv = env.
rpc(
467 "deposit_authorized",
481 "18004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
483 "28004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
485 "38004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
487 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
489 "58004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
491 "68004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
493 "78004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
495 "88004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
497 "98004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
501 testcase(
"deposit_authorized too long credentials");
502 auto const jv = env.
rpc(
504 "deposit_authorized",
508 jv[jss::result], alice, becky,
false, credIds,
"invalidParams");
512 testcase(
"deposit_authorized with credentials");
513 auto const jv = env.
rpc(
515 "deposit_authorized",
519 jv[jss::result], alice, becky,
true, {credIdx});
532 jv[jss::result][jss::index].asString();
534 testcase(
"deposit_authorized account without preauth");
537 "deposit_authorized",
541 jv[jss::result], becky, alice,
true, {credBecky});
553 jv[jss::result][jss::index].asString();
558 "deposit_authorized",
571 testcase(
"deposit_authorized with expired credentials");
574 char const credType2[] =
"fghijk";
577 .parentCloseTime.time_since_epoch()
583 jv[sfExpiration.jsonName] = x;
589 std::string const credIdx2 = jv[jss::result][jss::index].asString();
603 "deposit_authorized",
607 jv[jss::result], alice, becky,
true, {credIdx2});
617 "deposit_authorized",