diff options
48 files changed, 564 insertions, 155 deletions
diff --git a/packages/taler-harness/src/env-full.ts b/packages/taler-harness/src/env-full.ts index bb2cb8c47..87ed200d5 100644 --- a/packages/taler-harness/src/env-full.ts +++ b/packages/taler-harness/src/env-full.ts @@ -25,7 +25,7 @@ import { ExchangeService, FakebankService, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, } from "./harness/harness.js"; /** @@ -82,7 +82,7 @@ export async function runEnvFull(t: GlobalTestState): Promise<void> { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -91,7 +91,7 @@ export async function runEnvFull(t: GlobalTestState): Promise<void> { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 062b21eba..9ed4e77ce 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -713,7 +713,7 @@ export class FakebankService return { accountName: accountName, accountPassword: password, - accountPaytoUri: generateRandomPayto(accountName), + accountPaytoUri: getTestHarnessPaytoForLabel(accountName), wireGatewayApiBaseUrl: `http://localhost:${this.bankConfig.httpPort}/accounts/${accountName}/taler-wire-gateway/`, }; } @@ -1874,7 +1874,7 @@ export class MerchantService implements MerchantServiceInterface { return await this.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, @@ -2385,11 +2385,7 @@ export function generateRandomTestIban(salt: string | null = null): string { return `DE${check_digits}${bban}`; } -/** - * Generate a payto address, whose authority depends - * on whether the banking is served by euFin or Pybank. - */ -export function generateRandomPayto(label: string): string { +export function getTestHarnessPaytoForLabel(label: string): string { return `payto://x-taler-bank/localhost/${label}?receiver-name=${label}`; } diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index 30f2bea63..c6e9b2d35 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -57,7 +57,7 @@ import { ExchangeService, ExchangeServiceInterface, FakebankService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, harnessHttpLib, @@ -267,7 +267,7 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -276,7 +276,7 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -399,7 +399,7 @@ export async function createSimpleTestkudosEnvironmentV2( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -408,7 +408,7 @@ export async function createSimpleTestkudosEnvironmentV2( await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -474,7 +474,7 @@ export async function createSimpleTestkudosEnvironmentV3( const receiverName = "Exchange"; const exchangeBankUsername = "exchange"; const exchangeBankPassword = "mypw"; - const exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + const exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); const wireGatewayApiBaseUrl = new URL( `accounts/${exchangeBankUsername}/taler-wire-gateway/`, bank.corebankApiBaseUrl, @@ -552,7 +552,7 @@ export async function createSimpleTestkudosEnvironmentV3( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -561,7 +561,7 @@ export async function createSimpleTestkudosEnvironmentV3( await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -733,13 +733,13 @@ export async function createFaultInjectedMerchantTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-deposit.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-deposit.ts index a0e97c218..aa107696c 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-deposit.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-deposit.ts @@ -24,7 +24,7 @@ import { TransactionMinorState, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, generateRandomPayto } from "../harness/harness.js"; +import { GlobalTestState, getTestHarnessPaytoForLabel } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV3, withdrawViaBankV3, @@ -83,7 +83,7 @@ export async function runAgeRestrictionsDepositTest(t: GlobalTestState) { WalletApiOperation.CreateDepositGroup, { amount: "TESTKUDOS:10" as AmountString, - depositPaytoUri: generateRandomPayto("foo"), + depositPaytoUri: getTestHarnessPaytoForLabel("foo"), transactionId: depositTxId, }, ); diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts index 58f8bb106..544957185 100644 --- a/packages/taler-harness/src/integrationtests/test-bank-api.ts +++ b/packages/taler-harness/src/integrationtests/test-bank-api.ts @@ -30,7 +30,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; @@ -66,7 +66,7 @@ export async function runBankApiTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); let wireGatewayApiBaseUrl = new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href; await exchange.addBankAccount("1", { @@ -95,13 +95,13 @@ export async function runBankApiTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-currency-scope.ts b/packages/taler-harness/src/integrationtests/test-currency-scope.ts index 34d18d87d..48502f6b7 100644 --- a/packages/taler-harness/src/integrationtests/test-currency-scope.ts +++ b/packages/taler-harness/src/integrationtests/test-currency-scope.ts @@ -26,7 +26,7 @@ import { GlobalTestState, HarnessExchangeBankAccount, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -81,7 +81,7 @@ export async function runCurrencyScopeTest(t: GlobalTestState) { ).href, accountName: "myexchange", accountPassword: "x", - accountPaytoUri: generateRandomPayto("myexchange"), + accountPaytoUri: getTestHarnessPaytoForLabel("myexchange"), }; let exchangeTwoBankAccount: HarnessExchangeBankAccount = { @@ -91,7 +91,7 @@ export async function runCurrencyScopeTest(t: GlobalTestState) { ).href, accountName: "myexchange2", accountPassword: "x", - accountPaytoUri: generateRandomPayto("myexchange2"), + accountPaytoUri: getTestHarnessPaytoForLabel("myexchange2"), }; bank.setSuggestedExchange( @@ -151,7 +151,7 @@ export async function runCurrencyScopeTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -160,7 +160,7 @@ export async function runCurrencyScopeTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-deposit.ts b/packages/taler-harness/src/integrationtests/test-deposit.ts index 13c35e7fa..654829c91 100644 --- a/packages/taler-harness/src/integrationtests/test-deposit.ts +++ b/packages/taler-harness/src/integrationtests/test-deposit.ts @@ -25,7 +25,7 @@ import { j2s, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, generateRandomPayto } from "../harness/harness.js"; +import { GlobalTestState, getTestHarnessPaytoForLabel } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV3, withdrawViaBankV3, @@ -51,7 +51,7 @@ export async function runDepositTest(t: GlobalTestState) { await withdrawalResult.withdrawalFinishedCond; - const depositPaytoUri = generateRandomPayto("foo"); + const depositPaytoUri = getTestHarnessPaytoForLabel("foo"); const bal = await walletClient.call(WalletApiOperation.GetBalances, {}); diff --git a/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts b/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts index 801162ac8..9bdb0d93b 100644 --- a/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts +++ b/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts @@ -36,7 +36,7 @@ import { GlobalTestState, MerchantService, WalletCli, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; @@ -74,7 +74,7 @@ export async function runExchangeManagementFaultTest( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -111,13 +111,13 @@ export async function runExchangeManagementFaultTest( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts index 4f2fb1ee4..828289373 100644 --- a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts +++ b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts @@ -35,7 +35,7 @@ import { makeNoFeeCoinConfig } from "../harness/denomStructures.js"; import { BankService, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, MerchantService, setupDb, @@ -128,7 +128,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -171,13 +171,13 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-fee-regression.ts b/packages/taler-harness/src/integrationtests/test-fee-regression.ts index 72f56fb0e..b08fce4cb 100644 --- a/packages/taler-harness/src/integrationtests/test-fee-regression.ts +++ b/packages/taler-harness/src/integrationtests/test-fee-regression.ts @@ -27,7 +27,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -70,7 +70,7 @@ export async function createMyTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -170,7 +170,7 @@ export async function createMyTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-kyc-balance-withdrawal.ts b/packages/taler-harness/src/integrationtests/test-kyc-balance-withdrawal.ts index 320db6912..5e7a4756e 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-balance-withdrawal.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-balance-withdrawal.ts @@ -37,7 +37,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -84,7 +84,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-deposit-aggregate.ts b/packages/taler-harness/src/integrationtests/test-kyc-deposit-aggregate.ts index 21f6f47a2..fb0e7d79e 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-deposit-aggregate.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-deposit-aggregate.ts @@ -32,7 +32,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -79,7 +79,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit-kyctransfer.ts b/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit-kyctransfer.ts new file mode 100644 index 000000000..9264018be --- /dev/null +++ b/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit-kyctransfer.ts @@ -0,0 +1,355 @@ +/* + 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 { + Logger, + TalerCorebankApiClient, + TransactionMajorState, + TransactionMinorState, + TransactionType, + WireGatewayApiClient, +} from "@gnu-taler/taler-util"; +import { + createSyncCryptoApi, + EddsaKeyPairStrings, + WalletApiOperation, +} from "@gnu-taler/taler-wallet-core"; +import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; +import { + BankService, + DbInfo, + ExchangeService, + getTestHarnessPaytoForLabel, + GlobalTestState, + HarnessExchangeBankAccount, + setupDb, + WalletClient, + WalletService, +} from "../harness/harness.js"; +import { + EnvOptions, + postAmlDecisionNoRules, + withdrawViaBankV3, +} from "../harness/helpers.js"; + +const logger = new Logger("test-kyc-deposit-deposit.ts"); + +interface KycTestEnv { + commonDb: DbInfo; + bankClient: TalerCorebankApiClient; + exchange: ExchangeService; + exchangeBankAccount: HarnessExchangeBankAccount; + walletClient: WalletClient; + walletService: WalletService; + amlKeypair: EddsaKeyPairStrings; +} + +async function createKycTestkudosEnvironment( + t: GlobalTestState, + coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")), + opts: EnvOptions = {}, +): Promise<KycTestEnv> { + const db = await setupDb(t); + + const bank = await BankService.create(t, { + allowRegistrations: true, + currency: "TESTKUDOS", + database: db.connStr, + httpPort: 8082, + }); + + const exchange = ExchangeService.create(t, { + name: "testexchange-1", + currency: "TESTKUDOS", + httpPort: 8081, + database: db.connStr, + }); + + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); + + const wireGatewayApiBaseUrl = new URL( + `accounts/${exchangeBankUsername}/taler-wire-gateway/`, + bank.corebankApiBaseUrl, + ).href; + + await exchange.addBankAccount("1", { + accountName: exchangeBankUsername, + accountPassword: exchangeBankPassword, + wireGatewayApiBaseUrl, + accountPaytoUri: exchangePaytoUri, + }); + + bank.setSuggestedExchange(exchange, exchangePaytoUri); + + await bank.start(); + + await bank.pingUntilAvailable(); + + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + + const ageMaskSpec = opts.ageMaskSpec; + + if (ageMaskSpec) { + exchange.enableAgeRestrictions(ageMaskSpec); + // Enable age restriction for all coins. + exchange.addCoinConfigList( + coinConfig.map((x) => ({ + ...x, + name: `${x.name}-age`, + ageRestricted: true, + })), + ); + // For mixed age restrictions, we also offer coins without age restrictions + if (opts.mixedAgeRestriction) { + exchange.addCoinConfigList( + coinConfig.map((x) => ({ ...x, ageRestricted: false })), + ); + } + } else { + exchange.addCoinConfigList(coinConfig); + } + + await exchange.modifyConfig(async (config) => { + config.setString("exchange", "enable_kyc", "yes"); + + config.setString("KYC-RULE-R1", "operation_type", "deposit"); + config.setString("KYC-RULE-R1", "enabled", "yes"); + config.setString("KYC-RULE-R1", "exposed", "yes"); + config.setString("KYC-RULE-R1", "is_and_combinator", "yes"); + config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:5"); + config.setString("KYC-RULE-R1", "timeframe", "1d"); + config.setString("KYC-RULE-R1", "next_measures", "M1"); + + config.setString("KYC-MEASURE-M1", "check_name", "C1"); + config.setString("KYC-MEASURE-M1", "context", "{}"); + config.setString("KYC-MEASURE-M1", "program", "P1"); + + config.setString("AML-PROGRAM-P1", "command", "/bin/true"); + config.setString("AML-PROGRAM-P1", "enabled", "true"); + config.setString("AML-PROGRAM-P1", "description", "this does nothing"); + config.setString("AML-PROGRAM-P1", "fallback", "M1"); + + config.setString("KYC-CHECK-C1", "type", "INFO"); + config.setString("KYC-CHECK-C1", "description", "my check!"); + config.setString("KYC-CHECK-C1", "fallback", "M1"); + }); + + await exchange.start(); + + const cryptoApi = createSyncCryptoApi(); + const amlKeypair = await cryptoApi.createEddsaKeypair({}); + + await exchange.enableAmlAccount(amlKeypair.pub, "Alice"); + + const walletService = new WalletService(t, { + name: "wallet", + useInMemoryDb: true, + }); + await walletService.start(); + await walletService.pingUntilAvailable(); + + const walletClient = new WalletClient({ + name: "wallet", + unixPath: walletService.socketPath, + onNotification(n) { + console.log("got notification", n); + }, + }); + await walletClient.connect(); + await walletClient.client.call(WalletApiOperation.InitWallet, { + config: { + testing: { + skipDefaults: true, + }, + }, + }); + + console.log("setup done!"); + + return { + commonDb: db, + exchange, + amlKeypair, + walletClient, + walletService, + bankClient, + exchangeBankAccount: { + accountName: "", + accountPassword: "", + accountPaytoUri: exchangePaytoUri, + wireGatewayApiBaseUrl, + }, + }; +} + +export async function runKycDepositDepositKyctransferTest(t: GlobalTestState) { + // Set up test environment + + const { + walletClient, + bankClient, + exchange, + amlKeypair, + exchangeBankAccount, + } = await createKycTestkudosEnvironment(t); + + // Withdraw digital cash into the wallet. + + const wres = await withdrawViaBankV3(t, { + bankClient, + amount: "TESTKUDOS:50", + exchange: exchange, + walletClient: walletClient, + }); + + await wres.withdrawalFinishedCond; + + const depositPaytoUri = getTestHarnessPaytoForLabel("deposit-test"); + + await bankClient.registerAccountExtended({ + name: "deposit-test", + password: "test", + username: "deposit-test", + is_taler_exchange: false, + payto_uri: depositPaytoUri, + }); + + const depositResp = await walletClient.call( + WalletApiOperation.CreateDepositGroup, + { + amount: "TESTKUDOS:10", + depositPaytoUri, + }, + ); + + console.log("waiting for kyc-required"); + + await walletClient.call(WalletApiOperation.TestingWaitTransactionState, { + transactionId: depositResp.transactionId, + txState: { + major: TransactionMajorState.Pending, + minor: TransactionMinorState.KycAuthRequired, + }, + }); + + t.logStep("kyc-auth-requested"); + + const wireGatewayApiClient = new WireGatewayApiClient( + exchangeBankAccount.wireGatewayApiBaseUrl, + { + auth: { + username: "admin", + password: "adminpw", + }, + }, + ); + + { + const txDetails = await walletClient.call( + WalletApiOperation.GetTransactionById, + { + transactionId: depositResp.transactionId, + }, + ); + + t.assertDeepEqual(txDetails.type, TransactionType.Deposit); + const kycTx = txDetails.kycAuthTransferInfo; + t.assertTrue(!!kycTx); + + await wireGatewayApiClient.adminAddKycauth({ + amount: "TESTKUDOS:0.1", + debitAccountPayto: depositPaytoUri, + accountPub: kycTx.accountPub, + }); + } + + await walletClient.call(WalletApiOperation.TestingWaitTransactionState, { + transactionId: depositResp.transactionId, + txState: { + major: TransactionMajorState.Pending, + minor: TransactionMinorState.KycRequired, + }, + }); + + const txDetails = await walletClient.call( + WalletApiOperation.GetTransactionById, + { + transactionId: depositResp.transactionId, + }, + ); + + const kycPaytoHash = txDetails.kycPaytoHash; + + t.assertTrue(!!kycPaytoHash); + + await postAmlDecisionNoRules(t, { + amlPriv: amlKeypair.priv, + amlPub: amlKeypair.pub, + exchangeBaseUrl: exchange.baseUrl, + paytoHash: kycPaytoHash, + }); + + logger.info(`made decision to have no rules on ${kycPaytoHash}`); + + await walletClient.call(WalletApiOperation.TestingWaitTransactionState, { + transactionId: depositResp.transactionId, + txState: [ + { + major: TransactionMajorState.Done, + }, + { + major: TransactionMajorState.Pending, + minor: TransactionMinorState.Track, + }, + ], + }); + + await exchange.runAggregatorOnceWithTimetravel({ + timetravelMicroseconds: 1000 * 1000 * 60 * 60, + }); + + await exchange.runTransferOnceWithTimetravel({ + timetravelMicroseconds: 1000 * 1000 * 60 * 60, + }); + + await walletClient.call(WalletApiOperation.TestingWaitTransactionState, { + transactionId: depositResp.transactionId, + txState: { + major: TransactionMajorState.Done, + }, + }); +} + +runKycDepositDepositKyctransferTest.suites = ["wallet"]; diff --git a/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit.ts b/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit.ts index fea3a7309..10f34a56a 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit.ts @@ -33,7 +33,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -82,7 +82,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-exchange-wallet.ts b/packages/taler-harness/src/integrationtests/test-kyc-exchange-wallet.ts index da1ba6d8d..fbbaf382d 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-exchange-wallet.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-exchange-wallet.ts @@ -34,7 +34,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -77,7 +77,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-form-withdrawal.ts b/packages/taler-harness/src/integrationtests/test-kyc-form-withdrawal.ts index 357332deb..6a8a13ab9 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-form-withdrawal.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-form-withdrawal.ts @@ -40,7 +40,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, harnessHttpLib, @@ -84,7 +84,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts b/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts index 5adb23f5a..3b32656ae 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts @@ -28,7 +28,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, harnessHttpLib, @@ -78,7 +78,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -204,7 +204,7 @@ async function createKycTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -213,7 +213,7 @@ async function createKycTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-kyc-merchant-deposit.ts b/packages/taler-harness/src/integrationtests/test-kyc-merchant-deposit.ts index e33d5e45b..72a3c3f0c 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-merchant-deposit.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-merchant-deposit.ts @@ -28,7 +28,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, harnessHttpLib, @@ -74,7 +74,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -200,7 +200,7 @@ async function createKycTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -209,7 +209,7 @@ async function createKycTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts b/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts index 97e6a9121..c0d3881a0 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts @@ -41,7 +41,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, harnessHttpLib, @@ -89,7 +89,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-kyc-peer-pull.ts index 0496a51cb..0919f6550 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-peer-pull.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-peer-pull.ts @@ -38,7 +38,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -86,7 +86,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-peer-push.ts b/packages/taler-harness/src/integrationtests/test-kyc-peer-push.ts index 465279c28..6e1a78a26 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-peer-push.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-peer-push.ts @@ -37,7 +37,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -85,7 +85,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc-threshold-withdrawal.ts b/packages/taler-harness/src/integrationtests/test-kyc-threshold-withdrawal.ts index bf3c2dbb2..c89bbe641 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc-threshold-withdrawal.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc-threshold-withdrawal.ts @@ -34,7 +34,7 @@ import { BankService, DbInfo, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -77,7 +77,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index 169c14698..3a68fcbce 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -39,7 +39,7 @@ import { MerchantService, WalletClient, WalletService, - generateRandomPayto, + getTestHarnessPaytoForLabel, harnessHttpLib, setupDb, } from "../harness/harness.js"; @@ -78,7 +78,7 @@ async function createKycTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -219,7 +219,7 @@ async function createKycTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -228,7 +228,7 @@ async function createKycTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-bank.ts b/packages/taler-harness/src/integrationtests/test-libeufin-bank.ts index 01b20ddbf..1b67332d8 100644 --- a/packages/taler-harness/src/integrationtests/test-libeufin-bank.ts +++ b/packages/taler-harness/src/integrationtests/test-libeufin-bank.ts @@ -35,7 +35,7 @@ import { GlobalTestState, LibeufinBankService, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, generateRandomTestIban, setupDb, } from "../harness/harness.js"; @@ -74,7 +74,7 @@ export async function runLibeufinBankTest(t: GlobalTestState) { const exchangeBankUsername = "exchange"; const exchangeBankPw = "mypw"; - const exchangePayto = generateRandomPayto(exchangeBankUsername); + const exchangePayto = getTestHarnessPaytoForLabel(exchangeBankUsername); const wireGatewayApiBaseUrl = new URL( "accounts/exchange/taler-wire-gateway/", bank.baseUrl, @@ -108,13 +108,13 @@ export async function runLibeufinBankTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); const { walletClient } = await createWalletDaemonWithClient(t, { diff --git a/packages/taler-harness/src/integrationtests/test-merchant-categories.ts b/packages/taler-harness/src/integrationtests/test-merchant-categories.ts index 87d94c583..21ccfef3a 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-categories.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-categories.ts @@ -22,7 +22,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, harnessHttpLib, setupDb, } from "../harness/harness.js"; @@ -78,7 +78,7 @@ export async function runMerchantCategoriesTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts index 19f89ae2c..096b59fa8 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts @@ -34,7 +34,7 @@ import { import { BankService, ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, harnessHttpLib, MerchantService, @@ -87,7 +87,7 @@ export async function createConfusedMerchantTestkudosEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -131,13 +131,13 @@ export async function createConfusedMerchantTestkudosEnvironment( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts index c0c9353e4..51beded8d 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts @@ -22,7 +22,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, harnessHttpLib, setupDb, } from "../harness/harness.js"; @@ -78,7 +78,7 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, @@ -88,7 +88,7 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "myinst", name: "Second Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts index 188451e15..f41b028ae 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts @@ -22,7 +22,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, harnessHttpLib, setupDb, } from "../harness/harness.js"; @@ -78,7 +78,7 @@ export async function runMerchantInstancesTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, @@ -88,7 +88,7 @@ export async function runMerchantInstancesTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, @@ -98,7 +98,7 @@ export async function runMerchantInstancesTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "myinst", name: "Second Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], auth: { method: "external", }, diff --git a/packages/taler-harness/src/integrationtests/test-multiexchange.ts b/packages/taler-harness/src/integrationtests/test-multiexchange.ts index 26e843073..8c1424437 100644 --- a/packages/taler-harness/src/integrationtests/test-multiexchange.ts +++ b/packages/taler-harness/src/integrationtests/test-multiexchange.ts @@ -26,7 +26,7 @@ import { GlobalTestState, HarnessExchangeBankAccount, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -82,7 +82,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { ).href, accountName: "myexchange", accountPassword: "x", - accountPaytoUri: generateRandomPayto("myexchange"), + accountPaytoUri: getTestHarnessPaytoForLabel("myexchange"), }; let exchangeTwoBankAccount: HarnessExchangeBankAccount = { @@ -92,7 +92,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { ).href, accountName: "myexchange2", accountPassword: "x", - accountPaytoUri: generateRandomPayto("myexchange2"), + accountPaytoUri: getTestHarnessPaytoForLabel("myexchange2"), }; bank.setSuggestedExchange( @@ -152,7 +152,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -161,7 +161,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-payment-fault.ts b/packages/taler-harness/src/integrationtests/test-payment-fault.ts index dabe42a6b..a6836953e 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-fault.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-fault.ts @@ -38,7 +38,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -71,7 +71,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -140,7 +140,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl()); diff --git a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts index 3c902ee17..e3f3e18e3 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts @@ -25,7 +25,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -59,7 +59,7 @@ async function setupTest(t: GlobalTestState): Promise<{ let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -107,13 +107,13 @@ async function setupTest(t: GlobalTestState): Promise<{ await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-revocation.ts b/packages/taler-harness/src/integrationtests/test-revocation.ts index 6441ae974..d88a74150 100644 --- a/packages/taler-harness/src/integrationtests/test-revocation.ts +++ b/packages/taler-harness/src/integrationtests/test-revocation.ts @@ -31,7 +31,7 @@ import { WalletCli, WalletClient, delayMs, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -93,7 +93,7 @@ async function createTestEnvironment( let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -153,13 +153,13 @@ async function createTestEnvironment( await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts index 046bd5aed..27bf7bdd6 100644 --- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts +++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts @@ -33,7 +33,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -74,7 +74,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -120,13 +120,13 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], }); await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-blocked-deposit.ts b/packages/taler-harness/src/integrationtests/test-wallet-blocked-deposit.ts index 7a6c9e6d2..70f8989c8 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-blocked-deposit.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-blocked-deposit.ts @@ -26,7 +26,7 @@ import { } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig } from "../harness/denomStructures.js"; -import { GlobalTestState, generateRandomPayto } from "../harness/harness.js"; +import { GlobalTestState, getTestHarnessPaytoForLabel } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV3, createWalletDaemonWithClient, @@ -104,7 +104,7 @@ export async function runWalletBlockedDepositTest(t: GlobalTestState) { }, }); - const userPayto = generateRandomPayto("foo"); + const userPayto = getTestHarnessPaytoForLabel("foo"); const bal = await w1.call(WalletApiOperation.GetBalances, {}); console.log(`balance: ${j2s(bal)}`); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts index ba2b2670c..7378e272a 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts @@ -34,7 +34,7 @@ import { GlobalTestState, WalletClient, WalletService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { withdrawViaBankV3 } from "../harness/helpers.js"; @@ -64,7 +64,7 @@ export async function runWalletDd48Test(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts b/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts index 3a1b467c3..3d7ea32e6 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts @@ -32,7 +32,7 @@ import { FakebankService, GlobalTestState, HarnessExchangeBankAccount, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -98,7 +98,7 @@ export async function runWalletExchangeUpdateTest( ).href, accountName: "myexchange", accountPassword: "x", - accountPaytoUri: generateRandomPayto("myexchange"), + accountPaytoUri: getTestHarnessPaytoForLabel("myexchange"), }; await exchangeOne.addBankAccount("1", exchangeBankAccount); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-insufficient-balance.ts b/packages/taler-harness/src/integrationtests/test-wallet-insufficient-balance.ts index eb8b958a8..3b1f4bf27 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-insufficient-balance.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-insufficient-balance.ts @@ -28,7 +28,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { ExchangeService, - generateRandomPayto, + getTestHarnessPaytoForLabel, GlobalTestState, HarnessExchangeBankAccount, setupDb, @@ -63,7 +63,7 @@ export async function runWalletInsufficientBalanceTest(t: GlobalTestState) { const receiverName = "Exchange2"; const exchangeBankUsername = "exchange2"; const exchangeBankPassword = "mypw"; - const exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + const exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); const wireGatewayApiBaseUrl = new URL( `accounts/${exchangeBankUsername}/taler-wire-gateway/`, bank.corebankApiBaseUrl, @@ -95,7 +95,7 @@ export async function runWalletInsufficientBalanceTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -104,7 +104,7 @@ export async function runWalletInsufficientBalanceTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-wallet-network-availability.ts b/packages/taler-harness/src/integrationtests/test-wallet-network-availability.ts index d97737e25..ba0038608 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-network-availability.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-network-availability.ts @@ -25,7 +25,7 @@ import { TransactionType, } from "@gnu-taler/taler-util"; import { WalletApiOperation, parseTransactionIdentifier } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, generateRandomPayto } from "harness/harness.js"; +import { GlobalTestState, getTestHarnessPaytoForLabel } from "harness/harness.js"; import { createSimpleTestkudosEnvironmentV3, withdrawViaBankV3 } from "harness/helpers.js"; import { TaskRunResultType } from "../../../taler-wallet-core/src/common.js"; @@ -78,7 +78,7 @@ export async function runWalletNetworkAvailabilityTest(t: GlobalTestState) { WalletApiOperation.CreateDepositGroup, { amount: "TESTKUDOS:10.5" as AmountString, - depositPaytoUri: generateRandomPayto("foo"), + depositPaytoUri: getTestHarnessPaytoForLabel("foo"), }, ); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts index 5088c8228..27280103b 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts @@ -32,7 +32,7 @@ import { MerchantService, WalletClient, WalletService, - generateRandomPayto, + getTestHarnessPaytoForLabel, generateRandomTestIban, setupDb, } from "../harness/harness.js"; @@ -62,7 +62,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); const merchant = await MerchantService.create(t, { name: "testmerchant-1", diff --git a/packages/taler-harness/src/integrationtests/test-wallet-observability.ts b/packages/taler-harness/src/integrationtests/test-wallet-observability.ts index 55a60cb76..cf924f649 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-observability.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-observability.ts @@ -26,7 +26,7 @@ import { GlobalTestState, WalletClient, WalletService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { withdrawViaBankV3 } from "../harness/helpers.js"; @@ -53,7 +53,7 @@ export async function runWalletObservabilityTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts b/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts index 93fe94270..6197e6c36 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts @@ -30,7 +30,7 @@ import { WalletApiOperation, parseTransactionIdentifier, } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, generateRandomPayto } from "../harness/harness.js"; +import { GlobalTestState, getTestHarnessPaytoForLabel } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV3, makeTestPaymentV2, @@ -120,7 +120,7 @@ export async function runWalletRefreshTest(t: GlobalTestState) { WalletApiOperation.CreateDepositGroup, { amount: "TESTKUDOS:10.5" as AmountString, - depositPaytoUri: generateRandomPayto("foo"), + depositPaytoUri: getTestHarnessPaytoForLabel("foo"), }, ); @@ -175,7 +175,7 @@ export async function runWalletRefreshTest(t: GlobalTestState) { WalletApiOperation.CreateDepositGroup, { amount: "TESTKUDOS:10.5" as AmountString, - depositPaytoUri: generateRandomPayto("foo"), + depositPaytoUri: getTestHarnessPaytoForLabel("foo"), }, ); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts b/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts index c5a0fd363..359adc7e3 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts @@ -32,7 +32,7 @@ import { ExchangeService, GlobalTestState, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { @@ -74,7 +74,7 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, @@ -121,7 +121,7 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -130,7 +130,7 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts index 6256d3843..2f6d2ff5d 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts @@ -38,7 +38,7 @@ import { GlobalTestState, HarnessExchangeBankAccount, MerchantService, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; import { createWalletDaemonWithClient } from "../harness/helpers.js"; @@ -164,7 +164,7 @@ export async function runWithdrawalConversionTest(t: GlobalTestState) { ).href, accountName: "myexchange", accountPassword: "x", - accountPaytoUri: generateRandomPayto("myexchange"), + accountPaytoUri: getTestHarnessPaytoForLabel("myexchange"), conversionUrl: "http://localhost:8071/", }; @@ -203,7 +203,7 @@ export async function runWithdrawalConversionTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", - paytoUris: [generateRandomPayto("merchant-default")], + paytoUris: [getTestHarnessPaytoForLabel("merchant-default")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), @@ -212,7 +212,7 @@ export async function runWithdrawalConversionTest(t: GlobalTestState) { await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", - paytoUris: [generateRandomPayto("minst1")], + paytoUris: [getTestHarnessPaytoForLabel("minst1")], defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts index 0657d2da7..c7bf0b938 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts @@ -25,7 +25,7 @@ import { ExchangeService, GlobalTestState, WalletCli, - generateRandomPayto, + getTestHarnessPaytoForLabel, setupDb, } from "../harness/harness.js"; @@ -85,7 +85,7 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) { let receiverName = "Exchange"; let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw"; - let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); await exchange.addBankAccount("1", { accountName: exchangeBankUsername, diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index 35ada99f1..c9e31b046 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -49,6 +49,7 @@ import { runFeeRegressionTest } from "./test-fee-regression.js"; import { runForcedSelectionTest } from "./test-forced-selection.js"; import { runKycBalanceWithdrawalTest } from "./test-kyc-balance-withdrawal.js"; import { runKycDepositAggregateTest } from "./test-kyc-deposit-aggregate.js"; +import { runKycDepositDepositKyctransferTest } from "./test-kyc-deposit-deposit-kyctransfer.js"; import { runKycDepositDepositTest } from "./test-kyc-deposit-deposit.js"; import { runKycExchangeWalletTest } from "./test-kyc-exchange-wallet.js"; import { runKycFormWithdrawalTest } from "./test-kyc-form-withdrawal.js"; @@ -266,6 +267,7 @@ const allTests: TestMainFunction[] = [ runKycDepositDepositTest, runKycMerchantDepositTest, runKycMerchantAggregateTest, + runKycDepositDepositKyctransferTest, ]; export interface TestRunSpec { diff --git a/packages/taler-util/src/bank-api-client.ts b/packages/taler-util/src/bank-api-client.ts index 642232962..67cde0c18 100644 --- a/packages/taler-util/src/bank-api-client.ts +++ b/packages/taler-util/src/bank-api-client.ts @@ -151,6 +151,25 @@ export class WireGatewayApiClient { logger.info(`add-incoming response status: ${resp.status}`); await checkSuccessResponseOrThrow(resp); } + + async adminAddKycauth(params: { + amount: string; + accountPub: string; + debitAccountPayto: string; + }): Promise<void> { + let url = new URL(`admin/add-kycauth`, this.baseUrl); + const resp = await this.httpLib.fetch(url.href, { + method: "POST", + body: { + amount: params.amount, + account_pub: params.accountPub, + debit_account: params.debitAccountPayto, + }, + headers: this.makeAuthHeader(), + }); + logger.info(`add-kycauth response status: ${resp.status}`); + await checkSuccessResponseOrThrow(resp); + } } export interface AccountBalance { @@ -215,21 +234,6 @@ export class TalerCorebankApiClient { logger.info(`result: ${j2s(res)}`); } - async createTransaction( - username: string, - req: BankAccessApiCreateTransactionRequest, - ): Promise<any> { - const reqUrl = new URL(`accounts/${username}/transactions`, this.baseUrl); - - const resp = await this.httpLib.fetch(reqUrl.href, { - method: "POST", - body: req, - headers: this.makeAuthHeader(), - }); - - return await readSuccessResponseJsonOrThrow(resp, codecForAny()); - } - async registerAccountExtended(req: RegisterAccountRequest): Promise<void> { const url = new URL("accounts", this.baseUrl); const resp = await this.httpLib.fetch(url.href, { diff --git a/packages/taler-util/src/types-taler-wallet-transactions.ts b/packages/taler-util/src/types-taler-wallet-transactions.ts index 8d01e7fdf..95c858482 100644 --- a/packages/taler-util/src/types-taler-wallet-transactions.ts +++ b/packages/taler-util/src/types-taler-wallet-transactions.ts @@ -234,6 +234,28 @@ export interface TransactionCommon { * KYC access token. Useful for testing, not so useful for UIs. */ kycAccessToken?: string; + + kycAuthTransferInfo?: KycAuthTransferInfo; +} + +export interface KycAuthTransferInfo { + /** + * Payto URI of the account that must make the transfer. + * + * The KYC auth transfer will *not* work if it originates + * from a different account. + */ + debitPaytoUri: string; + + /** + * Account public key that must be included in the subject. + */ + accountPub: string; + + /** + * Possible target payto URIs. + */ + creditPaytoUris: string[]; } export type Transaction = diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts index 9acebfd00..23d6e1059 100644 --- a/packages/taler-wallet-core/src/deposits.ts +++ b/packages/taler-wallet-core/src/deposits.ts @@ -39,6 +39,7 @@ import { ExchangeBatchDepositRequest, ExchangeRefundRequest, HttpStatusCode, + KycAuthTransferInfo, Logger, MerchantContractTerms, NotificationType, @@ -201,6 +202,34 @@ export class DepositTransactionContext implements TransactionContext { dg.statusPerCoin.length; } + let kycAuthTransferInfo: KycAuthTransferInfo | undefined = undefined; + + switch (dg.operationStatus) { + case DepositOperationStatus.PendingDepositKycAuth: + case DepositOperationStatus.SuspendedDepositKycAuth: { + if (!dg.kycInfo) { + break; + } + const creditPaytoUris: string[] = []; + const exchangeWire = await getExchangeWireDetailsInTx( + tx, + dg.kycInfo.exchangeBaseUrl, + ); + if (exchangeWire) { + // FIXME: Add subject, amount + for (const acc of exchangeWire.wireInfo.accounts) { + creditPaytoUris.push(acc.payto_uri); + } + } + kycAuthTransferInfo = { + debitPaytoUri: dg.wire.payto_uri, + accountPub: dg.merchantPub, + creditPaytoUris, + }; + break; + } + } + const txState = computeDepositTransactionStatus(dg); return { type: TransactionType.Deposit, @@ -225,6 +254,7 @@ export class DepositTransactionContext implements TransactionContext { depositGroupId: dg.depositGroupId, trackingState, deposited, + kycAuthTransferInfo, kycPaytoHash: dg.kycInfo?.paytoHash, kycAccessToken: dg.kycInfo?.accessToken, kycUrl: dg.kycInfo |