taler-typescript-core

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

commit 2643f33dbdfb6bb75d42ddce7c0c65c7adfa0842
parent 7f90bd4267223e02a0ef280f0e3a27a80ee9f465
Author: Florian Dold <florian@dold.me>
Date:   Wed, 21 Aug 2024 11:41:41 +0200

harness: update oauth2 kyc test

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-kyc.ts | 39++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -25,8 +25,10 @@ import { TransactionMajorState, TransactionMinorState, TransactionType, + codecForKycProcessClientInformation, j2s, } from "@gnu-taler/taler-util"; +import { readResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import * as http from "node:http"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; @@ -343,7 +345,10 @@ async function runTestfakeKycService(): Promise<TestfakeKycService> { JSON.stringify({ status: "success", data: { - name: "Alice Abc", + id: "Foobar", + first_name: "Alice", + last_name: "Abc", + birthdate: "2000-01-01", }, }), ); @@ -447,11 +452,39 @@ export async function runKycTest(t: GlobalTestState) { // We now simulate the user interacting with the KYC service, // which would usually done in the browser. - const proofUrl = new URL(`kyc-proof/MYPROV`, exchange.baseUrl); - proofUrl.searchParams.set("state", paytoHash); + const accessToken = txState.kycAccessToken; + t.assertTrue(!!accessToken); + + const infoResp = await harnessHttpLib.fetch( + new URL(`kyc-info/${txState.kycAccessToken}`, exchange.baseUrl).href, + ); + + const clientInfo = await readResponseJsonOrThrow( + infoResp, + codecForKycProcessClientInformation(), + ); + + console.log(j2s(clientInfo)); + + const kycId = clientInfo.requirements.find((x) => x.id != null)?.id; + t.assertTrue(!!kycId); + + const startResp = await harnessHttpLib.fetch( + new URL(`kyc-start/${kycId}`, exchange.baseUrl).href, + { + method: "POST", + body: {}, + }, + ); + + logger.info(`kyc-start resp status: ${startResp.status}`); + logger.info(j2s(startResp.json())); // We need to "visit" the KYC proof URL at least once to trigger the exchange // asking for the KYC status. + const proofUrl = new URL(`kyc-proof/MYPROV`, exchange.baseUrl); + proofUrl.searchParams.set("state", paytoHash); + proofUrl.searchParams.set("code", "code_is_ok"); const proofHttpResp = await harnessHttpLib.fetch(proofUrl.href); logger.info(`proof resp status ${proofHttpResp.status}`); logger.info(`resp headers ${j2s(proofHttpResp.headers.toJSON())}`);