commit 425be38ce793c9590820b3b922906db76f9c2141
parent dd52fc10287f49edad0e0c590db5d893ac8b90cf
Author: Florian Dold <florian@dold.me>
Date: Wed, 30 Jul 2025 15:01:00 +0200
harness: remove AMP double failure test
The fallback AMP may not ever fail, we don't expect this
to be handled properly, so it doesn't make sense to test for it.
Diffstat:
2 files changed, 1 insertion(+), 261 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-fail-recover-double.ts b/packages/taler-harness/src/integrationtests/test-kyc-fail-recover-double.ts
@@ -1,259 +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 {
- AmountString,
- bufferFromAmount,
- buildSigPS,
- codecForAccountKycStatus,
- codecForKycProcessClientInformation,
- codecForLegitimizationNeededResponse,
- codecOptional,
- Configuration,
- createNewWalletKycAccount,
- eddsaSign,
- encodeCrock,
- j2s,
- Logger,
- TalerSignaturePurpose,
- WalletKycRequest,
-} from "@gnu-taler/taler-util";
-import { readResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
-import {
- configureCommonKyc,
- createKycTestkudosEnvironment,
-} from "../harness/environments.js";
-import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
-
-const logger = new Logger(`test-kyc-fail-recover-double.ts`);
-
-function adjustExchangeConfig(config: Configuration) {
- configureCommonKyc(config);
-
- // trigger based on balance
- config.setString("KYC-RULE-R1", "operation_type", "balance");
- 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:5");
- config.setString("KYC-RULE-R1", "timeframe", "forever");
- config.setString("KYC-RULE-R1", "next_measures", "M1");
-
- // normal measure
- config.setString("KYC-MEASURE-M1", "check_name", "C1");
- config.setString("KYC-MEASURE-M1", "context", "{}");
- config.setString("KYC-MEASURE-M1", "program", "P1");
-
- // program that will failed based on input, but also
- // the fallback measure will fail when this program fail
- config.setString(
- "AML-PROGRAM-P1",
- "command",
- "taler-harness aml-program run-program --name FAIL_RECOVER",
- );
- config.setString("AML-PROGRAM-P1", "enabled", "true");
- config.setString(
- "AML-PROGRAM-P1",
- "description",
- "just fail based on the name",
- );
- config.setString("AML-PROGRAM-P1", "description_i18n", "{}");
- config.setString("AML-PROGRAM-P1", "fallback", "FREEZE-fail");
-
- // normal form
- config.setString("KYC-CHECK-C1", "type", "FORM");
- config.setString("KYC-CHECK-C1", "form_name", "firstForm");
- config.setString("KYC-CHECK-C1", "description", "starting check!");
- config.setString("KYC-CHECK-C1", "description_i18n", "{}");
- config.setString("KYC-CHECK-C1", "outputs", "NAME");
- config.setString("KYC-CHECK-C1", "fallback", "FREEZE");
-
- // fallback measure that will fail to recover
- config.setString("KYC-MEASURE-FREEZE-fail", "check_name", "SKIP");
- config.setString("KYC-MEASURE-FREEZE-fail", "context", "{}");
- config.setString("KYC-MEASURE-FREEZE-fail", "program", "FREEZE-fail");
-
- config.setString(
- "AML-PROGRAM-FREEZE-fail",
- "command",
- "taler-harness aml-program run-program --name fail-exec-child-error",
- );
- config.setString("AML-PROGRAM-FREEZE-fail", "enabled", "true");
- config.setString(
- "AML-PROGRAM-FREEZE-fail",
- "description",
- "try to freeze but fail",
- );
- config.setString("AML-PROGRAM-FREEZE-fail", "description_i18n", "{}");
- config.setString("AML-PROGRAM-FREEZE-fail", "fallback", "FREEZE-fail");
-}
-
-export async function runKycFailRecoverDoubleTest(t: GlobalTestState) {
- // Set up test environment
-
- const { exchange, amlKeypair } = await createKycTestkudosEnvironment(t, {
- adjustExchangeConfig,
- onWalletNotification: () => {},
- });
-
- // Withdraw digital cash into the wallet.
- let kycPaytoHash: string;
- let accessToken: string;
- let latestFormId: string;
-
- const account = await createNewWalletKycAccount(new Uint8Array());
- logger.info("step 1) Check balance to trigger AML");
- {
- const balance: AmountString = "TESTKUDOS:20";
- const sigBlob = buildSigPS(TalerSignaturePurpose.WALLET_ACCOUNT_SETUP)
- .put(bufferFromAmount(balance))
- .build();
- const body: WalletKycRequest = {
- balance,
- reserve_pub: account.id,
- reserve_sig: encodeCrock(eddsaSign(sigBlob, account.signingKey)),
- };
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-wallet`, exchange.baseUrl).href,
- {
- method: "POST",
- body,
- },
- );
-
- t.assertDeepEqual(infoResp.status, 451);
- const clientInfo = await readResponseJsonOrThrow(
- infoResp,
- codecOptional(codecForLegitimizationNeededResponse()),
- );
-
- t.assertTrue(clientInfo?.h_payto !== undefined);
- kycPaytoHash = clientInfo?.h_payto;
- }
-
- logger.info("step 2) Get account access token");
- {
- const sigBlob = buildSigPS(TalerSignaturePurpose.KYC_AUTH).build();
-
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-check/${kycPaytoHash}`, exchange.baseUrl).href,
- {
- headers: {
- "Account-Owner-Signature": encodeCrock(
- eddsaSign(sigBlob, account.signingKey),
- ),
- },
- },
- );
-
- t.assertDeepEqual(infoResp.status, 202);
- const clientInfo = await readResponseJsonOrThrow(
- infoResp,
- codecOptional(codecForAccountKycStatus()),
- );
- t.assertTrue(clientInfo?.access_token !== undefined);
- accessToken = clientInfo?.access_token;
- }
-
- logger.info("step 3) Check KYC info, should be waiting for the first form");
- {
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-info/${accessToken}?timeout_ms=1000`, exchange.baseUrl).href,
- );
- const clientInfo = await readResponseJsonOrThrow(
- infoResp,
- codecOptional(codecForKycProcessClientInformation()),
- );
-
- console.log(j2s(clientInfo));
- t.assertDeepEqual(infoResp.status, 200);
- t.assertDeepEqual(clientInfo?.requirements.length, 1);
- t.assertDeepEqual(clientInfo?.requirements[0].form, "firstForm");
- t.assertTrue(!!clientInfo?.requirements[0].id);
- latestFormId = clientInfo?.requirements[0].id;
- }
-
- logger.info("step 4) Complete form expecting to fail");
- {
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-upload/${latestFormId}`, exchange.baseUrl).href,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: { NAME: "child-fail" },
- },
- );
-
- t.assertDeepEqual(infoResp.status, 500);
- }
-
- logger.info("step 4) Complete form expecting to fail again");
- {
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-upload/${latestFormId}`, exchange.baseUrl).href,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: { NAME: "child-fail" },
- },
- );
-
- t.assertDeepEqual(infoResp.status, 500);
- }
-
- logger.info("step 5) Complete form expecting but this time it should work");
- {
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-upload/${latestFormId}`, exchange.baseUrl).href,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: { NAME: "just-kidding" },
- },
- );
- logger.info(`kyc-upload response: ${j2s(await infoResp.json())}`);
- t.assertDeepEqual(infoResp.status, 409);
- }
-
- {
- logger.info(
- "step 6) Check KYC info again after some time, here the exchange fails",
- );
- const infoResp = await harnessHttpLib.fetch(
- new URL(`kyc-info/${accessToken}?timeout_ms=1000`, exchange.baseUrl).href,
- );
-
- const clientInfo = await readResponseJsonOrThrow(
- infoResp,
- codecOptional(codecForKycProcessClientInformation()),
- );
-
- console.log(j2s(clientInfo));
- t.assertDeepEqual(infoResp.status, 200);
- t.assertDeepEqual(clientInfo?.requirements.length, 0);
- }
-}
-
-runKycFailRecoverDoubleTest.suites = ["wallet", "merchant", "kyc"];
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -72,8 +72,8 @@ import { runKycDepositAggregateImplicitAuthTest } from "./test-kyc-deposit-aggre
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 { runKycDepositKycauthTest } from "./test-kyc-deposit-kycauth.js";
import { runKycExchangeWalletTest } from "./test-kyc-exchange-wallet.js";
-import { runKycFailRecoverDoubleTest } from "./test-kyc-fail-recover-double.js";
import { runKycFailRecoverSimpleTest } from "./test-kyc-fail-recover-simple.js";
import { runKycFormBadMeasureTest } from "./test-kyc-form-bad-measure.js";
import { runKycFormCompressionTest } from "./test-kyc-form-compression.js";
@@ -189,7 +189,6 @@ import { runWithdrawalHugeTest } from "./test-withdrawal-huge.js";
import { runWithdrawalIdempotentTest } from "./test-withdrawal-idempotent.js";
import { runWithdrawalManualTest } from "./test-withdrawal-manual.js";
import { runWithdrawalPrepareTest } from "./test-withdrawal-prepare.js";
-import { runKycDepositKycauthTest } from "./test-kyc-deposit-kycauth.js";
/**
* Test runner.