taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f2b36f366d7f395a51bcab15eba8430b526b7a14
parent ef5b6bac0549d800ed5956303139b6d421fbbf27
Author: Florian Dold <florian@dold.me>
Date:   Mon,  4 Nov 2024 11:58:21 +0100

harness: test for KYC decision on unknown account

Diffstat:
Apackages/taler-harness/src/integrationtests/test-kyc-initial-decision.ts | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-harness/src/integrationtests/testrunner.ts | 2++
2 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-kyc-initial-decision.ts b/packages/taler-harness/src/integrationtests/test-kyc-initial-decision.ts @@ -0,0 +1,88 @@ +/* + This file is part of GNU Taler + (C) 2024 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 { + Configuration, + Duration, + encodeCrock, + hashPaytoUri, + TalerProtocolTimestamp, +} from "@gnu-taler/taler-util"; +import { + createKycTestkudosEnvironment, + postAmlDecision, +} from "../harness/environments.js"; +import { + getTestHarnessPaytoForLabel, + GlobalTestState, +} from "../harness/harness.js"; + +function adjustExchangeConfig(config: Configuration) { + config.setString("exchange", "enable_kyc", "yes"); + + config.setString("KYC-RULE-R1", "operation_type", "withdraw"); + config.setString("KYC-RULE-R1", "enabled", "yes"); + config.setString("KYC-RULE-R1", "exposed", "yes"); + config.setString("KYC-RULE-R1", "is_and_combinator", "no"); + config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:100"); + config.setString("KYC-RULE-R1", "timeframe", "1d"); + config.setString("KYC-RULE-R1", "next_measures", "verboten"); +} + +/** + * Test making decisions on unknown accounts. + */ +export async function runKycInitialDecisionTest(t: GlobalTestState) { + // Set up test environment + + const { walletClient, bankClient, exchange, amlKeypair, merchant } = + await createKycTestkudosEnvironment(t, { adjustExchangeConfig }); + + const merchantPayto = getTestHarnessPaytoForLabel("merchant-default"); + + const kycPaytoHash = encodeCrock(hashPaytoUri(merchantPayto)); + + // Make a decision where the exchange doesn't know the account yet. + await postAmlDecision(t, { + amlPriv: amlKeypair.priv, + amlPub: amlKeypair.pub, + exchangeBaseUrl: exchange.baseUrl, + paytoHash: kycPaytoHash, + newRules: { + expiration_time: TalerProtocolTimestamp.now(), + custom_measures: {}, + // Strict rules for this particular merchant! + rules: [ + { + operation_type: "DEPOSIT", + display_priority: 1, + measures: ["verboten"], + threshold: "TESTKUDOS:10", + timeframe: Duration.toTalerProtocolDuration( + Duration.fromSpec({ + days: 1, + }), + ), + }, + ], + }, + }); +} + +runKycInitialDecisionTest.suites = ["wallet"]; diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -152,6 +152,7 @@ import { runWithdrawalManualTest } from "./test-withdrawal-manual.js"; import { runWithdrawalPrepareTest } from "./test-withdrawal-prepare.js"; import { runKycMerchantActivateBankAccountTest } from "./test-kyc-merchant-activate-bank-account.js"; import { runKycSkipExpirationTest } from "./test-kyc-skip-expiration.js"; +import { runKycInitialDecisionTest } from "./test-kyc-initial-decision.js"; /** * Test runner. @@ -288,6 +289,7 @@ const allTests: TestMainFunction[] = [ runWalletTransactionsTest, runKycWithdrawalVerbotenTest, runKycMerchantActivateBankAccountTest, + runKycInitialDecisionTest, ]; export interface TestRunSpec {