summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-02-15 20:28:09 +0100
committerMS <ms@taler.net>2021-02-15 20:28:09 +0100
commitd384bd5c62198f1160119e60776350109a8ca7d3 (patch)
tree51f013844c6ecaf56f7e4389e1cae9c5a241ac7a /packages/taler-wallet-cli/src/integrationtests/libeufin.ts
parent7a2ab04da8548d9b409df1ab183c785c7bde7e48 (diff)
downloadwallet-core-d384bd5c62198f1160119e60776350109a8ca7d3.tar.gz
wallet-core-d384bd5c62198f1160119e60776350109a8ca7d3.tar.bz2
wallet-core-d384bd5c62198f1160119e60776350109a8ca7d3.zip
TWG, payments reversal testing.
Up to the point where the payments to be reversed get created via the native Sandbox API, instead of the add-incoming API, that got recently removed from the Nexus implementation.
Diffstat (limited to 'packages/taler-wallet-cli/src/integrationtests/libeufin.ts')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/libeufin.ts60
1 files changed, 53 insertions, 7 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
index 1bced0bec..9be1135a2 100644
--- a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
@@ -19,6 +19,7 @@
*/
import axios from "axios";
import { URL } from "@gnu-taler/taler-wallet-core";
+import { getRandomIban, getRandomString } from "./helpers";
import {
GlobalTestState,
DbInfo,
@@ -113,6 +114,20 @@ export interface LibeufinPreparedPaymentDetails {
nexusBankAccountName: string;
}
+export interface LibeufinSandboxAddIncomingRequest {
+ creditorIban: string;
+ creditorBic: string;
+ creditorName: string;
+ debitorIban: string;
+ debitorBic: string;
+ debitorName: string;
+ subject: string;
+ amount: string;
+ currency: string;
+ uid: string;
+ direction: string;
+}
+
export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
static async create(
gc: GlobalTestState,
@@ -221,6 +236,12 @@ export interface CreateEbicsSubscriberRequest {
systemID?: string;
}
+export interface TwgAddIncomingRequest {
+ amount: string;
+ reserve_pub: string;
+ debit_account: string;
+}
+
interface CreateEbicsBankAccountRequest {
subscriber: {
hostID: string;
@@ -266,6 +287,7 @@ export class NexusUserBundle {
twgReq: CreateTalerWireGatewayFacadeRequest;
twgTransferPermission: PostNexusPermissionRequest;
twgHistoryPermission: PostNexusPermissionRequest;
+ twgAddIncomingPermission: PostNexusPermissionRequest;
localAccountName: string;
remoteAccountName: string;
@@ -295,8 +317,8 @@ export class NexusUserBundle {
this.twgTransferPermission = {
action: "grant",
permission: {
- subjectType: `username-${salt}`,
- subjectId: "twguser",
+ subjectId: `username-${salt}`,
+ subjectType: "user",
resourceType: "facade",
resourceId: `twg-${salt}`,
permissionName: "facade.talerWireGateway.transfer",
@@ -305,8 +327,8 @@ export class NexusUserBundle {
this.twgHistoryPermission = {
action: "grant",
permission: {
- subjectType: `username-${salt}`,
- subjectId: "twguser",
+ subjectId: `username-${salt}`,
+ subjectType: "user",
resourceType: "facade",
resourceId: `twg-${salt}`,
permissionName: "facade.talerWireGateway.history",
@@ -327,9 +349,7 @@ export class SandboxUserBundle {
this.ebicsBankAccount = {
currency: "EUR",
bic: "BELADEBEXXX",
- iban: `DE715001051796${(Math.random() * 100000000)
- .toString()
- .substring(0, 8)}`,
+ iban: getRandomIban("DE"),
label: `remote-account-${salt}`,
name: `Taler Exchange: ${salt}`,
subscriber: {
@@ -630,6 +650,32 @@ export namespace LibeufinSandboxApi {
await axios.post(url.href, req);
}
+ export async function bookPayment(
+ libeufinSandboxService: LibeufinSandboxServiceInterface,
+ creditorBundle: SandboxUserBundle,
+ debitorBundle: SandboxUserBundle,
+ subject: string,
+ amount: string,
+ currency: string,
+ ) {
+ let req: LibeufinSandboxAddIncomingRequest = {
+ creditorIban: creditorBundle.ebicsBankAccount.iban,
+ creditorBic: creditorBundle.ebicsBankAccount.bic,
+ creditorName: creditorBundle.ebicsBankAccount.name,
+ debitorIban: debitorBundle.ebicsBankAccount.iban,
+ debitorBic: debitorBundle.ebicsBankAccount.bic,
+ debitorName: debitorBundle.ebicsBankAccount.name,
+ subject: subject,
+ amount: amount,
+ currency: currency,
+ uid: getRandomString(),
+ direction: "CRDT",
+ };
+ const baseUrl = libeufinSandboxService.baseUrl;
+ let url = new URL("admin/payments", baseUrl);
+ await axios.post(url.href, req);
+ }
+
export async function simulateIncomingTransaction(
libeufinSandboxService: LibeufinSandboxServiceInterface,
accountLabel: string,