From 06301efda34a7b92b7e193b9af67c75946286774 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 21 Jun 2023 12:36:22 +0200 Subject: -logging --- .../taler-harness/src/integrationtests/test-kyc.ts | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'packages') diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index 660595845..0fe24d708 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -20,6 +20,7 @@ import { Duration, j2s, + Logger, NotificationType, TransactionMajorState, TransactionMinorState, @@ -45,6 +46,8 @@ import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js"; import * as http from "node:http"; import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; +const logger = new Logger("test-kyc.ts"); + export async function createKycTestkudosEnvironment( t: GlobalTestState, coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")), @@ -226,7 +229,7 @@ function splitInTwoAt(s: string, separator: string): [string, string] { async function runTestfakeKycService(): Promise { const server = http.createServer((req, res) => { const requestUrl = req.url!; - console.log(`kyc: got ${req.method} request`, requestUrl); + logger.info(`kyc: got ${req.method} request, ${requestUrl}`); const [path, query] = splitInTwoAt(requestUrl, "?"); @@ -254,7 +257,7 @@ async function runTestfakeKycService(): Promise { }); req.on("end", () => { - console.log("login request body:", reqBody); + logger.info("login request body:", reqBody); res.writeHead(200, { "Content-Type": "application/json" }); // Normally, the access_token would also include which user we're trying @@ -267,7 +270,7 @@ async function runTestfakeKycService(): Promise { ); }); } else if (path === "/oauth/v2/info") { - console.log("authorization header:", req.headers.authorization); + logger.info("authorization header:", req.headers.authorization); res.writeHead(200, { "Content-Type": "application/json" }); res.end( JSON.stringify({ @@ -352,11 +355,14 @@ export async function runKycTest(t: GlobalTestState) { const kycNotif = await kycNotificationCond; - console.log("got kyc notification:", j2s(kycNotif)); + logger.info("got kyc notification:", j2s(kycNotif)); - const txState = await walletClient.client.call(WalletApiOperation.GetTransactionById, { - transactionId: withdrawalTxId - }); + const txState = await walletClient.client.call( + WalletApiOperation.GetTransactionById, + { + transactionId: withdrawalTxId, + }, + ); t.assertDeepEqual(txState.type, TransactionType.Withdrawal); @@ -364,7 +370,7 @@ export async function runKycTest(t: GlobalTestState) { t.assertTrue(!!kycUrl); - console.log(`kyc URL is ${kycUrl}`); + logger.info(`kyc URL is ${kycUrl}`); // We now simulate the user interacting with the KYC service, // which would usually done in the browser. @@ -375,11 +381,13 @@ export async function runKycTest(t: GlobalTestState) { }); const kycServerResp = await httpLib.fetch(kycUrl); const kycLoginResp = await kycServerResp.json(); - console.log("kyc server resp:", j2s(kycLoginResp)); + logger.info(`kyc server resp: ${j2s(kycLoginResp)}`); const kycProofUrl = kycLoginResp.redirect_uri; + // We need to "visit" the KYC proof URL at least once to trigger the exchange + // asking for the KYC status. const proofHttpResp = await httpLib.fetch(kycProofUrl); - console.log("proof resp status", proofHttpResp.status); - console.log("resp headers", proofHttpResp.headers.toJSON()); + logger.info(`proof resp status ${proofHttpResp.status}`); + logger.info(`resp headers ${j2s(proofHttpResp.headers.toJSON())}`); // Now that KYC is done, withdrawal should finally succeed. -- cgit v1.2.3