Avoid Sandbox (deprecated) POST /admin/payments/ API.

This commit is contained in:
ms 2021-09-01 17:51:52 +02:00
parent 79c14e77ec
commit 8b73c30b1f
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
2 changed files with 27 additions and 31 deletions

View File

@ -68,39 +68,37 @@ export async function runLibeufinRefundMultipleUsersTest(t: GlobalTestState) {
["twg"], ["twg"],
); );
/** // user 01 gets the payment
* user01 pays user02 using a invalid subject. At the end, await libeufinServices.libeufinSandbox.makeTransaction(
* user01 checks whether one incoming payment exists in the user02sandbox.ebicsBankAccount.label, // debit
* history. This one incoming payment will be the refund. user01sandbox.ebicsBankAccount.label, // credit
*/ "EUR:1",
await LibeufinSandboxApi.bookPayment(
libeufinServices.libeufinSandbox,
user02sandbox,
user01sandbox,
"not a public key", "not a public key",
"1",
"EUR",
); );
// user 01 fetches the payments
await LibeufinNexusApi.fetchAllTransactions( await LibeufinNexusApi.fetchAllTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user02nexus.localAccountName, user01nexus.localAccountName,
); );
delayMs(2000); // time to ingest.
// user 01 tries to submit the reimbursement, as
// the payment didn't have a valid public key in
// the subject.
await LibeufinNexusApi.submitInitiatedPayment( await LibeufinNexusApi.submitInitiatedPayment(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user02nexus.localAccountName, user01nexus.localAccountName,
"1", // so far the only one that can exist. "1", // so far the only one that can exist.
); );
// Counterpart checks whether the reimbursement shows up. // user 02 checks whether a reimbursement arrived.
let history = await LibeufinSandboxApi.getAccountTransactions( let history = await LibeufinSandboxApi.getAccountTransactions(
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
user01sandbox.ebicsBankAccount["label"], user02sandbox.ebicsBankAccount["label"],
); );
// reimbursement arrived IFF the total payments are 2:
t.assertTrue(history["payments"].length == 1); // 1 the original (faulty) transaction + 1 the reimbursement.
t.assertTrue(history["payments"].length == 2);
} }
runLibeufinRefundMultipleUsersTest.suites = ["libeufin"]; runLibeufinRefundMultipleUsersTest.suites = ["libeufin"];

View File

@ -58,11 +58,7 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
["twg"], ["twg"],
); );
/** // user 02 pays user 01 with a faulty (non Taler) subject.
* user01 pays user02 using a invalid subject. At the end,
* user01 checks whether one incoming payment exists in the
* history. This one incoming payment will be the refund.
*/
await libeufinServices.libeufinSandbox.makeTransaction( await libeufinServices.libeufinSandbox.makeTransaction(
user02sandbox.ebicsBankAccount.label, // debit user02sandbox.ebicsBankAccount.label, // debit
user01sandbox.ebicsBankAccount.label, // credit user01sandbox.ebicsBankAccount.label, // credit
@ -70,34 +66,36 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
"not a public key", "not a public key",
); );
// Gets the faulty payment in the (ingested) history. // The bad payment should be now ingested and prepared as
// a reimbursement.
await LibeufinNexusApi.fetchAllTransactions( await LibeufinNexusApi.fetchAllTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user01nexus.localAccountName, user01nexus.localAccountName,
); );
// Check payment shows up in Nexus history. // Check that the payment arrived at the Nexus.
const nexusTxs = await LibeufinNexusApi.getAccountTransactions( const nexusTxs = await LibeufinNexusApi.getAccountTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user01nexus.localAccountName, user01nexus.localAccountName,
); );
t.assertTrue(nexusTxs.data["transactions"].length == 1); t.assertTrue(nexusTxs.data["transactions"].length == 1);
// This should pay the faulty payment back. // Submit the reimbursement
await LibeufinNexusApi.submitInitiatedPayment( await LibeufinNexusApi.submitInitiatedPayment(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user01nexus.localAccountName, user01nexus.localAccountName,
// The initiated payment ID below got set by the Taler // The initiated payment (= the reimbursement) ID below
// facade; at this point only one can / must exist. // got set by the Taler facade; at this point only one must
// exist. If "1" is not found, a 404 will make this test fail.
"1", "1",
); );
// Counterpart checks whether the reimbursement shows up. // user 02 checks whether the reimbursement arrived.
let history = await LibeufinSandboxApi.getAccountTransactions( let history = await LibeufinSandboxApi.getAccountTransactions(
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
user02sandbox.ebicsBankAccount["label"], user02sandbox.ebicsBankAccount["label"],
); );
// 2 payments must exist: 1 the original (faulty) payment +
// 2 is total: 1 the original payment + 1 the reimbursement. // 1 the reimbursement.
t.assertTrue(history["payments"].length == 2); t.assertTrue(history["payments"].length == 2);
} }
runLibeufinRefundTest.suites = ["libeufin"]; runLibeufinRefundTest.suites = ["libeufin"];