taler-typescript-core

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

commit 360c6e9267df2a0df9a2b5643e3cbf707fff36ed
parent ac8c6682a5a3ef70f82f28af827c450a1fdb0830
Author: Florian Dold <florian@dold.me>
Date:   Tue, 17 Sep 2024 18:22:53 +0200

harness: adjust merchant-exchange-confusion

Merchant behavior has changed here.

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts | 30+++++++++++++++++++++++++++---
Mpackages/taler-util/src/errors.ts | 3+++
2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts @@ -20,9 +20,12 @@ import { codecForMerchantOrderStatusUnpaid, ConfirmPayResultType, + j2s, MerchantApiClient, PreparePayResultType, TalerCorebankApiClient, + TalerErrorCode, + TypedTalerErrorDetail, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { URL } from "url"; @@ -32,7 +35,7 @@ import { FaultInjectedMerchantService, } from "../harness/faultInjection.js"; import { - BankService, + BankService, ExchangeService, getTestHarnessPaytoForLabel, GlobalTestState, @@ -92,7 +95,10 @@ export async function createConfusedMerchantTestkudosEnvironment( await exchange.addBankAccount("1", { accountName: exchangeBankUsername, accountPassword: exchangeBankPassword, - wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href, + wireGatewayApiBaseUrl: new URL( + "accounts/exchange/taler-wire-gateway/", + bank.baseUrl, + ).href, accountPaytoUri: exchangePaytoUri, }); @@ -258,7 +264,25 @@ export async function runMerchantExchangeConfusionTest(t: GlobalTestState) { proposalId: proposalId, }); - t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done); + t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Pending); + + console.log(j2s(confirmPayRes.lastError)); + + // Merchant should not accept the payment! + // Something is clearly wrong, as the exchange now announces + // its own base URL and something is wrong. + + // FIXME: This error code should probably be refined in the future. + + t.assertDeepEqual( + confirmPayRes.lastError?.code, + TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR, + ); + + const err = + confirmPayRes.lastError as TypedTalerErrorDetail<TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR>; + + t.assertDeepEqual(err.httpStatusCode, 400); } runMerchantExchangeConfusionTest.suites = ["merchant"]; diff --git a/packages/taler-util/src/errors.ts b/packages/taler-util/src/errors.ts @@ -182,6 +182,9 @@ export interface DetailsMap { type ErrBody<Y> = Y extends keyof DetailsMap ? DetailsMap[Y] : empty; +export type TypedTalerErrorDetail<Y> = TalerErrorDetail & + (Y extends keyof DetailsMap ? DetailsMap[Y] : {}); + export function makeErrorDetail<C extends TalerErrorCode>( code: C, detail: ErrBody<C>,