aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/helpers.ts10
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/libeufin.ts60
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts14
3 files changed, 76 insertions, 8 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/helpers.ts b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
index 0bd6750d9..bca983758 100644
--- a/packages/taler-wallet-cli/src/integrationtests/helpers.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
@@ -60,6 +60,16 @@ export interface SimpleTestEnvironment {
wallet: WalletCli;
}
+export function getRandomIban(countryCode: string): string {
+ return `${countryCode}715001051796${(Math.random() * 100000000)
+ .toString()
+ .substring(0, 8)}`;
+}
+
+export function getRandomString(): string {
+ return Math.random().toString(36).substring(2);
+}
+
/**
* Run a test case with a simple TESTKUDOS Taler environment, consisting
* of one exchange, one bank and one merchant.
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,
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
index 2d5103dce..2ceb8be0e 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
@@ -20,10 +20,13 @@
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
import { GlobalTestState } from "./harness";
+import { getRandomIban } from "./helpers";
import {
SandboxUserBundle,
NexusUserBundle,
launchLibeufinServices,
+ LibeufinNexusApi,
+ LibeufinSandboxApi,
} from "./libeufin";
/**
@@ -41,9 +44,18 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
);
const user02sandbox = new SandboxUserBundle("02");
- await launchLibeufinServices(
+ const libeufinServices = await launchLibeufinServices(
t,
[user01nexus, user02nexus],
[user01sandbox, user02sandbox],
);
+
+ await LibeufinSandboxApi.bookPayment(
+ libeufinServices.libeufinSandbox,
+ user02sandbox,
+ user01sandbox,
+ "not a public key",
+ "1",
+ "EUR",
+ );
}