diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 7c54c0c47..bac691637 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -1825,6 +1825,7 @@ export class MerchantService implements MerchantServiceInterface { if (!this.proc) { throw Error("merchant must be running to add instance"); } + console.trace("here!"); logger.info("adding instance"); const url = `http://localhost:${this.merchantConfig.httpPort}/management/instances`; const auth = instanceConfig.auth ?? { method: "external" }; diff --git a/packages/taler-harness/src/harness/libeufin-apis.ts b/packages/taler-harness/src/harness/libeufin-apis.ts index 3c57eee07..0553223cb 100644 --- a/packages/taler-harness/src/harness/libeufin-apis.ts +++ b/packages/taler-harness/src/harness/libeufin-apis.ts @@ -176,7 +176,10 @@ export interface LibeufinSandboxAddIncomingRequest { direction: string; } -const libeufinHttpLib = createPlatformHttpLib(); +const libeufinHarnessHttpLib = createPlatformHttpLib({ + allowHttp: true, + enableThrottling: false, +}); /** * APIs spread across Legacy and Access, it is therefore @@ -192,7 +195,7 @@ export namespace LibeufinSandboxApi { iban: string | null = null, ): Promise { let url = new URL("testing/register", libeufinSandboxService.baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: { username: username, @@ -211,7 +214,7 @@ export namespace LibeufinSandboxApi { ): Promise { // baseUrl should already be pointed to one demobank. let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: { userID: req.userID, @@ -228,7 +231,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL(`admin/ebics/hosts/${hostID}/rotate-keys`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: {}, }); @@ -239,7 +242,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL("admin/ebics/hosts", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: { hostID, @@ -255,7 +258,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL(`admin/bank-accounts/${req.label}`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: req, headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, @@ -272,7 +275,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL("admin/ebics/subscribers", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: req, headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, @@ -289,7 +292,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL("admin/ebics/bank-accounts", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: req, headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, @@ -306,7 +309,7 @@ export namespace LibeufinSandboxApi { `admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`, baseUrl, ); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", body: req, headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, @@ -322,7 +325,7 @@ export namespace LibeufinSandboxApi { `admin/bank-accounts/${accountLabel}/transactions`, baseUrl, ); - const res = await libeufinHttpLib.fetch(url.href, { + const res = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return (await res.json()) as SandboxAccountTransactions; @@ -334,7 +337,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL("admin/payments/camt", baseUrl); - return await libeufinHttpLib.fetch(url.href, { + return await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: { @@ -350,7 +353,7 @@ export namespace LibeufinSandboxApi { ): Promise { const baseUrl = libeufinSandboxService.baseUrl; let url = new URL(`admin/bank-accounts/${accountLabel}`, baseUrl); - const res = await libeufinHttpLib.fetch(url.href, { + const res = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return res.json(); @@ -362,7 +365,7 @@ export namespace LibeufinNexusApi { nexus: LibeufinNexusServiceInterface, ): Promise { let url = new URL("bank-connections", nexus.baseUrl); - const res = await libeufinHttpLib.fetch(url.href, { + const res = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return res.json(); @@ -374,7 +377,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL("bank-connections/delete-connection", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: req, @@ -387,7 +390,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL("bank-connections", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: { @@ -411,7 +414,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`bank-accounts/${accountName}`, baseUrl); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return resp.json(); @@ -427,7 +430,7 @@ export namespace LibeufinNexusApi { `bank-accounts/${accountName}/payment-initiations/${paymentId}/submit`, baseUrl, ); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: {}, @@ -443,7 +446,7 @@ export namespace LibeufinNexusApi { `bank-connections/${connectionName}/fetch-accounts`, baseUrl, ); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: {}, @@ -461,7 +464,7 @@ export namespace LibeufinNexusApi { `bank-connections/${connectionName}/import-account`, baseUrl, ); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: { @@ -477,7 +480,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`bank-connections/${connectionName}/connect`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: {}, @@ -495,7 +498,7 @@ export namespace LibeufinNexusApi { `/bank-accounts/${accountName}/payment-initiations`, baseUrl, ); - let response = await libeufinHttpLib.fetch(url.href, { + let response = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); const respJson = await response.json(); @@ -518,7 +521,7 @@ export namespace LibeufinNexusApi { for (const [k, v] of Object.entries(params)) { url.searchParams.set(k, String(v)); } - let response = await libeufinHttpLib.fetch(url.href, { + let response = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return response.json(); @@ -534,7 +537,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl); - let response = await libeufinHttpLib.fetch(url.href, { + let response = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return response.json(); @@ -553,7 +556,7 @@ export namespace LibeufinNexusApi { `/bank-accounts/${accountName}/fetch-transactions`, baseUrl, ); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: { @@ -572,7 +575,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/users/${username}/password`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: req, @@ -585,7 +588,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/user`, baseUrl); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return resp.json(); @@ -597,7 +600,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/users`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: req, @@ -609,7 +612,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/permissions`, baseUrl); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return resp.json(); @@ -621,7 +624,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/permissions`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: req, @@ -634,7 +637,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return resp.json(); @@ -653,7 +656,7 @@ export namespace LibeufinNexusApi { baseUrl, ); if (taskName) url = new URL(taskName, `${url.href}/`); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); return resp.json(); @@ -669,7 +672,7 @@ export namespace LibeufinNexusApi { `/bank-accounts/${bankAccountName}/schedule/${taskName}`, baseUrl, ); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "DELETE", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); @@ -682,7 +685,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: req, @@ -695,7 +698,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL(`facades/${facadeName}`, baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "DELETE", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); @@ -706,7 +709,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL("facades", baseUrl); - const resp = await libeufinHttpLib.fetch(url.href, { + const resp = await libeufinHarnessHttpLib.fetch(url.href, { headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, }); // FIXME: Just return validated, typed response here! @@ -719,7 +722,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL("facades", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: { @@ -741,7 +744,7 @@ export namespace LibeufinNexusApi { ): Promise { const baseUrl = libeufinNexusService.baseUrl; let url = new URL("facades", baseUrl); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: { @@ -766,7 +769,7 @@ export namespace LibeufinNexusApi { `/bank-accounts/${accountId}/submit-all-payment-initiations`, baseUrl, ); - await libeufinHttpLib.fetch(url.href, { + await libeufinHarnessHttpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBasicAuthHeader("admin", "secret") }, body: {}, diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts index 5ee35a377..3072badc0 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts @@ -82,13 +82,14 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { name: "w0", }); - await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV2(t, { walletClient: walletClientZero, bank, exchange, amount: "TESTKUDOS:20", restrictAge: 13, }); + await wres.withdrawalFinishedCond; const order = { summary: "Buy me!", @@ -111,13 +112,14 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { { const walletClient = walletClientOne; - await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20", restrictAge: 13, }); + await wres.withdrawalFinishedCond; const order = { summary: "Buy me!", @@ -136,13 +138,14 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { { const walletClient = walletClientTwo; - await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20", restrictAge: 13, }); + await wres.withdrawalFinishedCond; const order = { summary: "Buy me!", @@ -160,12 +163,13 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { { const walletClient = walletClientThree; - await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20", }); + await wres.withdrawalFinishedCond; const order = { summary: "Buy me!", diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts index 041b10cc0..e645d60f1 100644 --- a/packages/taler-harness/src/integrationtests/test-bank-api.ts +++ b/packages/taler-harness/src/integrationtests/test-bank-api.ts @@ -84,12 +84,6 @@ export async function runBankApiTest(t: GlobalTestState) { await merchant.start(); await merchant.pingUntilAvailable(); - await merchant.addDefaultInstance(); - await merchant.addInstanceWithWireAccount({ - id: "minst1", - name: "minst1", - paytoUris: [getPayto("minst1")], - }); await merchant.addInstanceWithWireAccount({ id: "default", @@ -97,6 +91,12 @@ export async function runBankApiTest(t: GlobalTestState) { paytoUris: [getPayto("merchant-default")], }); + await merchant.addInstanceWithWireAccount({ + id: "minst1", + name: "minst1", + paytoUris: [getPayto("minst1")], + }); + console.log("setup done!"); const bankUser = await BankApi.registerAccount(bank, "user1", "pw1", {}); diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts b/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts index 5d5beb06e..20fa34437 100644 --- a/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts +++ b/packages/taler-harness/src/integrationtests/test-libeufin-basic.ts @@ -19,12 +19,12 @@ */ import { AbsoluteTime, - MerchantContractTerms, Duration, + MerchantContractTerms, } from "@gnu-taler/taler-util"; import { - WalletApiOperation, HarnessExchangeBankAccount, + WalletApiOperation, } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { @@ -32,20 +32,19 @@ import { ExchangeService, GlobalTestState, MerchantService, - setupDb, - WalletCli, WalletClient, + setupDb, } from "../harness/harness.js"; +import { + createWalletDaemonWithClient, + makeTestPaymentV2, +} from "../harness/helpers.js"; import { LibeufinNexusApi, LibeufinNexusService, LibeufinSandboxApi, LibeufinSandboxService, } from "../harness/libeufin.js"; -import { - createWalletDaemonWithClient, - makeTestPaymentV2, -} from "../harness/helpers.js"; const exchangeIban = "DE71500105179674997361"; const customerIban = "DE84500105176881385584"; @@ -73,7 +72,7 @@ export async function createLibeufinTestEnvironment( const libeufinSandbox = await LibeufinSandboxService.create(t, { httpPort: 5010, - databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`, + databaseJdbcUri: db.connStr, }); await libeufinSandbox.start(); @@ -81,7 +80,7 @@ export async function createLibeufinTestEnvironment( const libeufinNexus = await LibeufinNexusService.create(t, { httpPort: 5011, - databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`, + databaseJdbcUri: db.connStr, }); await libeufinNexus.start(); @@ -218,7 +217,7 @@ export async function createLibeufinTestEnvironment( console.log("setup done!"); const { walletClient } = await createWalletDaemonWithClient(t, { - name: "default ", + name: "default", }); return { diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts index 167c54cb4..54205e9f2 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts @@ -86,6 +86,16 @@ export async function runMerchantInstancesTest(t: GlobalTestState) { }, }); + // Add it again, should be idempotent + await merchant.addInstanceWithWireAccount({ + id: "default", + name: "Default Instance", + paytoUris: [getPayto("merchant-default")], + auth: { + method: "external", + }, + }); + // Add an instance, no auth! await merchant.addInstanceWithWireAccount({ id: "myinst",