taler-typescript-core

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

commit 3fd9cb0598913097b159876f1948da00eaa21e1a
parent eff953b8686b2236a60b3fb947f7b01846beb4d5
Author: Florian Dold <florian@dold.me>
Date:   Wed, 13 Nov 2024 14:18:58 +0100

wallet-core: revert ToS acceptance after withdrawTestBalance

If the user didn't explicitly accept the ToS before, the testing call to
withdraw a test balance reverts the ToS back to the proposed state.

Diffstat:
Mpackages/taler-wallet-core/src/exchanges.ts | 2+-
Mpackages/taler-wallet-core/src/testing.ts | 9++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -605,7 +605,7 @@ export async function acceptExchangeTermsOfService( } /** - * Mark the current ToS version as accepted by the user. + * Set the ToS status of the exchange as not accepted. */ export async function forgetExchangeTermsOfService( wex: WalletExecutionContext, diff --git a/packages/taler-wallet-core/src/testing.ts b/packages/taler-wallet-core/src/testing.ts @@ -34,6 +34,7 @@ import { codecForCheckPaymentResponse, ConfirmPayResultType, Duration, + ExchangeTosStatus, IntegrationTestArgs, IntegrationTestV2Args, j2s, @@ -61,6 +62,7 @@ import { createDepositGroup } from "./deposits.js"; import { acceptExchangeTermsOfService, fetchFreshExchange, + forgetExchangeTermsOfService, } from "./exchanges.js"; import { confirmPay, @@ -129,7 +131,7 @@ export async function withdrawTestBalance( amount, ); - await fetchFreshExchange(wex, req.exchangeBaseUrl); + const exchangeBefore = await fetchFreshExchange(wex, req.exchangeBaseUrl); await acceptExchangeTermsOfService(wex, req.exchangeBaseUrl); const acceptResp = await acceptBankIntegratedWithdrawal(wex, { @@ -142,6 +144,11 @@ export async function withdrawTestBalance( withdrawalOperationId: wresp.withdrawal_id, }); + /* If the ToS weren't accepted before, restore the status. */ + if (exchangeBefore.tosStatus === ExchangeTosStatus.Proposed) { + await forgetExchangeTermsOfService(wex, req.exchangeBaseUrl); + } + return { transactionId: acceptResp.transactionId, accountPaytoUri: bankUser.accountPaytoUri,