wallet-core,harness: towards corebank API instead of fakebank/nexus API
This commit is contained in:
parent
0388d31d36
commit
58debefbe0
@ -124,6 +124,7 @@ export function useTestingAPI(): TestingAPI {
|
||||
const register = async (
|
||||
data: SandboxBackend.Access.BankRegistrationRequest,
|
||||
): Promise<HttpResponseOk<void>> => {
|
||||
// FIXME: This API is deprecated. The normal account registration API should be used instead.
|
||||
const res = await noAuthRequest<void>(`access-api/testing/register`, {
|
||||
method: "POST",
|
||||
data,
|
||||
|
@ -28,7 +28,7 @@ import {
|
||||
AccountAddDetails,
|
||||
AmountJson,
|
||||
Amounts,
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
Configuration,
|
||||
CoreApiResponse,
|
||||
Duration,
|
||||
@ -650,8 +650,7 @@ export class FakebankService
|
||||
}
|
||||
|
||||
get bankAccessApiBaseUrl(): string {
|
||||
let url = new URL("taler-bank-access/", this.baseUrl);
|
||||
return url.href;
|
||||
return this.baseUrl;
|
||||
}
|
||||
|
||||
async createExchangeAccount(
|
||||
@ -666,7 +665,7 @@ export class FakebankService
|
||||
accountName: accountName,
|
||||
accountPassword: password,
|
||||
accountPaytoUri: getPayto(accountName),
|
||||
wireGatewayApiBaseUrl: `http://localhost:${this.bankConfig.httpPort}/taler-wire-gateway/${accountName}/`,
|
||||
wireGatewayApiBaseUrl: `http://localhost:${this.bankConfig.httpPort}/accounts/${accountName}/taler-wire-gateway/`,
|
||||
};
|
||||
}
|
||||
|
||||
@ -691,14 +690,14 @@ export class FakebankService
|
||||
"bank",
|
||||
);
|
||||
await this.pingUntilAvailable();
|
||||
const bankClient = new BankAccessApiClient(this.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(this.bankAccessApiBaseUrl);
|
||||
for (const acc of this.accounts) {
|
||||
await bankClient.registerAccount(acc.accountName, acc.accountPassword);
|
||||
}
|
||||
}
|
||||
|
||||
async pingUntilAvailable(): Promise<void> {
|
||||
const url = `http://localhost:${this.bankConfig.httpPort}/taler-bank-integration/config`;
|
||||
const url = `http://localhost:${this.bankConfig.httpPort}/config`;
|
||||
await pingProc(this.proc, url, "bank");
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
import {
|
||||
AmountString,
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
ConfirmPayResultType,
|
||||
Duration,
|
||||
Logger,
|
||||
@ -560,7 +560,7 @@ export async function withdrawViaBankV2(
|
||||
): Promise<WithdrawViaBankResult> {
|
||||
const { walletClient: wallet, bank, exchange, amount } = p;
|
||||
|
||||
const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bank.bankAccessApiBaseUrl);
|
||||
|
||||
const user = await bankClient.createRandomBankUser();
|
||||
const wop = await bankClient.createWithdrawalOperation(user.username, amount);
|
||||
|
@ -1,775 +0,0 @@
|
||||
/**
|
||||
* This file defines most of the API calls offered
|
||||
* by Nexus and Sandbox. They don't have state,
|
||||
* therefore got moved away from libeufin.ts where
|
||||
* the services get actually started and managed.
|
||||
*/
|
||||
|
||||
import { URL } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
createPlatformHttpLib,
|
||||
makeBasicAuthHeader,
|
||||
} from "@gnu-taler/taler-util/http";
|
||||
import {
|
||||
LibeufinNexusTransactions,
|
||||
LibeufinSandboxAdminBankAccountBalance,
|
||||
NexusBankConnections,
|
||||
NexusFacadeListResponse,
|
||||
NexusGetPermissionsResponse,
|
||||
NexusNewTransactionsInfo,
|
||||
NexusTask,
|
||||
NexusTaskCollection,
|
||||
NexusUserResponse,
|
||||
} from "./libeufin.js";
|
||||
|
||||
export interface LibeufinSandboxServiceInterface {
|
||||
baseUrl: string;
|
||||
}
|
||||
|
||||
export interface LibeufinNexusServiceInterface {
|
||||
baseUrl: string;
|
||||
}
|
||||
|
||||
export interface CreateEbicsSubscriberRequest {
|
||||
hostID: string;
|
||||
userID: string;
|
||||
partnerID: string;
|
||||
systemID?: string;
|
||||
}
|
||||
|
||||
export interface BankAccountInfo {
|
||||
iban: string;
|
||||
bic: string;
|
||||
name: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface CreateEbicsBankConnectionRequest {
|
||||
name: string; // connection name.
|
||||
ebicsURL: string;
|
||||
hostID: string;
|
||||
userID: string;
|
||||
partnerID: string;
|
||||
systemID?: string;
|
||||
}
|
||||
|
||||
export interface UpdateNexusUserRequest {
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export interface NexusAuth {
|
||||
auth: {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PostNexusTaskRequest {
|
||||
name: string;
|
||||
cronspec: string;
|
||||
type: string; // fetch | submit
|
||||
params:
|
||||
| {
|
||||
level: string; // report | statement | all
|
||||
rangeType: string; // all | since-last | previous-days | latest
|
||||
}
|
||||
| {};
|
||||
}
|
||||
|
||||
export interface CreateNexusUserRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface PostNexusPermissionRequest {
|
||||
action: "revoke" | "grant";
|
||||
permission: {
|
||||
subjectType: string;
|
||||
subjectId: string;
|
||||
resourceType: string;
|
||||
resourceId: string;
|
||||
permissionName: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface CreateAnastasisFacadeRequest {
|
||||
name: string;
|
||||
connectionName: string;
|
||||
accountName: string;
|
||||
currency: string;
|
||||
reserveTransferLevel: "report" | "statement" | "notification";
|
||||
}
|
||||
|
||||
export interface CreateTalerWireGatewayFacadeRequest {
|
||||
name: string;
|
||||
connectionName: string;
|
||||
accountName: string;
|
||||
currency: string;
|
||||
reserveTransferLevel: "report" | "statement" | "notification";
|
||||
}
|
||||
|
||||
export interface SandboxAccountTransactions {
|
||||
payments: {
|
||||
accountLabel: string;
|
||||
creditorIban: string;
|
||||
creditorBic?: string;
|
||||
creditorName: string;
|
||||
debtorIban: string;
|
||||
debtorBic: string;
|
||||
debtorName: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
subject: string;
|
||||
date: string;
|
||||
creditDebitIndicator: "debit" | "credit";
|
||||
accountServicerReference: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface DeleteBankConnectionRequest {
|
||||
bankConnectionId: string;
|
||||
}
|
||||
|
||||
export interface SimulateIncomingTransactionRequest {
|
||||
debtorIban: string;
|
||||
debtorBic: string;
|
||||
debtorName: string;
|
||||
|
||||
/**
|
||||
* Subject / unstructured remittance info.
|
||||
*/
|
||||
subject: string;
|
||||
|
||||
/**
|
||||
* Decimal amount without currency.
|
||||
*/
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export interface CreateEbicsBankAccountRequest {
|
||||
subscriber: {
|
||||
hostID: string;
|
||||
partnerID: string;
|
||||
userID: string;
|
||||
systemID?: string;
|
||||
};
|
||||
// IBAN
|
||||
iban: string;
|
||||
// BIC
|
||||
bic: string;
|
||||
// human name
|
||||
name: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface LibeufinSandboxAddIncomingRequest {
|
||||
creditorIban: string;
|
||||
creditorBic: string;
|
||||
creditorName: string;
|
||||
debtorIban: string;
|
||||
debtorBic: string;
|
||||
debtorName: string;
|
||||
subject: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
uid: string;
|
||||
direction: string;
|
||||
}
|
||||
|
||||
const libeufinHarnessHttpLib = createPlatformHttpLib();
|
||||
|
||||
/**
|
||||
* APIs spread across Legacy and Access, it is therefore
|
||||
* the "base URL" relative to which API every call addresses.
|
||||
*/
|
||||
export namespace LibeufinSandboxApi {
|
||||
// Creates one bank account via the Access API.
|
||||
// Need the /demobanks/$id/access-api as the base URL
|
||||
export async function createDemobankAccount(
|
||||
username: string,
|
||||
password: string,
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
iban: string | null = null,
|
||||
): Promise<void> {
|
||||
let url = new URL("testing/register", libeufinSandboxService.baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: {
|
||||
username: username,
|
||||
password: password,
|
||||
iban: iban,
|
||||
},
|
||||
});
|
||||
}
|
||||
// Need /demobanks/$id as the base URL
|
||||
export async function createDemobankEbicsSubscriber(
|
||||
req: CreateEbicsSubscriberRequest,
|
||||
demobankAccountLabel: string,
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
username: string = "admin",
|
||||
password: string = "secret",
|
||||
): Promise<void> {
|
||||
// baseUrl should already be pointed to one demobank.
|
||||
let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: {
|
||||
userID: req.userID,
|
||||
hostID: req.hostID,
|
||||
partnerID: req.partnerID,
|
||||
demobankAccountLabel: demobankAccountLabel,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function rotateKeys(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
hostID: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL(`admin/ebics/hosts/${hostID}/rotate-keys`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
export async function createEbicsHost(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
hostID: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL("admin/ebics/hosts", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: {
|
||||
hostID,
|
||||
ebicsVersion: "2.5",
|
||||
},
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
export async function createBankAccount(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
req: BankAccountInfo,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL(`admin/bank-accounts/${req.label}`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: req,
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is useless. It creates a Ebics subscriber
|
||||
* but never gives it a bank account. To be removed
|
||||
*/
|
||||
export async function createEbicsSubscriber(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
req: CreateEbicsSubscriberRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL("admin/ebics/subscribers", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: req,
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new bank account and associate it to
|
||||
* a existing EBICS subscriber.
|
||||
*/
|
||||
export async function createEbicsBankAccount(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
req: CreateEbicsBankAccountRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL("admin/ebics/bank-accounts", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: req,
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
export async function simulateIncomingTransaction(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
accountLabel: string,
|
||||
req: SimulateIncomingTransactionRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL(
|
||||
`admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`,
|
||||
baseUrl,
|
||||
);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: req,
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAccountTransactions(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
accountLabel: string,
|
||||
): Promise<SandboxAccountTransactions> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL(
|
||||
`admin/bank-accounts/${accountLabel}/transactions`,
|
||||
baseUrl,
|
||||
);
|
||||
const res = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return (await res.json()) as SandboxAccountTransactions;
|
||||
}
|
||||
|
||||
export async function getCamt053(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
accountLabel: string,
|
||||
): Promise<any> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL("admin/payments/camt", baseUrl);
|
||||
return await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {
|
||||
bankaccount: accountLabel,
|
||||
type: 53,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAccountInfoWithBalance(
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
accountLabel: string,
|
||||
): Promise<LibeufinSandboxAdminBankAccountBalance> {
|
||||
const baseUrl = libeufinSandboxService.baseUrl;
|
||||
let url = new URL(`admin/bank-accounts/${accountLabel}`, baseUrl);
|
||||
const res = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
}
|
||||
|
||||
export namespace LibeufinNexusApi {
|
||||
export async function getAllConnections(
|
||||
nexus: LibeufinNexusServiceInterface,
|
||||
): Promise<NexusBankConnections> {
|
||||
let url = new URL("bank-connections", nexus.baseUrl);
|
||||
const res = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function deleteBankConnection(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
req: DeleteBankConnectionRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("bank-connections/delete-connection", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: req,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createEbicsBankConnection(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
req: CreateEbicsBankConnectionRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("bank-connections", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {
|
||||
source: "new",
|
||||
type: "ebics",
|
||||
name: req.name,
|
||||
data: {
|
||||
ebicsURL: req.ebicsURL,
|
||||
hostID: req.hostID,
|
||||
userID: req.userID,
|
||||
partnerID: req.partnerID,
|
||||
systemID: req.systemID,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getBankAccount(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
accountName: string,
|
||||
): Promise<any> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`bank-accounts/${accountName}`, baseUrl);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function submitInitiatedPayment(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
accountName: string,
|
||||
paymentId: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`bank-accounts/${accountName}/payment-initiations/${paymentId}/submit`,
|
||||
baseUrl,
|
||||
);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchAccounts(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
connectionName: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`bank-connections/${connectionName}/fetch-accounts`,
|
||||
baseUrl,
|
||||
);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
|
||||
export async function importConnectionAccount(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
connectionName: string,
|
||||
offeredAccountId: string,
|
||||
nexusBankAccountId: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`bank-connections/${connectionName}/import-account`,
|
||||
baseUrl,
|
||||
);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {
|
||||
offeredAccountId,
|
||||
nexusBankAccountId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function connectBankConnection(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
connectionName: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`bank-connections/${connectionName}/connect`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getPaymentInitiations(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
accountName: string,
|
||||
username: string = "admin",
|
||||
password: string = "test",
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/bank-accounts/${accountName}/payment-initiations`,
|
||||
baseUrl,
|
||||
);
|
||||
let response = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
const respJson = await response.json();
|
||||
console.log(
|
||||
`Payment initiations of: ${accountName}`,
|
||||
JSON.stringify(respJson, null, 2),
|
||||
);
|
||||
}
|
||||
|
||||
// Uses the Anastasis API to get a list of transactions.
|
||||
export async function getAnastasisTransactions(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
anastasisBaseUrl: string,
|
||||
// FIXME: Nail down type!
|
||||
params: {}, // of the request: {delta: 5, ..}
|
||||
username: string = "admin",
|
||||
password: string = "test",
|
||||
): Promise<any> {
|
||||
let url = new URL("history/incoming", anastasisBaseUrl);
|
||||
for (const [k, v] of Object.entries(params)) {
|
||||
url.searchParams.set(k, String(v));
|
||||
}
|
||||
let response = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// FIXME: this function should return some structured
|
||||
// object that represents a history.
|
||||
export async function getAccountTransactions(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
accountName: string,
|
||||
username: string = "admin",
|
||||
password: string = "test",
|
||||
): Promise<LibeufinNexusTransactions> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl);
|
||||
let response = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function fetchTransactions(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
accountName: string,
|
||||
rangeType: string = "all",
|
||||
level: string = "report",
|
||||
username: string = "admin",
|
||||
password: string = "test",
|
||||
): Promise<NexusNewTransactionsInfo> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/bank-accounts/${accountName}/fetch-transactions`,
|
||||
baseUrl,
|
||||
);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {
|
||||
rangeType: rangeType,
|
||||
level: level,
|
||||
},
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function changePassword(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
username: string,
|
||||
req: UpdateNexusUserRequest,
|
||||
auth: NexusAuth,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/users/${username}/password`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: req,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getUser(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
auth: NexusAuth,
|
||||
): Promise<NexusUserResponse> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/user`, baseUrl);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function createUser(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
req: CreateNexusUserRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/users`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: req,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAllPermissions(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
): Promise<NexusGetPermissionsResponse> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/permissions`, baseUrl);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function postPermission(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
req: PostNexusPermissionRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/permissions`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: req,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAllTasks(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
bankAccountName: string,
|
||||
): Promise<NexusTaskCollection> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function getTask(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
bankAccountName: string,
|
||||
// When void, the request returns the list of all the
|
||||
// tasks under this bank account.
|
||||
taskName: string,
|
||||
): Promise<NexusTask> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/bank-accounts/${bankAccountName}/schedule/${taskName}`,
|
||||
baseUrl,
|
||||
);
|
||||
if (taskName) url = new URL(taskName, `${url.href}/`);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function deleteTask(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
bankAccountName: string,
|
||||
taskName: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/bank-accounts/${bankAccountName}/schedule/${taskName}`,
|
||||
baseUrl,
|
||||
);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "DELETE",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
export async function postTask(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
bankAccountName: string,
|
||||
req: PostNexusTaskRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: req,
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteFacade(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
facadeName: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`facades/${facadeName}`, baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "DELETE",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAllFacades(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
): Promise<NexusFacadeListResponse> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("facades", baseUrl);
|
||||
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
});
|
||||
// FIXME: Just return validated, typed response here!
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export async function createAnastasisFacade(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
req: CreateAnastasisFacadeRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("facades", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {
|
||||
name: req.name,
|
||||
type: "anastasis",
|
||||
config: {
|
||||
bankAccount: req.accountName,
|
||||
bankConnection: req.connectionName,
|
||||
currency: req.currency,
|
||||
reserveTransferLevel: req.reserveTransferLevel,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function createTwgFacade(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
req: CreateTalerWireGatewayFacadeRequest,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("facades", baseUrl);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {
|
||||
name: req.name,
|
||||
type: "taler-wire-gateway",
|
||||
config: {
|
||||
bankAccount: req.accountName,
|
||||
bankConnection: req.connectionName,
|
||||
currency: req.currency,
|
||||
reserveTransferLevel: req.reserveTransferLevel,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function submitAllPaymentInitiations(
|
||||
libeufinNexusService: LibeufinNexusServiceInterface,
|
||||
accountId: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/bank-accounts/${accountId}/submit-all-payment-initiations`,
|
||||
baseUrl,
|
||||
);
|
||||
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@
|
||||
import {
|
||||
addPaytoQueryParams,
|
||||
Amounts,
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
Configuration,
|
||||
decodeCrock,
|
||||
j2s,
|
||||
@ -236,7 +236,7 @@ deploymentCli
|
||||
|
||||
console.log(tipReserveResp);
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
args.tipTopup.bankAccessUrl,
|
||||
{
|
||||
auth: {
|
||||
|
@ -27,7 +27,7 @@ import {
|
||||
withdrawViaBankV2,
|
||||
} from "../harness/helpers.js";
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
MerchantApiClient,
|
||||
WireGatewayApiClient,
|
||||
} from "@gnu-taler/taler-util";
|
||||
@ -179,7 +179,7 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
|
||||
|
||||
// Pay with coin from tipping
|
||||
{
|
||||
const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bank.bankAccessApiBaseUrl);
|
||||
const mbu = await bankClient.createRandomBankUser();
|
||||
const tipReserveResp = await merchantClient.createTippingReserve({
|
||||
exchange_url: exchange.baseUrl,
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
CreditDebitIndicator,
|
||||
WireGatewayApiClient,
|
||||
createEddsaKeyPair,
|
||||
@ -99,7 +99,7 @@ export async function runBankApiTest(t: GlobalTestState) {
|
||||
|
||||
console.log("setup done!");
|
||||
|
||||
const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bank.bankAccessApiBaseUrl);
|
||||
|
||||
const bankUser = await bankClient.registerAccount("user1", "pw1");
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
ExchangesListResponse,
|
||||
TalerErrorCode,
|
||||
URL,
|
||||
@ -263,7 +263,7 @@ export async function runExchangeManagementTest(
|
||||
|
||||
// Create withdrawal operation
|
||||
|
||||
const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bank.bankAccessApiBaseUrl);
|
||||
|
||||
const user = await bankClient.createRandomBankUser();
|
||||
const wop = await bankClient.createWithdrawalOperation(
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
Duration,
|
||||
j2s,
|
||||
Logger,
|
||||
@ -302,7 +302,7 @@ export async function runKycTest(t: GlobalTestState) {
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bank.bankAccessApiBaseUrl);
|
||||
|
||||
const amount = "TESTKUDOS:20";
|
||||
const user = await bankClient.createRandomBankUser();
|
||||
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
LibeufinNexusApi,
|
||||
LibeufinNexusService,
|
||||
LibeufinSandboxService,
|
||||
LibeufinSandboxApi,
|
||||
findNexusPayment,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
const nexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinNexusApi.createUser(nexus, {
|
||||
username: "one",
|
||||
password: "testing-the-bankaccount-api",
|
||||
});
|
||||
const sandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5012,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
});
|
||||
await sandbox.start();
|
||||
await sandbox.pingUntilAvailable();
|
||||
await LibeufinSandboxApi.createEbicsHost(sandbox, "mock");
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997361",
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
{
|
||||
hostID: "mock",
|
||||
partnerID: "mock",
|
||||
userID: "mock",
|
||||
},
|
||||
"mock",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/" },
|
||||
);
|
||||
await LibeufinNexusApi.createEbicsBankConnection(nexus, {
|
||||
name: "bankaccount-api-test-connection",
|
||||
ebicsURL: "http://localhost:5012/ebicsweb",
|
||||
hostID: "mock",
|
||||
userID: "mock",
|
||||
partnerID: "mock",
|
||||
});
|
||||
await LibeufinNexusApi.connectBankConnection(
|
||||
nexus,
|
||||
"bankaccount-api-test-connection",
|
||||
);
|
||||
await LibeufinNexusApi.fetchAccounts(
|
||||
nexus,
|
||||
"bankaccount-api-test-connection",
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.importConnectionAccount(
|
||||
nexus,
|
||||
"bankaccount-api-test-connection",
|
||||
"mock",
|
||||
"local-mock",
|
||||
);
|
||||
await LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
sandbox,
|
||||
"mock", // creditor bankaccount label
|
||||
{
|
||||
debtorIban: "DE84500105176881385584",
|
||||
debtorBic: "BELADEBEXXX",
|
||||
debtorName: "mock2",
|
||||
amount: "EUR:1",
|
||||
subject: "mock subject",
|
||||
},
|
||||
);
|
||||
await LibeufinNexusApi.fetchTransactions(nexus, "local-mock");
|
||||
let transactions = await LibeufinNexusApi.getAccountTransactions(
|
||||
nexus,
|
||||
"local-mock",
|
||||
);
|
||||
let el = findNexusPayment("mock subject", transactions);
|
||||
t.assertTrue(el instanceof Object);
|
||||
}
|
||||
|
||||
runLibeufinApiBankaccountTest.suites = ["libeufin"];
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import { LibeufinNexusApi, LibeufinNexusService } from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinApiBankconnectionTest(t: GlobalTestState) {
|
||||
const nexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinNexusApi.createUser(nexus, {
|
||||
username: "one",
|
||||
password: "testing-the-bankconnection-api",
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.createEbicsBankConnection(nexus, {
|
||||
name: "bankconnection-api-test-connection",
|
||||
ebicsURL: "http://localhost:5012/ebicsweb",
|
||||
hostID: "mock",
|
||||
userID: "mock",
|
||||
partnerID: "mock",
|
||||
});
|
||||
|
||||
let connections = await LibeufinNexusApi.getAllConnections(nexus);
|
||||
t.assertTrue(connections.bankConnections.length == 1);
|
||||
|
||||
await LibeufinNexusApi.deleteBankConnection(nexus, {
|
||||
bankConnectionId: "bankconnection-api-test-connection",
|
||||
});
|
||||
connections = await LibeufinNexusApi.getAllConnections(nexus);
|
||||
t.assertTrue(connections.bankConnections.length == 0);
|
||||
}
|
||||
runLibeufinApiBankconnectionTest.suites = ["libeufin"];
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { URL } from "@gnu-taler/taler-util";
|
||||
import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
|
||||
import {
|
||||
launchLibeufinServices,
|
||||
NexusUserBundle,
|
||||
SandboxUserBundle,
|
||||
} from "../harness/libeufin.js";
|
||||
import {
|
||||
createPlatformHttpLib,
|
||||
makeBasicAuthHeader,
|
||||
} from "@gnu-taler/taler-util/http";
|
||||
|
||||
export async function runLibeufinApiFacadeBadRequestTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus],
|
||||
[user01sandbox],
|
||||
["twg"],
|
||||
);
|
||||
console.log("malformed facade");
|
||||
const baseUrl = libeufinServices.libeufinNexus.baseUrl;
|
||||
let url = new URL("facades", baseUrl);
|
||||
let resp = await harnessHttpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: {
|
||||
name: "malformed-facade",
|
||||
type: "taler-wire-gateway",
|
||||
config: {}, // malformation here.
|
||||
},
|
||||
headers: {
|
||||
Authorization: makeBasicAuthHeader("admin", "test"),
|
||||
},
|
||||
});
|
||||
t.assertTrue(resp.status == 400);
|
||||
}
|
||||
|
||||
runLibeufinApiFacadeBadRequestTest.suites = ["libeufin"];
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinNexusApi,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinApiFacadeTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus],
|
||||
[user01sandbox],
|
||||
["twg"],
|
||||
);
|
||||
let resp = await LibeufinNexusApi.getAllFacades(
|
||||
libeufinServices.libeufinNexus,
|
||||
);
|
||||
// check that original facade shows up.
|
||||
t.assertTrue(resp.facades[0].name == user01nexus.twgReq["name"]);
|
||||
|
||||
const twgBaseUrl: string = resp.facades[0]["baseUrl"];
|
||||
t.assertTrue(typeof twgBaseUrl === "string");
|
||||
t.assertTrue(twgBaseUrl.startsWith("http://"));
|
||||
t.assertTrue(twgBaseUrl.endsWith("/"));
|
||||
|
||||
// delete it.
|
||||
await LibeufinNexusApi.deleteFacade(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.twgReq["name"],
|
||||
);
|
||||
resp = await LibeufinNexusApi.getAllFacades(libeufinServices.libeufinNexus);
|
||||
t.assertTrue(!resp.hasOwnProperty("facades"));
|
||||
}
|
||||
|
||||
runLibeufinApiFacadeTest.suites = ["libeufin"];
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
NexusUserBundle,
|
||||
LibeufinNexusApi,
|
||||
LibeufinNexusService,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinApiPermissionsTest(t: GlobalTestState) {
|
||||
const nexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.createUser(nexus, user01nexus.userReq);
|
||||
await LibeufinNexusApi.postPermission(
|
||||
nexus,
|
||||
user01nexus.twgTransferPermission,
|
||||
);
|
||||
let transferPermission = await LibeufinNexusApi.getAllPermissions(nexus);
|
||||
let element = transferPermission["permissions"].pop();
|
||||
t.assertTrue(!!element);
|
||||
t.assertTrue(
|
||||
element["permissionName"] == "facade.talerwiregateway.transfer" &&
|
||||
element["subjectId"] == "username-01",
|
||||
);
|
||||
let denyTransfer = user01nexus.twgTransferPermission;
|
||||
|
||||
// Now revoke permission.
|
||||
denyTransfer["action"] = "revoke";
|
||||
await LibeufinNexusApi.postPermission(nexus, denyTransfer);
|
||||
|
||||
transferPermission = await LibeufinNexusApi.getAllPermissions(nexus);
|
||||
t.assertTrue(transferPermission["permissions"].length == 0);
|
||||
}
|
||||
|
||||
runLibeufinApiPermissionsTest.suites = ["libeufin"];
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
LibeufinSandboxApi,
|
||||
LibeufinSandboxService,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
// This test only checks that LibEuFin doesn't fail when
|
||||
// it generates Camt statements - no assertions take place.
|
||||
// Furthermore, it prints the Camt.053 being generated.
|
||||
export async function runLibeufinApiSandboxCamtTest(t: GlobalTestState) {
|
||||
const sandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5012,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
});
|
||||
await sandbox.start();
|
||||
await sandbox.pingUntilAvailable();
|
||||
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account-0",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account-1",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-0",
|
||||
"mock-account-1",
|
||||
"EUR:1",
|
||||
"+1",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-0",
|
||||
"mock-account-1",
|
||||
"EUR:1",
|
||||
"+1",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-0",
|
||||
"mock-account-1",
|
||||
"EUR:1",
|
||||
"+1",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-1",
|
||||
"mock-account-0",
|
||||
"EUR:5",
|
||||
"minus 5",
|
||||
);
|
||||
await sandbox.c53tick();
|
||||
let ret = await LibeufinSandboxApi.getCamt053(sandbox, "mock-account-1");
|
||||
console.log(ret);
|
||||
}
|
||||
runLibeufinApiSandboxCamtTest.experimental = true;
|
||||
runLibeufinApiSandboxCamtTest.suites = ["libeufin"];
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
LibeufinSandboxApi,
|
||||
LibeufinSandboxService,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
export async function runLibeufinApiSandboxTransactionsTest(
|
||||
t: GlobalTestState,
|
||||
) {
|
||||
const sandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5012,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
});
|
||||
await sandbox.start();
|
||||
await sandbox.pingUntilAvailable();
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997361",
|
||||
);
|
||||
await LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
sandbox,
|
||||
"mock-account",
|
||||
{
|
||||
debtorIban: "DE84500105176881385584",
|
||||
debtorBic: "BELADEBEXXX",
|
||||
debtorName: "mock2",
|
||||
subject: "mock subject",
|
||||
amount: "EUR:1",
|
||||
},
|
||||
);
|
||||
await LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
sandbox,
|
||||
"mock-account",
|
||||
{
|
||||
debtorIban: "DE84500105176881385584",
|
||||
debtorBic: "BELADEBEXXX",
|
||||
debtorName: "mock2",
|
||||
subject: "mock subject 2",
|
||||
amount: "EUR:1.1",
|
||||
},
|
||||
);
|
||||
let ret = await LibeufinSandboxApi.getAccountInfoWithBalance(
|
||||
sandbox,
|
||||
"mock-account",
|
||||
);
|
||||
t.assertAmountEquals(ret.balance, "EUR:2.1");
|
||||
}
|
||||
runLibeufinApiSandboxTransactionsTest.suites = ["libeufin"];
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
launchLibeufinServices,
|
||||
LibeufinNexusApi,
|
||||
LibeufinNexusService,
|
||||
NexusUserBundle,
|
||||
SandboxUserBundle,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Test Nexus scheduling API. It creates a task, check whether it shows
|
||||
* up, then deletes it, and check if it's gone. Ideally, a check over the
|
||||
* _liveliness_ of a scheduled task should happen.
|
||||
*/
|
||||
export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
|
||||
const nexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
await launchLibeufinServices(t, [user01nexus], [user01sandbox]);
|
||||
await LibeufinNexusApi.postTask(nexus, user01nexus.localAccountName, {
|
||||
name: "test-task",
|
||||
cronspec: "* * *",
|
||||
type: "fetch",
|
||||
params: {
|
||||
level: "all",
|
||||
rangeType: "all",
|
||||
},
|
||||
});
|
||||
let resp = await LibeufinNexusApi.getTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
t.assertTrue(resp.taskName == "test-task");
|
||||
await LibeufinNexusApi.deleteTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
try {
|
||||
await LibeufinNexusApi.getTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
} catch (err: any) {
|
||||
t.assertTrue(err.response.status == 404);
|
||||
}
|
||||
|
||||
// Same with submit task.
|
||||
await LibeufinNexusApi.postTask(nexus, user01nexus.localAccountName, {
|
||||
name: "test-task",
|
||||
cronspec: "* * *",
|
||||
type: "submit",
|
||||
params: {},
|
||||
});
|
||||
resp = await LibeufinNexusApi.getTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
t.assertTrue(resp.taskName == "test-task");
|
||||
await LibeufinNexusApi.deleteTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
try {
|
||||
await LibeufinNexusApi.getTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
} catch (err: any) {
|
||||
t.assertTrue(err.response.status == 404);
|
||||
}
|
||||
}
|
||||
runLibeufinApiSchedulingTest.suites = ["libeufin"];
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import { LibeufinNexusApi, LibeufinNexusService } from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinApiUsersTest(t: GlobalTestState) {
|
||||
const nexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinNexusApi.createUser(nexus, {
|
||||
username: "one",
|
||||
password: "will-be-changed",
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.changePassword(
|
||||
nexus,
|
||||
"one",
|
||||
{
|
||||
newPassword: "got-changed",
|
||||
},
|
||||
{
|
||||
auth: {
|
||||
username: "admin",
|
||||
password: "test",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
let resp = await LibeufinNexusApi.getUser(nexus, {
|
||||
auth: {
|
||||
username: "one",
|
||||
password: "got-changed",
|
||||
},
|
||||
});
|
||||
console.log(resp);
|
||||
t.assertTrue(resp["username"] == "one" && !resp["superuser"]);
|
||||
}
|
||||
|
||||
runLibeufinApiUsersTest.suites = ["libeufin"];
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState, delayMs } from "../harness/harness.js";
|
||||
import {
|
||||
NexusUserBundle,
|
||||
LibeufinNexusApi,
|
||||
LibeufinNexusService,
|
||||
LibeufinSandboxService,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Testing how Nexus reacts when the Sandbox is unreachable.
|
||||
* Typically, because the user specified a wrong EBICS endpoint.
|
||||
*/
|
||||
export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/not-found", // the EBICS endpoint at Sandbox
|
||||
);
|
||||
|
||||
// Start Nexus
|
||||
const libeufinNexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
await libeufinNexus.start();
|
||||
await libeufinNexus.pingUntilAvailable();
|
||||
|
||||
// Start Sandbox
|
||||
const libeufinSandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5010,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
});
|
||||
await libeufinSandbox.start();
|
||||
await libeufinSandbox.pingUntilAvailable();
|
||||
|
||||
// Connecting to a non-existent Sandbox endpoint.
|
||||
await LibeufinNexusApi.createEbicsBankConnection(
|
||||
libeufinNexus,
|
||||
user01nexus.connReq,
|
||||
);
|
||||
|
||||
// 502 Bad Gateway expected.
|
||||
try {
|
||||
await LibeufinNexusApi.connectBankConnection(
|
||||
libeufinNexus,
|
||||
user01nexus.connReq.name,
|
||||
);
|
||||
} catch (e: any) {
|
||||
t.assertTrue(e.response.status == 502);
|
||||
return;
|
||||
}
|
||||
t.assertTrue(false);
|
||||
}
|
||||
runLibeufinBadGatewayTest.suites = ["libeufin"];
|
@ -1,317 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
AbsoluteTime,
|
||||
Duration,
|
||||
MerchantContractTerms,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
|
||||
import {
|
||||
DbInfo,
|
||||
ExchangeService,
|
||||
GlobalTestState,
|
||||
HarnessExchangeBankAccount,
|
||||
MerchantService,
|
||||
WalletClient,
|
||||
setupDb,
|
||||
} from "../harness/harness.js";
|
||||
import {
|
||||
createWalletDaemonWithClient,
|
||||
makeTestPaymentV2,
|
||||
} from "../harness/helpers.js";
|
||||
import {
|
||||
LibeufinNexusApi,
|
||||
LibeufinNexusService,
|
||||
LibeufinSandboxApi,
|
||||
LibeufinSandboxService,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
const exchangeIban = "DE71500105179674997361";
|
||||
const customerIban = "DE84500105176881385584";
|
||||
const customerBic = "BELADEBEXXX";
|
||||
const merchantIban = "DE42500105171245624648";
|
||||
|
||||
export interface LibeufinTestEnvironment {
|
||||
commonDb: DbInfo;
|
||||
exchange: ExchangeService;
|
||||
exchangeBankAccount: HarnessExchangeBankAccount;
|
||||
merchant: MerchantService;
|
||||
walletClient: WalletClient;
|
||||
libeufinSandbox: LibeufinSandboxService;
|
||||
libeufinNexus: LibeufinNexusService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Taler environment with LibEuFin and an EBICS account.
|
||||
*/
|
||||
export async function createLibeufinTestEnvironment(
|
||||
t: GlobalTestState,
|
||||
coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("EUR")),
|
||||
): Promise<LibeufinTestEnvironment> {
|
||||
const db = await setupDb(t);
|
||||
|
||||
const libeufinSandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5010,
|
||||
databaseJdbcUri: db.connStr,
|
||||
});
|
||||
|
||||
await libeufinSandbox.start();
|
||||
await libeufinSandbox.pingUntilAvailable();
|
||||
|
||||
const libeufinNexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: db.connStr,
|
||||
});
|
||||
|
||||
await libeufinNexus.start();
|
||||
await libeufinNexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinSandboxApi.createEbicsHost(libeufinSandbox, "host01");
|
||||
// Subscriber and bank Account for the exchange
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"exchangeacct",
|
||||
"password-unused",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
exchangeIban,
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
{
|
||||
hostID: "host01",
|
||||
partnerID: "partner01",
|
||||
userID: "user01",
|
||||
},
|
||||
"exchangeacct",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" },
|
||||
);
|
||||
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"merchantacct",
|
||||
"password-unused",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
merchantIban,
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
{
|
||||
hostID: "host01",
|
||||
partnerID: "partner02",
|
||||
userID: "user02",
|
||||
},
|
||||
"merchantacct",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" },
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.createEbicsBankConnection(libeufinNexus, {
|
||||
name: "myconn",
|
||||
ebicsURL: "http://localhost:5010/ebicsweb",
|
||||
hostID: "host01",
|
||||
partnerID: "partner01",
|
||||
userID: "user01",
|
||||
});
|
||||
await LibeufinNexusApi.connectBankConnection(libeufinNexus, "myconn");
|
||||
await LibeufinNexusApi.fetchAccounts(libeufinNexus, "myconn");
|
||||
await LibeufinNexusApi.importConnectionAccount(
|
||||
libeufinNexus,
|
||||
"myconn",
|
||||
"exchangeacct",
|
||||
"myacct",
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.createTwgFacade(libeufinNexus, {
|
||||
name: "twg1",
|
||||
accountName: "myacct",
|
||||
connectionName: "myconn",
|
||||
currency: "EUR",
|
||||
reserveTransferLevel: "report",
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.createUser(libeufinNexus, {
|
||||
username: "twguser",
|
||||
password: "twgpw",
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.postPermission(libeufinNexus, {
|
||||
action: "grant",
|
||||
permission: {
|
||||
subjectType: "user",
|
||||
subjectId: "twguser",
|
||||
resourceType: "facade",
|
||||
resourceId: "twg1",
|
||||
permissionName: "facade.talerWireGateway.history",
|
||||
},
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.postPermission(libeufinNexus, {
|
||||
action: "grant",
|
||||
permission: {
|
||||
subjectType: "user",
|
||||
subjectId: "twguser",
|
||||
resourceType: "facade",
|
||||
resourceId: "twg1",
|
||||
permissionName: "facade.talerWireGateway.transfer",
|
||||
},
|
||||
});
|
||||
|
||||
const exchange = ExchangeService.create(t, {
|
||||
name: "testexchange-1",
|
||||
currency: "EUR",
|
||||
httpPort: 8081,
|
||||
database: db.connStr,
|
||||
});
|
||||
|
||||
const merchant = await MerchantService.create(t, {
|
||||
name: "testmerchant-1",
|
||||
currency: "EUR",
|
||||
httpPort: 8083,
|
||||
database: db.connStr,
|
||||
});
|
||||
|
||||
const exchangeBankAccount: HarnessExchangeBankAccount = {
|
||||
accountName: "twguser",
|
||||
accountPassword: "twgpw",
|
||||
accountPaytoUri: `payto://iban/${exchangeIban}?receiver-name=Exchange`,
|
||||
wireGatewayApiBaseUrl:
|
||||
"http://localhost:5011/facades/twg1/taler-wire-gateway/",
|
||||
};
|
||||
|
||||
exchange.addBankAccount("1", exchangeBankAccount);
|
||||
|
||||
exchange.addCoinConfigList(coinConfig);
|
||||
|
||||
await exchange.start();
|
||||
await exchange.pingUntilAvailable();
|
||||
|
||||
merchant.addExchange(exchange);
|
||||
|
||||
await merchant.start();
|
||||
await merchant.pingUntilAvailable();
|
||||
|
||||
await merchant.addInstanceWithWireAccount({
|
||||
id: "default",
|
||||
name: "Default Instance",
|
||||
paytoUris: [`payto://iban/${merchantIban}?receiver-name=Merchant`],
|
||||
defaultWireTransferDelay: Duration.toTalerProtocolDuration(
|
||||
Duration.getZero(),
|
||||
),
|
||||
});
|
||||
|
||||
console.log("setup done!");
|
||||
|
||||
const { walletClient } = await createWalletDaemonWithClient(t, {
|
||||
name: "default",
|
||||
});
|
||||
|
||||
return {
|
||||
commonDb: db,
|
||||
exchange,
|
||||
merchant,
|
||||
walletClient,
|
||||
exchangeBankAccount,
|
||||
libeufinNexus,
|
||||
libeufinSandbox,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinBasicTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const { walletClient, exchange, merchant, libeufinSandbox, libeufinNexus } =
|
||||
await createLibeufinTestEnvironment(t);
|
||||
|
||||
await walletClient.call(WalletApiOperation.AddExchange, {
|
||||
exchangeBaseUrl: exchange.baseUrl,
|
||||
});
|
||||
|
||||
const wr = await walletClient.call(
|
||||
WalletApiOperation.AcceptManualWithdrawal,
|
||||
{
|
||||
exchangeBaseUrl: exchange.baseUrl,
|
||||
amount: "EUR:15",
|
||||
},
|
||||
);
|
||||
|
||||
const reservePub: string = wr.reservePub;
|
||||
|
||||
await LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
libeufinSandbox,
|
||||
"exchangeacct",
|
||||
{
|
||||
amount: "EUR:15.00",
|
||||
debtorBic: customerBic,
|
||||
debtorIban: customerIban,
|
||||
debtorName: "Jane Customer",
|
||||
subject: `Taler Top-up ${reservePub}`,
|
||||
},
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(libeufinNexus, "myacct");
|
||||
|
||||
await exchange.runWirewatchOnce();
|
||||
|
||||
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
|
||||
|
||||
const bal = await walletClient.call(WalletApiOperation.GetBalances, {});
|
||||
console.log("balances", JSON.stringify(bal, undefined, 2));
|
||||
t.assertAmountEquals(bal.balances[0].available, "EUR:14.7");
|
||||
|
||||
const order: Partial<MerchantContractTerms> = {
|
||||
summary: "Buy me!",
|
||||
amount: "EUR:5",
|
||||
fulfillment_url: "taler://fulfillment-success/thx",
|
||||
wire_transfer_deadline: AbsoluteTime.toProtocolTimestamp(
|
||||
AbsoluteTime.now(),
|
||||
),
|
||||
};
|
||||
|
||||
await makeTestPaymentV2(t, { walletClient, merchant, order });
|
||||
|
||||
await exchange.runAggregatorOnce();
|
||||
await exchange.runTransferOnce();
|
||||
|
||||
await LibeufinNexusApi.submitAllPaymentInitiations(libeufinNexus, "myacct");
|
||||
|
||||
const exchangeTransactions = await LibeufinSandboxApi.getAccountTransactions(
|
||||
libeufinSandbox,
|
||||
"exchangeacct",
|
||||
);
|
||||
|
||||
console.log(
|
||||
"exchange transactions:",
|
||||
JSON.stringify(exchangeTransactions, undefined, 2),
|
||||
);
|
||||
|
||||
t.assertDeepEqual(
|
||||
exchangeTransactions.payments[0].creditDebitIndicator,
|
||||
"credit",
|
||||
);
|
||||
t.assertDeepEqual(
|
||||
exchangeTransactions.payments[1].creditDebitIndicator,
|
||||
"debit",
|
||||
);
|
||||
t.assertDeepEqual(exchangeTransactions.payments[1].debtorIban, exchangeIban);
|
||||
t.assertDeepEqual(
|
||||
exchangeTransactions.payments[1].creditorIban,
|
||||
merchantIban,
|
||||
);
|
||||
}
|
||||
runLibeufinBasicTest.suites = ["libeufin"];
|
@ -1,147 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
launchLibeufinServices,
|
||||
LibeufinNexusApi,
|
||||
NexusUserBundle,
|
||||
SandboxUserBundle,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* This test checks how the C52 and C53 coordinate. It'll test
|
||||
* whether fresh transactions stop showing as C52 after they get
|
||||
* included in a bank statement.
|
||||
*/
|
||||
export async function runLibeufinC5xTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* User saltetd "02".
|
||||
*/
|
||||
const user02nexus = new NexusUserBundle(
|
||||
"02",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user02sandbox = new SandboxUserBundle("02");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus, user02nexus],
|
||||
[user01sandbox, user02sandbox],
|
||||
["twg"],
|
||||
);
|
||||
|
||||
// Check that C52 and C53 have zero entries.
|
||||
|
||||
// C52
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // level
|
||||
);
|
||||
// C53
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"statement", // level
|
||||
);
|
||||
const nexusTxs = await LibeufinNexusApi.getAccountTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
t.assertTrue(nexusTxs["transactions"].length == 0);
|
||||
|
||||
// Addressing one payment to user 01
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user02sandbox.ebicsBankAccount.label, // debit
|
||||
user01sandbox.ebicsBankAccount.label, // credit
|
||||
"EUR:10",
|
||||
"first payment",
|
||||
);
|
||||
|
||||
let expectOne = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // C52
|
||||
);
|
||||
t.assertTrue(expectOne.newTransactions == 1);
|
||||
t.assertTrue(expectOne.downloadedTransactions == 1);
|
||||
|
||||
/* Expect zero payments being downloaded because the
|
||||
* previous request consumed already the one pending
|
||||
* payment.
|
||||
*/
|
||||
let expectZero = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // C52
|
||||
);
|
||||
t.assertTrue(expectZero.newTransactions == 0);
|
||||
t.assertTrue(expectZero.downloadedTransactions == 0);
|
||||
|
||||
/**
|
||||
* A statement should still account zero payments because
|
||||
* so far the payment made before is still pending.
|
||||
*/
|
||||
expectZero = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"statement", // C53
|
||||
);
|
||||
t.assertTrue(expectZero.newTransactions == 0);
|
||||
t.assertTrue(expectZero.downloadedTransactions == 0);
|
||||
|
||||
/**
|
||||
* Ticking now. That books any pending transaction.
|
||||
*/
|
||||
await libeufinServices.libeufinSandbox.c53tick();
|
||||
|
||||
/**
|
||||
* A statement is now expected to download the transaction,
|
||||
* although that got already ingested along the report
|
||||
* earlier. Thus the transaction counts as downloaded but
|
||||
* not as new.
|
||||
*/
|
||||
expectOne = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"statement", // C53
|
||||
);
|
||||
t.assertTrue(expectOne.downloadedTransactions == 1);
|
||||
t.assertTrue(expectOne.newTransactions == 0);
|
||||
}
|
||||
runLibeufinC5xTest.suites = ["libeufin"];
|
@ -1,179 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinNexusApi,
|
||||
LibeufinSandboxApi,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Testing the Anastasis API, offered by the Anastasis facade.
|
||||
*/
|
||||
export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus],
|
||||
[user01sandbox],
|
||||
["anastasis"], // create only one Anastasis facade.
|
||||
);
|
||||
let resp = await LibeufinNexusApi.getAllFacades(
|
||||
libeufinServices.libeufinNexus,
|
||||
);
|
||||
// check that original facade shows up.
|
||||
t.assertTrue(
|
||||
resp["facades"][0]["name"] == user01nexus.anastasisReq["name"],
|
||||
);
|
||||
const anastasisBaseUrl: string = resp["facades"][0]["baseUrl"];
|
||||
t.assertTrue(typeof anastasisBaseUrl === "string");
|
||||
t.assertTrue(anastasisBaseUrl.startsWith("http://"));
|
||||
t.assertTrue(anastasisBaseUrl.endsWith("/"));
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.postPermission(libeufinServices.libeufinNexus, {
|
||||
action: "grant",
|
||||
permission: {
|
||||
subjectId: user01nexus.userReq.username,
|
||||
subjectType: "user",
|
||||
resourceType: "facade",
|
||||
resourceId: user01nexus.anastasisReq.name,
|
||||
permissionName: "facade.anastasis.history",
|
||||
},
|
||||
});
|
||||
|
||||
// check if empty.
|
||||
let txsEmpty = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{ delta: 5 },
|
||||
);
|
||||
|
||||
t.assertTrue(txsEmpty.data.incoming_transactions.length == 0);
|
||||
|
||||
LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user01sandbox.ebicsBankAccount.label,
|
||||
{
|
||||
debtorIban: "ES3314655813489414469157",
|
||||
debtorBic: "BCMAESM1XXX",
|
||||
debtorName: "Mock Donor",
|
||||
subject: "Anastasis donation",
|
||||
amount: "EUR:3", // Sandbox takes currency from its 'config'
|
||||
},
|
||||
);
|
||||
|
||||
LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user01sandbox.ebicsBankAccount.label,
|
||||
{
|
||||
debtorIban: "ES3314655813489414469157",
|
||||
debtorBic: "BCMAESM1XXX",
|
||||
debtorName: "Mock Donor",
|
||||
subject: "another Anastasis donation",
|
||||
amount: "EUR:1", // Sandbox takes currency from its "config"
|
||||
},
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
||||
let txs = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{ delta: 5 },
|
||||
user01nexus.userReq.username,
|
||||
user01nexus.userReq.password,
|
||||
);
|
||||
|
||||
// check the two payments show up
|
||||
let txsList = txs.data.incoming_transactions;
|
||||
t.assertTrue(txsList.length == 2);
|
||||
t.assertTrue(
|
||||
[txsList[0].subject, txsList[1].subject].includes("Anastasis donation"),
|
||||
);
|
||||
t.assertTrue(
|
||||
[txsList[0].subject, txsList[1].subject].includes(
|
||||
"another Anastasis donation",
|
||||
),
|
||||
);
|
||||
t.assertTrue(txsList[0].row_id == 1);
|
||||
t.assertTrue(txsList[1].row_id == 2);
|
||||
|
||||
LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user01sandbox.ebicsBankAccount.label,
|
||||
{
|
||||
debtorIban: "ES3314655813489414469157",
|
||||
debtorBic: "BCMAESM1XXX",
|
||||
debtorName: "Mock Donor",
|
||||
subject: "last Anastasis donation",
|
||||
amount: "EUR:10.10", // Sandbox takes currency from its "config"
|
||||
},
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
||||
let txsLast = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{ delta: 5, start: 2 },
|
||||
user01nexus.userReq.username,
|
||||
user01nexus.userReq.password,
|
||||
);
|
||||
console.log(
|
||||
txsLast.data.incoming_transactions[0].subject == "last Anastasis donation",
|
||||
);
|
||||
|
||||
let txsReverse = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{ delta: -5, start: 4 },
|
||||
user01nexus.userReq.username,
|
||||
user01nexus.userReq.password,
|
||||
);
|
||||
t.assertTrue(txsReverse.data.incoming_transactions[0].row_id == 3);
|
||||
t.assertTrue(txsReverse.data.incoming_transactions[1].row_id == 2);
|
||||
t.assertTrue(txsReverse.data.incoming_transactions[2].row_id == 1);
|
||||
}
|
||||
|
||||
runLibeufinAnastasisFacadeTest.suites = ["libeufin"];
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinSandboxApi,
|
||||
LibeufinNexusApi,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus],
|
||||
[user01sandbox],
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
||||
/* Rotate the Sandbox keys, and fetch the transactions again */
|
||||
await LibeufinSandboxApi.rotateKeys(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user01sandbox.ebicsBankAccount.subscriber.hostID,
|
||||
);
|
||||
|
||||
try {
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
} catch (e: any) {
|
||||
/**
|
||||
* Asserting that Nexus responded with a 500 Internal server
|
||||
* error, because the bank signed the last response with a new
|
||||
* key pair that was never downloaded by Nexus.
|
||||
*
|
||||
* NOTE: the bank accepted the request addressed to the old
|
||||
* public key. Should it in this case reject the request even
|
||||
* before trying to verify it?
|
||||
*/
|
||||
t.assertTrue(e.response.status == 500);
|
||||
// FIXME: uncomment and adapt the following command after #6723 is fixed.
|
||||
// t.assertTrue(e.response.data.code == 9000);
|
||||
}
|
||||
}
|
||||
runLibeufinKeyrotationTest.suites = ["libeufin"];
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinNexusApi,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* This test checks how the C52 and C53 coordinate. It'll test
|
||||
* whether fresh transactions stop showing as C52 after they get
|
||||
* included in a bank statement.
|
||||
*/
|
||||
export async function runLibeufinNexusBalanceTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* User saltetd "02".
|
||||
*/
|
||||
const user02nexus = new NexusUserBundle(
|
||||
"02",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user02sandbox = new SandboxUserBundle("02");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus, user02nexus],
|
||||
[user01sandbox, user02sandbox],
|
||||
["twg"],
|
||||
);
|
||||
|
||||
// user 01 gets 10
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user02sandbox.ebicsBankAccount.label, // debit
|
||||
user01sandbox.ebicsBankAccount.label, // credit
|
||||
"EUR:10",
|
||||
"first payment",
|
||||
);
|
||||
// user 01 gets another 10
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user02sandbox.ebicsBankAccount.label, // debit
|
||||
user01sandbox.ebicsBankAccount.label, // credit
|
||||
"EUR:10",
|
||||
"second payment",
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // level
|
||||
);
|
||||
|
||||
// Check that user 01 has 20, via Nexus.
|
||||
let accountInfo = await LibeufinNexusApi.getBankAccount(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
t.assertAmountEquals(accountInfo.data.lastSeenBalance, "EUR:20");
|
||||
|
||||
// Booking the first two transactions.
|
||||
await libeufinServices.libeufinSandbox.c53tick();
|
||||
|
||||
// user 01 gives 30
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user01sandbox.ebicsBankAccount.label,
|
||||
user02sandbox.ebicsBankAccount.label,
|
||||
"EUR:30",
|
||||
"third payment",
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // level
|
||||
);
|
||||
|
||||
let accountInfoDebit = await LibeufinNexusApi.getBankAccount(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
t.assertDeepEqual(accountInfoDebit.data.lastSeenBalance, "-EUR:10");
|
||||
}
|
||||
|
||||
runLibeufinNexusBalanceTest.suites = ["libeufin"];
|
||||
runLibeufinNexusBalanceTest.experimental = true;
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState, delayMs } from "../harness/harness.js";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinSandboxApi,
|
||||
LibeufinNexusApi,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* User 01 expects a refund from user 02, and expectedly user 03
|
||||
* should not be involved in the process.
|
||||
*/
|
||||
export async function runLibeufinRefundMultipleUsersTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* User saltetd "02"
|
||||
*/
|
||||
const user02nexus = new NexusUserBundle(
|
||||
"02",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user02sandbox = new SandboxUserBundle("02");
|
||||
|
||||
/**
|
||||
* User saltetd "03"
|
||||
*/
|
||||
const user03nexus = new NexusUserBundle(
|
||||
"03",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user03sandbox = new SandboxUserBundle("03");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus, user02nexus],
|
||||
[user01sandbox, user02sandbox],
|
||||
["twg"],
|
||||
);
|
||||
|
||||
// user 01 gets the payment
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user02sandbox.ebicsBankAccount.label, // debit
|
||||
user01sandbox.ebicsBankAccount.label, // credit
|
||||
"EUR:1",
|
||||
"not a public key",
|
||||
);
|
||||
|
||||
// user 01 fetches the payments
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
||||
// user 01 tries to submit the reimbursement, as
|
||||
// the payment didn't have a valid public key in
|
||||
// the subject.
|
||||
await LibeufinNexusApi.submitInitiatedPayment(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"1", // so far the only one that can exist.
|
||||
);
|
||||
|
||||
// user 02 checks whether a reimbursement arrived.
|
||||
let history = await LibeufinSandboxApi.getAccountTransactions(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user02sandbox.ebicsBankAccount["label"],
|
||||
);
|
||||
// reimbursement arrived IFF the total payments are 2:
|
||||
// 1 the original (faulty) transaction + 1 the reimbursement.
|
||||
t.assertTrue(history["payments"].length == 2);
|
||||
}
|
||||
|
||||
runLibeufinRefundMultipleUsersTest.suites = ["libeufin"];
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState, delayMs } from "../harness/harness.js";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinSandboxApi,
|
||||
LibeufinNexusApi,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinRefundTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* User saltetd "02"
|
||||
*/
|
||||
const user02nexus = new NexusUserBundle(
|
||||
"02",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user02sandbox = new SandboxUserBundle("02");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus, user02nexus],
|
||||
[user01sandbox, user02sandbox],
|
||||
["twg"],
|
||||
);
|
||||
|
||||
// user 02 pays user 01 with a faulty (non Taler) subject.
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user02sandbox.ebicsBankAccount.label, // debit
|
||||
user01sandbox.ebicsBankAccount.label, // credit
|
||||
"EUR:1",
|
||||
"not a public key",
|
||||
);
|
||||
|
||||
// The bad payment should be now ingested and prepared as
|
||||
// a reimbursement.
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
// Check that the payment arrived at the Nexus.
|
||||
const nexusTxs = await LibeufinNexusApi.getAccountTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
t.assertTrue(nexusTxs["transactions"].length == 1);
|
||||
|
||||
// Submit the reimbursement
|
||||
await LibeufinNexusApi.submitInitiatedPayment(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
// The initiated payment (= the reimbursement) ID below
|
||||
// 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",
|
||||
);
|
||||
|
||||
// user 02 checks whether the reimbursement arrived.
|
||||
let history = await LibeufinSandboxApi.getAccountTransactions(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user02sandbox.ebicsBankAccount["label"],
|
||||
);
|
||||
// 2 payments must exist: 1 the original (faulty) payment +
|
||||
// 1 the reimbursement.
|
||||
t.assertTrue(history["payments"].length == 2);
|
||||
}
|
||||
runLibeufinRefundTest.suites = ["libeufin"];
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
LibeufinSandboxApi,
|
||||
LibeufinSandboxService,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
export async function runLibeufinSandboxWireTransferCliTest(
|
||||
t: GlobalTestState,
|
||||
) {
|
||||
const sandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5012,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
});
|
||||
await sandbox.start();
|
||||
await sandbox.pingUntilAvailable();
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997361",
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account-2",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997364",
|
||||
);
|
||||
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account",
|
||||
"mock-account-2",
|
||||
"EUR:1",
|
||||
"one!",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account",
|
||||
"mock-account-2",
|
||||
"EUR:1",
|
||||
"two!",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account",
|
||||
"mock-account-2",
|
||||
"EUR:1",
|
||||
"three!",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-2",
|
||||
"mock-account",
|
||||
"EUR:1",
|
||||
"Give one back.",
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-2",
|
||||
"mock-account",
|
||||
"EUR:0.11",
|
||||
"Give fraction back.",
|
||||
);
|
||||
let ret = await LibeufinSandboxApi.getAccountInfoWithBalance(
|
||||
sandbox,
|
||||
"mock-account-2",
|
||||
);
|
||||
console.log(ret.balance);
|
||||
t.assertTrue(ret.balance == "EUR:1.89");
|
||||
}
|
||||
runLibeufinSandboxWireTransferCliTest.suites = ["libeufin"];
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 Taler Systems S.A.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import {
|
||||
LibeufinNexusService,
|
||||
LibeufinSandboxService,
|
||||
LibeufinCli,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
* Run basic test with LibEuFin.
|
||||
*/
|
||||
export async function runLibeufinTutorialTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const libeufinSandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5010,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
});
|
||||
|
||||
await libeufinSandbox.start();
|
||||
await libeufinSandbox.pingUntilAvailable();
|
||||
|
||||
const libeufinNexus = await LibeufinNexusService.create(t, {
|
||||
httpPort: 5011,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
});
|
||||
|
||||
const nexusUser = { username: "foo", password: "secret" };
|
||||
const libeufinCli = new LibeufinCli(t, {
|
||||
sandboxUrl: libeufinSandbox.baseUrl,
|
||||
nexusUrl: libeufinNexus.baseUrl,
|
||||
sandboxDatabaseUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
nexusDatabaseUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
||||
nexusUser: nexusUser,
|
||||
});
|
||||
|
||||
const ebicsDetails = {
|
||||
hostId: "testhost",
|
||||
partnerId: "partner01",
|
||||
userId: "user01",
|
||||
};
|
||||
const bankAccountDetails = {
|
||||
currency: "EUR",
|
||||
iban: "DE18500105172929531888",
|
||||
bic: "INGDDEFFXXX",
|
||||
personName: "Jane Normal",
|
||||
accountName: "testacct01",
|
||||
};
|
||||
|
||||
await libeufinCli.checkSandbox();
|
||||
await libeufinCli.createEbicsHost("testhost");
|
||||
await libeufinCli.createEbicsSubscriber(ebicsDetails);
|
||||
await libeufinCli.createEbicsBankAccount(ebicsDetails, bankAccountDetails);
|
||||
await libeufinCli.generateTransactions(bankAccountDetails.accountName);
|
||||
|
||||
await libeufinNexus.start();
|
||||
await libeufinNexus.pingUntilAvailable();
|
||||
|
||||
await libeufinNexus.createNexusSuperuser(nexusUser);
|
||||
const connectionDetails = {
|
||||
subscriberDetails: ebicsDetails,
|
||||
ebicsUrl: `${libeufinSandbox.baseUrl}ebicsweb`, // FIXME: need appropriate URL concatenation
|
||||
connectionName: "my-ebics-conn",
|
||||
};
|
||||
await libeufinCli.createEbicsConnection(connectionDetails);
|
||||
await libeufinCli.createBackupFile({
|
||||
passphrase: "secret",
|
||||
outputFile: `${t.testDir}/connection-backup.json`,
|
||||
connectionName: connectionDetails.connectionName,
|
||||
});
|
||||
await libeufinCli.createKeyLetter({
|
||||
outputFile: `${t.testDir}/letter.pdf`,
|
||||
connectionName: connectionDetails.connectionName,
|
||||
});
|
||||
await libeufinCli.connect(connectionDetails.connectionName);
|
||||
await libeufinCli.downloadBankAccounts(connectionDetails.connectionName);
|
||||
await libeufinCli.listOfferedBankAccounts(connectionDetails.connectionName);
|
||||
|
||||
const bankAccountImportDetails = {
|
||||
offeredBankAccountName: bankAccountDetails.accountName,
|
||||
nexusBankAccountName: "at-nexus-testacct01",
|
||||
connectionName: connectionDetails.connectionName,
|
||||
};
|
||||
|
||||
await libeufinCli.importBankAccount(bankAccountImportDetails);
|
||||
await libeufinSandbox.c53tick();
|
||||
await libeufinCli.fetchTransactions(
|
||||
bankAccountImportDetails.nexusBankAccountName,
|
||||
);
|
||||
await libeufinCli.transactions(bankAccountImportDetails.nexusBankAccountName);
|
||||
|
||||
const paymentDetails = {
|
||||
creditorIban: "DE42500105171245624648",
|
||||
creditorBic: "BELADEBEXXX",
|
||||
creditorName: "Mina Musterfrau",
|
||||
subject: "Purchase 01234",
|
||||
amount: "1.0",
|
||||
currency: "EUR",
|
||||
nexusBankAccountName: bankAccountImportDetails.nexusBankAccountName,
|
||||
};
|
||||
await libeufinCli.preparePayment(paymentDetails);
|
||||
await libeufinCli.submitPayment(paymentDetails, "1");
|
||||
|
||||
await libeufinCli.newTalerWireGatewayFacade({
|
||||
accountName: bankAccountImportDetails.nexusBankAccountName,
|
||||
connectionName: "my-ebics-conn",
|
||||
currency: "EUR",
|
||||
facadeName: "my-twg",
|
||||
});
|
||||
await libeufinCli.listFacades();
|
||||
}
|
||||
runLibeufinTutorialTest.suites = ["libeufin"];
|
@ -22,7 +22,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
CoreApiResponse,
|
||||
MerchantApiClient,
|
||||
} from "@gnu-taler/taler-util";
|
||||
@ -127,7 +127,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
|
||||
|
||||
// Create withdrawal operation
|
||||
|
||||
const bankClient = new BankAccessApiClient(bank.bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bank.bankAccessApiBaseUrl);
|
||||
|
||||
const user = await bankClient.createRandomBankUser();
|
||||
const wop = await bankClient.createWithdrawalOperation(
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
MerchantApiClient,
|
||||
TransactionMajorState,
|
||||
WireGatewayApiClient,
|
||||
@ -38,7 +38,7 @@ export async function runTippingTest(t: GlobalTestState) {
|
||||
const { walletClient, bank, exchange, merchant, exchangeBankAccount } =
|
||||
await createSimpleTestkudosEnvironmentV2(t);
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
bank.bankAccessApiBaseUrl,
|
||||
);
|
||||
const mbu = await bankAccessApiClient.createRandomBankUser();
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
Duration,
|
||||
NotificationType,
|
||||
TransactionMajorState,
|
||||
@ -121,7 +121,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {
|
||||
skipDefaults: true,
|
||||
});
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
bank.bankAccessApiBaseUrl,
|
||||
);
|
||||
const user = await bankAccessApiClient.createRandomBankUser();
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { BankAccessApiClient, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||
import { TalerCorebankApiClient, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||
import { GlobalTestState } from "../harness/harness.js";
|
||||
import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js";
|
||||
@ -33,7 +33,7 @@ export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
|
||||
|
||||
// Create a withdrawal operation
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
bank.bankAccessApiBaseUrl,
|
||||
);
|
||||
const user = await bankAccessApiClient.createRandomBankUser();
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
j2s,
|
||||
NotificationType,
|
||||
TransactionMajorState,
|
||||
@ -41,7 +41,7 @@ export async function runWithdrawalBankIntegratedTest(t: GlobalTestState) {
|
||||
|
||||
// Create a withdrawal operation
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
bank.bankAccessApiBaseUrl,
|
||||
);
|
||||
const user = await bankAccessApiClient.createRandomBankUser();
|
||||
|
@ -54,7 +54,10 @@ export async function runWithdrawalFakebankTest(t: GlobalTestState) {
|
||||
exchange.addBankAccount("1", {
|
||||
accountName: "exchange",
|
||||
accountPassword: "x",
|
||||
wireGatewayApiBaseUrl: new URL("/exchange/", bank.baseUrl).href,
|
||||
wireGatewayApiBaseUrl: new URL(
|
||||
"/accounts/exchange/taler-wire-gateway",
|
||||
bank.baseUrl,
|
||||
).href,
|
||||
accountPaytoUri: "payto://x-taler-bank/localhost/exchange",
|
||||
});
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { BankAccessApiClient, j2s } from "@gnu-taler/taler-util";
|
||||
import { TalerCorebankApiClient, j2s } from "@gnu-taler/taler-util";
|
||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||
import { CoinConfig } from "../harness/denomStructures.js";
|
||||
import {
|
||||
@ -107,7 +107,7 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) {
|
||||
|
||||
const amount = "TESTKUDOS:7.5";
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
bank.bankAccessApiBaseUrl,
|
||||
);
|
||||
const user = await bankAccessApiClient.createRandomBankUser();
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
import {
|
||||
AbsoluteTime,
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
Logger,
|
||||
WireGatewayApiClient,
|
||||
j2s,
|
||||
@ -41,7 +41,7 @@ export async function runWithdrawalManualTest(t: GlobalTestState) {
|
||||
|
||||
// Create a withdrawal operation
|
||||
|
||||
const bankAccessApiClient = new BankAccessApiClient(
|
||||
const bankAccessApiClient = new TalerCorebankApiClient(
|
||||
bank.bankAccessApiBaseUrl,
|
||||
);
|
||||
|
||||
|
@ -43,25 +43,6 @@ import { runExchangeTimetravelTest } from "./test-exchange-timetravel.js";
|
||||
import { runFeeRegressionTest } from "./test-fee-regression.js";
|
||||
import { runForcedSelectionTest } from "./test-forced-selection.js";
|
||||
import { runKycTest } from "./test-kyc.js";
|
||||
import { runLibeufinApiBankaccountTest } from "./test-libeufin-api-bankaccount.js";
|
||||
import { runLibeufinApiBankconnectionTest } from "./test-libeufin-api-bankconnection.js";
|
||||
import { runLibeufinApiFacadeBadRequestTest } from "./test-libeufin-api-facade-bad-request.js";
|
||||
import { runLibeufinApiFacadeTest } from "./test-libeufin-api-facade.js";
|
||||
import { runLibeufinApiPermissionsTest } from "./test-libeufin-api-permissions.js";
|
||||
import { runLibeufinApiSandboxCamtTest } from "./test-libeufin-api-sandbox-camt.js";
|
||||
import { runLibeufinApiSandboxTransactionsTest } from "./test-libeufin-api-sandbox-transactions.js";
|
||||
import { runLibeufinApiSchedulingTest } from "./test-libeufin-api-scheduling.js";
|
||||
import { runLibeufinApiUsersTest } from "./test-libeufin-api-users.js";
|
||||
import { runLibeufinBadGatewayTest } from "./test-libeufin-bad-gateway.js";
|
||||
import { runLibeufinBasicTest } from "./test-libeufin-basic.js";
|
||||
import { runLibeufinC5xTest } from "./test-libeufin-c5x.js";
|
||||
import { runLibeufinAnastasisFacadeTest } from "./test-libeufin-facade-anastasis.js";
|
||||
import { runLibeufinKeyrotationTest } from "./test-libeufin-keyrotation.js";
|
||||
import { runLibeufinNexusBalanceTest } from "./test-libeufin-nexus-balance.js";
|
||||
import { runLibeufinRefundMultipleUsersTest } from "./test-libeufin-refund-multiple-users.js";
|
||||
import { runLibeufinRefundTest } from "./test-libeufin-refund.js";
|
||||
import { runLibeufinSandboxWireTransferCliTest } from "./test-libeufin-sandbox-wire-transfer-cli.js";
|
||||
import { runLibeufinTutorialTest } from "./test-libeufin-tutorial.js";
|
||||
import { runMerchantExchangeConfusionTest } from "./test-merchant-exchange-confusion.js";
|
||||
import { runMerchantInstancesDeleteTest } from "./test-merchant-instances-delete.js";
|
||||
import { runMerchantInstancesUrlsTest } from "./test-merchant-instances-urls.js";
|
||||
@ -144,25 +125,6 @@ const allTests: TestMainFunction[] = [
|
||||
runKycTest,
|
||||
runExchangePurseTest,
|
||||
runExchangeDepositTest,
|
||||
runLibeufinAnastasisFacadeTest,
|
||||
runLibeufinApiBankaccountTest,
|
||||
runLibeufinApiBankconnectionTest,
|
||||
runLibeufinApiFacadeBadRequestTest,
|
||||
runLibeufinApiFacadeTest,
|
||||
runLibeufinApiPermissionsTest,
|
||||
runLibeufinApiSandboxCamtTest,
|
||||
runLibeufinApiSandboxTransactionsTest,
|
||||
runLibeufinApiSchedulingTest,
|
||||
runLibeufinApiUsersTest,
|
||||
runLibeufinBadGatewayTest,
|
||||
runLibeufinBasicTest,
|
||||
runLibeufinC5xTest,
|
||||
runLibeufinKeyrotationTest,
|
||||
runLibeufinNexusBalanceTest,
|
||||
runLibeufinRefundMultipleUsersTest,
|
||||
runLibeufinRefundTest,
|
||||
runLibeufinSandboxWireTransferCliTest,
|
||||
runLibeufinTutorialTest,
|
||||
runMerchantExchangeConfusionTest,
|
||||
runMerchantInstancesDeleteTest,
|
||||
runMerchantInstancesTest,
|
||||
|
@ -146,11 +146,87 @@ export class WireGatewayApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChallengeContactData {
|
||||
// E-Mail address
|
||||
email?: string;
|
||||
|
||||
// Phone number.
|
||||
phone?: string;
|
||||
}
|
||||
|
||||
export interface Balance {
|
||||
amount: AmountString;
|
||||
credit_debit_indicator: "credit" | "debit";
|
||||
}
|
||||
|
||||
export interface RegisterAccountRequest {
|
||||
// Username
|
||||
username: string;
|
||||
|
||||
// Password.
|
||||
password: string;
|
||||
|
||||
// Legal name of the account owner
|
||||
name: string;
|
||||
|
||||
// Defaults to false.
|
||||
is_public?: boolean;
|
||||
|
||||
// Is this a taler exchange account?
|
||||
// If true:
|
||||
// - incoming transactions to the account that do not
|
||||
// have a valid reserve public key are automatically
|
||||
// - the account provides the taler-wire-gateway-api endpoints
|
||||
// Defaults to false.
|
||||
is_taler_exchange?: boolean;
|
||||
|
||||
// Addresses where to send the TAN for transactions.
|
||||
// Currently only used for cashouts.
|
||||
// If missing, cashouts will fail.
|
||||
// In the future, might be used for other transactions
|
||||
// as well.
|
||||
challenge_contact_data?: ChallengeContactData;
|
||||
|
||||
// 'payto' address pointing a bank account
|
||||
// external to the libeufin-bank.
|
||||
// Payments will be sent to this bank account
|
||||
// when the user wants to convert the local currency
|
||||
// back to fiat currency outside libeufin-bank.
|
||||
cashout_payto_uri?: string;
|
||||
|
||||
// Internal payto URI of this bank account.
|
||||
// Used mostly for testing.
|
||||
internal_payto_uri?: string;
|
||||
}
|
||||
|
||||
export interface AccountData {
|
||||
// Legal name of the account owner.
|
||||
name: string;
|
||||
|
||||
// Available balance on the account.
|
||||
balance: Balance;
|
||||
|
||||
// payto://-URI of the account.
|
||||
payto_uri: string;
|
||||
|
||||
// Number indicating the max debit allowed for the requesting user.
|
||||
debit_threshold: AmountString;
|
||||
|
||||
contact_data?: ChallengeContactData;
|
||||
|
||||
// 'payto' address pointing the bank account
|
||||
// where to send cashouts. This field is optional
|
||||
// because not all the accounts are required to participate
|
||||
// in the merchants' circuit. One example is the exchange:
|
||||
// that never cashouts. Registering these accounts can
|
||||
// be done via the access API.
|
||||
cashout_payto_uri?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This API look like it belongs to harness
|
||||
* but it will be nice to have in utils to be used by others
|
||||
* Client for the Taler corebank API.
|
||||
*/
|
||||
export class BankAccessApiClient {
|
||||
export class TalerCorebankApiClient {
|
||||
httpLib: HttpRequestLibrary;
|
||||
|
||||
constructor(
|
||||
@ -215,23 +291,22 @@ export class BankAccessApiClient {
|
||||
return await readSuccessResponseJsonOrThrow(resp, codecForAny());
|
||||
}
|
||||
|
||||
async registerAccount(
|
||||
username: string,
|
||||
password: string,
|
||||
options: {
|
||||
iban?: string;
|
||||
} = {},
|
||||
): Promise<BankUser> {
|
||||
const url = new URL("testing/register", this.baseUrl);
|
||||
/**
|
||||
* Register a new account and return information about it.
|
||||
*
|
||||
* This is a helper, as it does both the registration and the
|
||||
* account info query.
|
||||
*/
|
||||
async registerAccount(username: string, password: string): Promise<BankUser> {
|
||||
const url = new URL("accounts", this.baseUrl);
|
||||
const resp = await this.httpLib.fetch(url.href, {
|
||||
method: "POST",
|
||||
body: {
|
||||
username,
|
||||
password,
|
||||
iban: options?.iban,
|
||||
name: username,
|
||||
},
|
||||
});
|
||||
let paytoUri = `payto://x-taler-bank/localhost/${username}`;
|
||||
if (resp.status !== 200 && resp.status !== 202 && resp.status !== 204) {
|
||||
logger.error(`${j2s(await resp.json())}`);
|
||||
throw TalerError.fromDetail(
|
||||
@ -241,31 +316,24 @@ export class BankAccessApiClient {
|
||||
},
|
||||
);
|
||||
}
|
||||
try {
|
||||
// Pybank has no body, thus this might throw.
|
||||
const respJson = await resp.json();
|
||||
// LibEuFin demobank returns payto URI in response
|
||||
if (respJson.paytoUri) {
|
||||
paytoUri = respJson.paytoUri;
|
||||
}
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
const infoUrl = new URL(`accounts/${username}`, this.baseUrl);
|
||||
const infoResp = await this.httpLib.fetch(infoUrl.href);
|
||||
// FIXME: Validate!
|
||||
const acctInfo: AccountData = await readSuccessResponseJsonOrThrow(
|
||||
infoResp,
|
||||
codecForAny(),
|
||||
);
|
||||
return {
|
||||
password,
|
||||
username,
|
||||
accountPaytoUri: paytoUri,
|
||||
accountPaytoUri: acctInfo.payto_uri,
|
||||
};
|
||||
}
|
||||
|
||||
async createRandomBankUser(): Promise<BankUser> {
|
||||
const username = "user-" + encodeCrock(getRandomBytes(10)).toLowerCase();
|
||||
const password = "pw-" + encodeCrock(getRandomBytes(10)).toLowerCase();
|
||||
// FIXME: This is just a temporary workaround, because demobank is running out of short IBANs
|
||||
const iban = generateIban("DE", 15);
|
||||
return await this.registerAccount(username, password, {
|
||||
iban,
|
||||
});
|
||||
return await this.registerAccount(username, password);
|
||||
}
|
||||
|
||||
async createWithdrawalOperation(
|
||||
|
@ -366,7 +366,7 @@ export const codecForAmountResponse = (): Codec<AmountResponse> =>
|
||||
.property("rawAmount", codecForAmountString())
|
||||
.build("AmountResponse");
|
||||
|
||||
export interface Balance {
|
||||
export interface WalletBalance {
|
||||
scopeInfo: ScopeInfo;
|
||||
available: AmountString;
|
||||
pendingIncoming: AmountString;
|
||||
@ -458,11 +458,11 @@ export type ScopeInfoAuditor = {
|
||||
export type ScopeInfo = ScopeInfoGlobal | ScopeInfoExchange | ScopeInfoAuditor;
|
||||
|
||||
export interface BalancesResponse {
|
||||
balances: Balance[];
|
||||
balances: WalletBalance[];
|
||||
}
|
||||
|
||||
export const codecForBalance = (): Codec<Balance> =>
|
||||
buildCodecForObject<Balance>()
|
||||
export const codecForBalance = (): Codec<WalletBalance> =>
|
||||
buildCodecForObject<WalletBalance>()
|
||||
.property("scopeInfo", codecForAny()) // FIXME
|
||||
.property("available", codecForString())
|
||||
.property("hasPendingTransactions", codecForBoolean())
|
||||
|
@ -31,7 +31,7 @@ import {
|
||||
AmountJson,
|
||||
Amounts,
|
||||
AmountString,
|
||||
BankAccessApiClient,
|
||||
TalerCorebankApiClient,
|
||||
codecForAny,
|
||||
codecForBankWithdrawalOperationPostResponse,
|
||||
codecForBatchDepositSuccess,
|
||||
@ -118,7 +118,7 @@ export async function topupReserveWithDemobank(
|
||||
args: TopupReserveWithDemobankArgs,
|
||||
) {
|
||||
const { http, bankAccessApiBaseUrl, amount, exchangeInfo, reservePub } = args;
|
||||
const bankClient = new BankAccessApiClient(bankAccessApiBaseUrl);
|
||||
const bankClient = new TalerCorebankApiClient(bankAccessApiBaseUrl);
|
||||
const bankUser = await bankClient.createRandomBankUser();
|
||||
const wopi = await bankClient.createWithdrawalOperation(
|
||||
bankUser.username,
|
||||
|
@ -25,6 +25,7 @@ import {
|
||||
IntegrationTestV2Args,
|
||||
Logger,
|
||||
NotificationType,
|
||||
RegisterAccountRequest,
|
||||
stringToBytes,
|
||||
TestPayResult,
|
||||
TransactionMajorState,
|
||||
@ -216,17 +217,25 @@ async function confirmBankWithdrawalUri(
|
||||
|
||||
async function registerRandomBankUser(
|
||||
http: HttpRequestLibrary,
|
||||
bankAccessApiBaseUrl: string,
|
||||
corebankApiBaseUrl: string,
|
||||
): Promise<BankUser> {
|
||||
const reqUrl = new URL("testing/register", bankAccessApiBaseUrl).href;
|
||||
const reqUrl = new URL("accounts", corebankApiBaseUrl).href;
|
||||
const randId = makeId(8);
|
||||
const username = `testuser-${randId.toLowerCase()}`;
|
||||
const password = `testpw-${randId}`;
|
||||
|
||||
const bankUser: BankUser = {
|
||||
// euFin doesn't allow resource names to have upper case letters.
|
||||
username: `testuser-${randId.toLowerCase()}`,
|
||||
password: `testpw-${randId}`,
|
||||
username,
|
||||
password,
|
||||
};
|
||||
|
||||
const resp = await http.postJson(reqUrl, bankUser);
|
||||
const userReq: RegisterAccountRequest = {
|
||||
username,
|
||||
password,
|
||||
name: username,
|
||||
};
|
||||
|
||||
const resp = await http.fetch(reqUrl, { method: "POST", body: userReq });
|
||||
await checkSuccessResponseOrThrow(resp);
|
||||
return bankUser;
|
||||
}
|
||||
|
@ -1513,13 +1513,19 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
||||
const components = pt.targetPath.split("/");
|
||||
const creditorAcct = components[components.length - 1];
|
||||
logger.info(`making testbank transfer to '${creditorAcct}'`);
|
||||
const fbReq = await ws.http.postJson(
|
||||
new URL(`${creditorAcct}/admin/add-incoming`, req.bank).href,
|
||||
const fbReq = await ws.http.fetch(
|
||||
new URL(
|
||||
`accounts/${creditorAcct}/taler-wire-gateway/admin/add-incoming`,
|
||||
req.bank,
|
||||
).href,
|
||||
{
|
||||
amount: Amounts.stringify(amount),
|
||||
reserve_pub: wres.reservePub,
|
||||
debit_account:
|
||||
"payto://x-taler-bank/localhost/testdebtor?receiver-name=Foo",
|
||||
method: "POST",
|
||||
body: {
|
||||
amount: Amounts.stringify(amount),
|
||||
reserve_pub: wres.reservePub,
|
||||
debit_account:
|
||||
"payto://x-taler-bank/localhost/testdebtor?receiver-name=Foo",
|
||||
},
|
||||
},
|
||||
);
|
||||
const fbResp = await readSuccessResponseJsonOrThrow(fbReq, codecForAny());
|
||||
|
Loading…
Reference in New Issue
Block a user