diff options
author | Florian Dold <florian@dold.me> | 2023-06-21 12:36:22 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-21 12:36:22 +0200 |
commit | 06301efda34a7b92b7e193b9af67c75946286774 (patch) | |
tree | a3e9e85bbd579a826811719f52e3240a6cafb615 /packages/taler-harness | |
parent | 5eb339b836b250891f00d8287781175b50788eb7 (diff) | |
download | wallet-core-06301efda34a7b92b7e193b9af67c75946286774.tar.xz |
-logging
Diffstat (limited to 'packages/taler-harness')
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-kyc.ts | 30 |
1 files changed, 19 insertions, 11 deletions
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<TestfakeKycService> { 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<TestfakeKycService> { }); 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<TestfakeKycService> { ); }); } 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. |