taler-typescript-core

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

commit 12bec720a24426658e6daee9dee3196946c09c34
parent 76a4547e15e6ee68b7650ce4768fb4e375e5257e
Author: Florian Dold <florian@dold.me>
Date:   Mon, 28 Oct 2024 12:06:54 +0100

harness: fix kyc-merchant-activate-bank-account test

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-kyc-merchant-activate-bank-account.ts | 100++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 58 insertions(+), 42 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-kyc-merchant-activate-bank-account.ts b/packages/taler-harness/src/integrationtests/test-kyc-merchant-activate-bank-account.ts @@ -18,51 +18,39 @@ * Imports. */ import { - AmountString, codecForAccountKycRedirects, - codecForKycProcessClientInformation, codecForQueryInstancesResponse, - encodeCrock, - hashPaytoUri, j2s, Logger, MerchantAccountKycRedirectsResponse, - TalerMerchantApi, + parsePaytoUri, WireGatewayApiClient, } from "@gnu-taler/taler-util"; +import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; +import { createKycTestkudosEnvironment } from "../harness/environments.js"; import { - readResponseJsonOrThrow, - readSuccessResponseJsonOrThrow, -} from "@gnu-taler/taler-util/http"; -import { - createKycTestkudosEnvironment, - postAmlDecisionNoRules, - withdrawViaBankV3, -} from "../harness/environments.js"; -import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; + getTestHarnessPaytoForLabel, + GlobalTestState, + harnessHttpLib, +} from "../harness/harness.js"; -const logger = new Logger(`test-kyc-merchant-deposit.ts`); +const logger = new Logger(`test-kyc-merchant-activate-bank-account.ts`); -export async function runKycMerchantActivateBankAccountTest(t: GlobalTestState) { +export async function runKycMerchantActivateBankAccountTest( + t: GlobalTestState, +) { // Set up test environment - - const { - merchant, - walletClient, - bankClient, - exchange, - exchangeBankAccount, - amlKeypair, - } = await createKycTestkudosEnvironment(t, { - adjustExchangeConfig(config) { - config.setString("exchange", "enable_kyc", "yes"); - - // no kyc depoist requirement, the exchange - // just need the merchant to prove the that it is the - // legal owner of the account making a simple - // wire transfer - }, - }); + const { merchant, bankClient, exchangeBankAccount } = + await createKycTestkudosEnvironment(t, { + adjustExchangeConfig(config) { + config.setString("exchange", "enable_kyc", "yes"); + + // no kyc deposit requirement, the exchange + // just need the merchant to prove the that it is the + // legal owner of the account making a simple + // wire transfer + }, + }); let accountPub: string; @@ -104,23 +92,52 @@ export async function runKycMerchantActivateBankAccountTest(t: GlobalTestState) // meaning that the bank account is not yet known by the exchange t.assertDeepEqual(kycRespOne.kyc_data[0].exchange_http_status, 404); - // prove that we own the account by sending some money from // the merchant account - bankClient.setAuth({ username: "merchant-default", password: "merchant-default" }) + bankClient.setAuth({ + username: "merchant-default", + password: "merchant-default", + }); + await bankClient.registerAccountExtended({ name: "merchant-default", password: "merchant-default", username: "merchant-default", payto_uri: kycRespOne.kyc_data[0].payto_uri, //this bank user needs to have the same payto that the exchange is asking from - }) - - await bankClient.makeTransaction("TESTKUDOS:1" as AmountString, kycRespOne.kyc_data[0].payto_kycauths![0]) + }); + + const wireGatewayApiClient = new WireGatewayApiClient( + exchangeBankAccount.wireGatewayApiBaseUrl, + { + auth: { + username: exchangeBankAccount.accountName, + password: exchangeBankAccount.accountPassword, + }, + }, + ); + + const kycauthPayto = kycRespOne.kyc_data[0].payto_kycauths![0]; + logger.info(`kycauth payto: ${kycauthPayto}`); + const p = parsePaytoUri(kycauthPayto); + + const msgAccountPub = p?.params["message"]; + t.assertTrue(!!accountPub); + + // FIXME: This is kinda brittle, would be better to pick out + // what looks like a public key from the message. + t.assertDeepEqual(`KYC:${accountPub}`, msgAccountPub); + + await wireGatewayApiClient.adminAddKycauth({ + amount: "TESTKUDOS:0.1", + // FIXME: Don't hardcode this. + debitAccountPayto: getTestHarnessPaytoForLabel("merchant-default"), + accountPub, + }); let kycRespTwo: MerchantAccountKycRedirectsResponse | undefined = undefined; - // We do this in a loop as a work-around. - // Not exactly the correct behavior from the merchant right now. + // Loop requesting the KYC status. + // The merchant currently doesn't support long-polling for this. while (true) { const kycStatusLongpollUrl = new URL( "private/kyc", @@ -147,7 +164,6 @@ export async function runKycMerchantActivateBankAccountTest(t: GlobalTestState) t.assertTrue(!!kycRespTwo); t.assertDeepEqual(kycRespTwo.kyc_data[0].exchange_http_status, 200); - } runKycMerchantActivateBankAccountTest.suites = ["wallet", "merchant", "kyc"];