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.
This commit is contained in:
parent
7a2ab04da8
commit
d384bd5c62
@ -60,6 +60,16 @@ export interface SimpleTestEnvironment {
|
|||||||
wallet: WalletCli;
|
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
|
* Run a test case with a simple TESTKUDOS Taler environment, consisting
|
||||||
* of one exchange, one bank and one merchant.
|
* of one exchange, one bank and one merchant.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||||
|
import { getRandomIban, getRandomString } from "./helpers";
|
||||||
import {
|
import {
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
DbInfo,
|
DbInfo,
|
||||||
@ -113,6 +114,20 @@ export interface LibeufinPreparedPaymentDetails {
|
|||||||
nexusBankAccountName: string;
|
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 {
|
export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
|
||||||
static async create(
|
static async create(
|
||||||
gc: GlobalTestState,
|
gc: GlobalTestState,
|
||||||
@ -221,6 +236,12 @@ export interface CreateEbicsSubscriberRequest {
|
|||||||
systemID?: string;
|
systemID?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TwgAddIncomingRequest {
|
||||||
|
amount: string;
|
||||||
|
reserve_pub: string;
|
||||||
|
debit_account: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface CreateEbicsBankAccountRequest {
|
interface CreateEbicsBankAccountRequest {
|
||||||
subscriber: {
|
subscriber: {
|
||||||
hostID: string;
|
hostID: string;
|
||||||
@ -266,6 +287,7 @@ export class NexusUserBundle {
|
|||||||
twgReq: CreateTalerWireGatewayFacadeRequest;
|
twgReq: CreateTalerWireGatewayFacadeRequest;
|
||||||
twgTransferPermission: PostNexusPermissionRequest;
|
twgTransferPermission: PostNexusPermissionRequest;
|
||||||
twgHistoryPermission: PostNexusPermissionRequest;
|
twgHistoryPermission: PostNexusPermissionRequest;
|
||||||
|
twgAddIncomingPermission: PostNexusPermissionRequest;
|
||||||
localAccountName: string;
|
localAccountName: string;
|
||||||
remoteAccountName: string;
|
remoteAccountName: string;
|
||||||
|
|
||||||
@ -295,8 +317,8 @@ export class NexusUserBundle {
|
|||||||
this.twgTransferPermission = {
|
this.twgTransferPermission = {
|
||||||
action: "grant",
|
action: "grant",
|
||||||
permission: {
|
permission: {
|
||||||
subjectType: `username-${salt}`,
|
subjectId: `username-${salt}`,
|
||||||
subjectId: "twguser",
|
subjectType: "user",
|
||||||
resourceType: "facade",
|
resourceType: "facade",
|
||||||
resourceId: `twg-${salt}`,
|
resourceId: `twg-${salt}`,
|
||||||
permissionName: "facade.talerWireGateway.transfer",
|
permissionName: "facade.talerWireGateway.transfer",
|
||||||
@ -305,8 +327,8 @@ export class NexusUserBundle {
|
|||||||
this.twgHistoryPermission = {
|
this.twgHistoryPermission = {
|
||||||
action: "grant",
|
action: "grant",
|
||||||
permission: {
|
permission: {
|
||||||
subjectType: `username-${salt}`,
|
subjectId: `username-${salt}`,
|
||||||
subjectId: "twguser",
|
subjectType: "user",
|
||||||
resourceType: "facade",
|
resourceType: "facade",
|
||||||
resourceId: `twg-${salt}`,
|
resourceId: `twg-${salt}`,
|
||||||
permissionName: "facade.talerWireGateway.history",
|
permissionName: "facade.talerWireGateway.history",
|
||||||
@ -327,9 +349,7 @@ export class SandboxUserBundle {
|
|||||||
this.ebicsBankAccount = {
|
this.ebicsBankAccount = {
|
||||||
currency: "EUR",
|
currency: "EUR",
|
||||||
bic: "BELADEBEXXX",
|
bic: "BELADEBEXXX",
|
||||||
iban: `DE715001051796${(Math.random() * 100000000)
|
iban: getRandomIban("DE"),
|
||||||
.toString()
|
|
||||||
.substring(0, 8)}`,
|
|
||||||
label: `remote-account-${salt}`,
|
label: `remote-account-${salt}`,
|
||||||
name: `Taler Exchange: ${salt}`,
|
name: `Taler Exchange: ${salt}`,
|
||||||
subscriber: {
|
subscriber: {
|
||||||
@ -630,6 +650,32 @@ export namespace LibeufinSandboxApi {
|
|||||||
await axios.post(url.href, req);
|
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(
|
export async function simulateIncomingTransaction(
|
||||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||||
accountLabel: string,
|
accountLabel: string,
|
||||||
|
@ -20,10 +20,13 @@
|
|||||||
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
||||||
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
||||||
import { GlobalTestState } from "./harness";
|
import { GlobalTestState } from "./harness";
|
||||||
|
import { getRandomIban } from "./helpers";
|
||||||
import {
|
import {
|
||||||
SandboxUserBundle,
|
SandboxUserBundle,
|
||||||
NexusUserBundle,
|
NexusUserBundle,
|
||||||
launchLibeufinServices,
|
launchLibeufinServices,
|
||||||
|
LibeufinNexusApi,
|
||||||
|
LibeufinSandboxApi,
|
||||||
} from "./libeufin";
|
} from "./libeufin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,9 +44,18 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
|
|||||||
);
|
);
|
||||||
const user02sandbox = new SandboxUserBundle("02");
|
const user02sandbox = new SandboxUserBundle("02");
|
||||||
|
|
||||||
await launchLibeufinServices(
|
const libeufinServices = await launchLibeufinServices(
|
||||||
t,
|
t,
|
||||||
[user01nexus, user02nexus],
|
[user01nexus, user02nexus],
|
||||||
[user01sandbox, user02sandbox],
|
[user01sandbox, user02sandbox],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await LibeufinSandboxApi.bookPayment(
|
||||||
|
libeufinServices.libeufinSandbox,
|
||||||
|
user02sandbox,
|
||||||
|
user01sandbox,
|
||||||
|
"not a public key",
|
||||||
|
"1",
|
||||||
|
"EUR",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user