commit 7524e8b823964875670f3f7332ccb1c652117650
parent 7f3c819d910518e69dd71ee78a5d79fcfb51f13b
Author: Florian Dold <florian@dold.me>
Date: Mon, 18 Nov 2024 18:10:53 +0100
kyc tests WIP
Diffstat:
3 files changed, 94 insertions(+), 92 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-decisions.ts b/packages/taler-harness/src/integrationtests/test-kyc-decisions.ts
@@ -0,0 +1,92 @@
+/*
+ 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,
+ hashFullPaytoUri,
+ hashNormalizedPaytoUri,
+ 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");
+}
+
+/**
+ * Tests for making AML decisions.
+ * - Test making decisions on unknown accounts.
+ * - Test making decisions with default rules.
+ */
+export async function runKycDecisionsTest(t: GlobalTestState) {
+ // Set up test environment
+
+ const { walletClient, bankClient, exchange, amlKeypair, merchant } =
+ await createKycTestkudosEnvironment(t, { adjustExchangeConfig });
+
+ const merchantPayto = getTestHarnessPaytoForLabel("merchant-default");
+
+ const kycPaytoHash = encodeCrock(hashNormalizedPaytoUri(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,
+ paytoUri: merchantPayto,
+ 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,
+ }),
+ ),
+ },
+ ],
+ },
+ });
+}
+
+runKycDecisionsTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-initial-decision.ts b/packages/taler-harness/src/integrationtests/test-kyc-initial-decision.ts
@@ -1,90 +0,0 @@
-/*
- 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,
- hashFullPaytoUri,
- hashNormalizedPaytoUri,
- 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(hashNormalizedPaytoUri(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,
- paytoUri: merchantPayto,
- 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,7 +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";
+import { runKycDecisionsTest } from "./test-kyc-decisions.js";
/**
* Test runner.
@@ -289,7 +289,7 @@ const allTests: TestMainFunction[] = [
runWalletTransactionsTest,
runKycWithdrawalVerbotenTest,
runKycMerchantActivateBankAccountTest,
- runKycInitialDecisionTest,
+ runKycDecisionsTest,
];
export interface TestRunSpec {