diff options
author | Florian Dold <florian@dold.me> | 2024-09-17 18:22:53 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-09-17 18:22:53 +0200 |
commit | 360c6e9267df2a0df9a2b5643e3cbf707fff36ed (patch) | |
tree | d52f3eac749ff9f40abd0188df6585d25d417f53 | |
parent | ac8c6682a5a3ef70f82f28af827c450a1fdb0830 (diff) |
harness: adjust merchant-exchange-confusion
Merchant behavior has changed here.
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts | 30 | ||||
-rw-r--r-- | packages/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 index 096b59fa8..8f47eda1b 100644 --- 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 index 41d470972..026d24f0a 100644 --- 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>, |