tests: logging for test-paywall-flow

This commit is contained in:
Florian Dold 2021-08-08 13:35:35 +02:00
parent 5f06ce16be
commit 425ea0fbca
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -23,6 +23,7 @@ import {
PreparePayResultType, PreparePayResultType,
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType, ConfirmPayResultType,
URL,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import axios from "axios"; import axios from "axios";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@ -74,9 +75,9 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const talerPayUriOne = orderStatus.taler_pay_uri; const talerPayUriOne = orderStatus.taler_pay_uri;
t.assertTrue(orderStatus.already_paid_order_id === undefined); t.assertTrue(orderStatus.already_paid_order_id === undefined);
let publicOrderStatusUrl = orderStatus.order_status_url; let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
let publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { let publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
validateStatus: () => true, validateStatus: () => true,
}); });
@ -103,10 +104,11 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const proposalId = preparePayResp.proposalId; const proposalId = preparePayResp.proposalId;
publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { console.log("requesting", publicOrderStatusUrl.href);
publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
validateStatus: () => true, validateStatus: () => true,
}); });
console.log("response body", publicOrderStatusResp.data);
if (publicOrderStatusResp.status != 402) { if (publicOrderStatusResp.status != 402) {
throw Error( throw Error(
`expected status 402 (after claiming), but got ${publicOrderStatusResp.status}`, `expected status 402 (after claiming), but got ${publicOrderStatusResp.status}`,
@ -126,7 +128,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done); t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
validateStatus: () => true, validateStatus: () => true,
}); });
@ -192,7 +194,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(orderStatus.order_status === "unpaid"); t.assertTrue(orderStatus.order_status === "unpaid");
t.assertTrue(orderStatus.already_paid_order_id === undefined); t.assertTrue(orderStatus.already_paid_order_id === undefined);
publicOrderStatusUrl = orderStatus.order_status_url; publicOrderStatusUrl = new URL(orderStatus.order_status_url);
// Here the re-purchase detection should kick in, // Here the re-purchase detection should kick in,
// and the wallet should re-pay for the old order // and the wallet should re-pay for the old order
@ -230,7 +232,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
console.log("requesting public status", publicOrderStatusUrl); console.log("requesting public status", publicOrderStatusUrl);
// Ask the order status of the claimed-but-unpaid order // Ask the order status of the claimed-but-unpaid order
publicOrderStatusResp = await axios.get(publicOrderStatusUrl, { publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
validateStatus: () => true, validateStatus: () => true,
}); });
@ -247,4 +249,4 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId); t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId);
} }
runPaywallFlowTest.suites = ["wallet"]; runPaywallFlowTest.suites = ["merchant", "wallet"];