diff options
author | MS <ms@taler.net> | 2022-12-09 10:51:33 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2022-12-09 10:55:52 +0100 |
commit | d4710ba700b37948f61b1b841962b73379423c04 (patch) | |
tree | 5bcd64b5125045417314a2af0a5c498a9a52e5a7 | |
parent | 68811cc5f59e9f7f3e46e5a35edc3e4470a295db (diff) |
Adapt libeufin test suite to recent API.
The new libeufin-sandbox API enforces every bank account
to be owned by one bank customer; this change therefore
provides every test user a customer profile before trying
the banking operations.
9 files changed, 147 insertions, 117 deletions
diff --git a/packages/taler-wallet-cli/src/harness/libeufin-apis.ts b/packages/taler-wallet-cli/src/harness/libeufin-apis.ts index 538d8e93f..f55275927 100644 --- a/packages/taler-wallet-cli/src/harness/libeufin-apis.ts +++ b/packages/taler-wallet-cli/src/harness/libeufin-apis.ts @@ -7,7 +7,7 @@ import axiosImp from "axios"; const axios = axiosImp.default; -import { URL } from "@gnu-taler/taler-util"; +import { Logger, URL } from "@gnu-taler/taler-util"; export interface LibeufinSandboxServiceInterface { baseUrl: string; @@ -167,13 +167,12 @@ function getRandomString(): string { return Math.random().toString(36).substring(2); } +/** + * APIs spread accross Legacy and Access, it is therefore + * the "base URL" relative to which API every call addresses. + */ export namespace LibeufinSandboxApi { - /** - * Return balance and payto-address of 'accountLabel'. - * Note: the demobank serving the request is hard-coded - * inside the base URL, and therefore contained in - * 'libeufinSandboxService'. - */ + // Need Access API base URL. export async function demobankAccountInfo( username: string, password: string, @@ -193,18 +192,24 @@ 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, ) { - let url = new URL("testing/register", libeufinSandboxService.baseUrl); + let url = new URL( + "testing/register", + libeufinSandboxService.baseUrl + ); await axios.post(url.href, { username: username, password: password, + iban: iban }); } - + // Need /demobanks/$id as the base URL export async function createDemobankEbicsSubscriber( req: CreateEbicsSubscriberRequest, demobankAccountLabel: string, @@ -213,7 +218,10 @@ export namespace LibeufinSandboxApi { password: string = "secret", ) { // baseUrl should already be pointed to one demobank. - let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl); + let url = new URL( + "ebics/subscribers", + libeufinSandboxService.baseUrl + ); await axios.post( url.href, { @@ -301,6 +309,10 @@ export namespace LibeufinSandboxApi { }); } + /** + * Create a new bank account and associate it to + * a existing EBICS subscriber. + */ export async function createEbicsBankAccount( libeufinSandboxService: LibeufinSandboxServiceInterface, req: CreateEbicsBankAccountRequest, @@ -712,7 +724,7 @@ export namespace LibeufinNexusApi { ): Promise<any> { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl); - if (taskName) url = new URL(taskName, `${url}/`); + if (taskName) url = new URL(taskName, `${url.href}/`); // It's caller's responsibility to interpret the response. return await axios.get(url.href, { diff --git a/packages/taler-wallet-cli/src/harness/libeufin.ts b/packages/taler-wallet-cli/src/harness/libeufin.ts index bc210d132..638c8ed90 100644 --- a/packages/taler-wallet-cli/src/harness/libeufin.ts +++ b/packages/taler-wallet-cli/src/harness/libeufin.ts @@ -27,7 +27,7 @@ * Imports. */ import axios from "axios"; -import { URL } from "@gnu-taler/taler-util"; +import { URL, Logger } from "@gnu-taler/taler-util"; import { GlobalTestState, DbInfo, @@ -56,6 +56,9 @@ import { CreateNexusUserRequest, } from "../harness/libeufin-apis.js"; + +const logger = new Logger("libeufin.ts"); + export { LibeufinSandboxApi, LibeufinNexusApi }; export interface LibeufinServices { @@ -125,7 +128,7 @@ export interface LibeufinCliDetails { sandboxUrl: string; nexusDatabaseUri: string; sandboxDatabaseUri: string; - user: LibeufinNexusUser; + nexusUser: LibeufinNexusUser; } export interface LibeufinEbicsSubscriberDetails { @@ -448,6 +451,21 @@ export class LibeufinCli { ); } + async registerBankCustomer(username: string, password: string): Promise<void> { + const stdout = await sh( + this.globalTestState, + "libeufin-cli-registercustomer", + "libeufin-cli sandbox demobank register --name='Test Customer'", + { + ...process.env, + LIBEUFIN_SANDBOX_URL: this.cliDetails.sandboxUrl + "/demobanks/default", + LIBEUFIN_SANDBOX_USERNAME: username, + LIBEUFIN_SANDBOX_PASSWORD: password, + }, + ); + console.log(stdout); + } + async createEbicsHost(hostId: string): Promise<void> { const stdout = await sh( this.globalTestState, @@ -528,8 +546,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -546,8 +564,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -562,8 +580,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -577,8 +595,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -592,8 +610,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -607,8 +625,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -627,8 +645,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -642,8 +660,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -657,8 +675,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -678,8 +696,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -698,8 +716,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -716,8 +734,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -734,8 +752,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -749,8 +767,8 @@ export class LibeufinCli { { ...process.env, LIBEUFIN_NEXUS_URL: this.cliDetails.nexusUrl, - LIBEUFIN_NEXUS_USERNAME: this.cliDetails.user.username, - LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.user.password, + LIBEUFIN_NEXUS_USERNAME: this.cliDetails.nexusUser.username, + LIBEUFIN_NEXUS_PASSWORD: this.cliDetails.nexusUser.password, }, ); console.log(stdout); @@ -773,7 +791,7 @@ interface NewTalerWireGatewayReq { /** * Launch Nexus and Sandbox AND creates users / facades / bank accounts / - * .. all that's required to start making banking traffic. + * .. all that's required to start making bank traffic. */ export async function launchLibeufinServices( t: GlobalTestState, @@ -799,7 +817,7 @@ export async function launchLibeufinServices( await libeufinNexus.start(); await libeufinNexus.pingUntilAvailable(); console.log("Libeufin services launched!"); - + for (let sb of sandboxUserBundle) { await LibeufinSandboxApi.createEbicsHost( libeufinSandbox, @@ -809,9 +827,15 @@ export async function launchLibeufinServices( libeufinSandbox, sb.ebicsBankAccount.subscriber, ); - await LibeufinSandboxApi.createEbicsBankAccount( - libeufinSandbox, - sb.ebicsBankAccount, + await LibeufinSandboxApi.createDemobankAccount( + sb.ebicsBankAccount.label, + "password-unused", + { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" } + ); + await LibeufinSandboxApi.createDemobankEbicsSubscriber( + sb.ebicsBankAccount.subscriber, + sb.ebicsBankAccount.label, + { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" } ); } console.log("Sandbox user(s) / account(s) / subscriber(s): created"); diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts index 26fecd77e..c3cbc0608 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts @@ -49,22 +49,21 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) { await sandbox.start(); await sandbox.pingUntilAvailable(); await LibeufinSandboxApi.createEbicsHost(sandbox, "mock"); - await LibeufinSandboxApi.createEbicsSubscriber(sandbox, { - hostID: "mock", - userID: "mock", - partnerID: "mock", - }); - await LibeufinSandboxApi.createEbicsBankAccount(sandbox, { - subscriber: { + await LibeufinSandboxApi.createDemobankAccount( + "mock", + "password-unused", + { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }, + "DE71500105179674997361" + ); + await LibeufinSandboxApi.createDemobankEbicsSubscriber( + { hostID: "mock", partnerID: "mock", userID: "mock", }, - iban: "DE71500105179674997361", - bic: "BELADEBEXXX", - name: "mock", - label: "mock", - }); + "mock", + { baseUrl: sandbox.baseUrl + "/demobanks/default/" } + ); await LibeufinNexusApi.createEbicsBankConnection(nexus, { name: "bankaccount-api-test-connection", ebicsURL: "http://localhost:5012/ebicsweb", diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-camt.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-camt.ts index 250d17d3d..cb85c1ffc 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-camt.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-camt.ts @@ -33,18 +33,17 @@ export async function runLibeufinApiSandboxCamtTest(t: GlobalTestState) { }); await sandbox.start(); await sandbox.pingUntilAvailable(); - await LibeufinSandboxApi.createBankAccount(sandbox, { - iban: "DE71500105179674997361", - bic: "BELADEBEXXX", - name: "Mock Name", - label: "mock-account-0", - }); - await LibeufinSandboxApi.createBankAccount(sandbox, { - iban: "DE71500105179674997361", - bic: "BELADEBEXXX", - name: "Mock Name", - label: "mock-account-1", - }); + + 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", diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-transactions.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-transactions.ts index 224c45970..24fd9d3ef 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-transactions.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-sandbox-transactions.ts @@ -32,12 +32,12 @@ export async function runLibeufinApiSandboxTransactionsTest( }); await sandbox.start(); await sandbox.pingUntilAvailable(); - await LibeufinSandboxApi.createBankAccount(sandbox, { - iban: "DE71500105179674997361", - bic: "BELADEBEXXX", - name: "Mock Name", - label: "mock-account", - }); + await LibeufinSandboxApi.createDemobankAccount( + "mock-account", + "password-unused", + { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }, + "DE71500105179674997361" + ); await LibeufinSandboxApi.simulateIncomingTransaction( sandbox, "mock-account", diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts index 8002f093f..94fd76683 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts @@ -81,41 +81,37 @@ export async function createLibeufinTestEnvironment( await LibeufinSandboxApi.createEbicsHost(libeufinSandbox, "host01"); // Subscriber and bank Account for the exchange - await LibeufinSandboxApi.createEbicsSubscriber(libeufinSandbox, { - hostID: "host01", - partnerID: "partner01", - userID: "user01", - }); - await LibeufinSandboxApi.createEbicsBankAccount(libeufinSandbox, { - bic: "DEUTDEBB101", - iban: exchangeIban, - label: "exchangeacct", - name: "Taler Exchange", - subscriber: { + await LibeufinSandboxApi.createDemobankAccount( + "exchangeacct", + "password-unused", + { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" }, + exchangeIban + ); + await LibeufinSandboxApi.createDemobankEbicsSubscriber( + { hostID: "host01", partnerID: "partner01", userID: "user01", }, - }); - // Subscriber and bank Account for the merchant - // (Merchant doesn't need EBICS access, but sandbox right now only supports EBICS - // accounts.) - await LibeufinSandboxApi.createEbicsSubscriber(libeufinSandbox, { - hostID: "host01", - partnerID: "partner02", - userID: "user02", - }); - await LibeufinSandboxApi.createEbicsBankAccount(libeufinSandbox, { - bic: "AUTOATW1XXX", - iban: merchantIban, - label: "merchantacct", - name: "Merchant", - subscriber: { + "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", diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-nexus-balance.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-nexus-balance.ts index a52de8d96..b1ef53a79 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-nexus-balance.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-nexus-balance.ts @@ -23,6 +23,7 @@ import { NexusUserBundle, launchLibeufinServices, LibeufinNexusApi, + LibeufinCli } from "../harness/libeufin.js"; /** @@ -66,7 +67,6 @@ export async function runLibeufinNexusBalanceTest(t: GlobalTestState) { "EUR:10", "first payment", ); - // user 01 gets another 10 await libeufinServices.libeufinSandbox.makeTransaction( user02sandbox.ebicsBankAccount.label, // debit diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-sandbox-wire-transfer-cli.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-sandbox-wire-transfer-cli.ts index 7f274f554..e56cb3d68 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-sandbox-wire-transfer-cli.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-sandbox-wire-transfer-cli.ts @@ -32,19 +32,19 @@ export async function runLibeufinSandboxWireTransferCliTest( }); await sandbox.start(); await sandbox.pingUntilAvailable(); - await LibeufinSandboxApi.createBankAccount(sandbox, { - iban: "DE71500105179674997361", - bic: "BELADEBEXXX", - name: "Mock Name", - label: "mock-account", - }); + 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 LibeufinSandboxApi.createBankAccount(sandbox, { - iban: "DE71500105179674997364", - bic: "BELADEBEXXX", - name: "Mock Name 2", - label: "mock-account-2", - }); await sandbox.makeTransaction( "mock-account", "mock-account-2", diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts index 0701fd1c5..7bc067cfe 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts @@ -49,7 +49,7 @@ export async function runLibeufinTutorialTest(t: GlobalTestState) { nexusUrl: libeufinNexus.baseUrl, sandboxDatabaseUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`, nexusDatabaseUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`, - user: nexusUser, + nexusUser: nexusUser, }); const ebicsDetails = { |