aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-08-25 13:24:30 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-08-25 13:24:30 +0200
commita58f73ecdb995e02a770338aa8a8aa529ccfdfaa (patch)
treee1f329bb59ffd1fa4419241cf3bc849738103b54 /packages/taler-harness/src/integrationtests/test-paywall-flow.ts
parent5ab3070b3a63c2e8fed0e413dea06cf03fb48f1e (diff)
parent896841aec5dc3594d83cc300349d20ec2270f88e (diff)
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-paywall-flow.ts')
-rw-r--r--packages/taler-harness/src/integrationtests/test-paywall-flow.ts73
1 files changed, 35 insertions, 38 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
index a9601c625..b0477a049 100644
--- a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
+++ b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
@@ -19,18 +19,22 @@
*/
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
-} from "../harness/helpers.js";
-import {
PreparePayResultType,
codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType,
URL,
} from "@gnu-taler/taler-util";
-import axiosImp from "axios";
-const axios = axiosImp.default;
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import {
+ createSimpleTestkudosEnvironmentV2,
+ withdrawViaBankV2,
+} from "../harness/helpers.js";
+import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
+
+const httpLib = createPlatformHttpLib({
+ allowHttp: true,
+ enableThrottling: false,
+});
/**
* Run test for basic, bank-integrated withdrawal.
@@ -38,12 +42,17 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
export async function runPaywallFlowTest(t: GlobalTestState) {
// Set up test environment
- const { wallet, bank, exchange, merchant } =
- await createSimpleTestkudosEnvironment(t);
+ const { walletClient, bank, exchange, merchant } =
+ await createSimpleTestkudosEnvironmentV2(t);
// Withdraw digital cash into the wallet.
- await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
+ await withdrawViaBankV2(t, {
+ walletClient,
+ bank,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
/**
* =========================================================================
@@ -77,9 +86,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(orderStatus.already_paid_order_id === undefined);
let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
- let publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
- validateStatus: () => true,
- });
+ let publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
if (publicOrderStatusResp.status != 402) {
throw Error(
@@ -88,12 +95,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
}
let pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
- publicOrderStatusResp.data,
+ publicOrderStatusResp.json(),
);
console.log(pubUnpaidStatus);
- let preparePayResp = await wallet.client.call(
+ let preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: pubUnpaidStatus.taler_pay_uri,
@@ -105,10 +112,8 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
const proposalId = preparePayResp.proposalId;
console.log("requesting", publicOrderStatusUrl.href);
- publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
- validateStatus: () => true,
- });
- console.log("response body", publicOrderStatusResp.data);
+ publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
+ console.log("response body", publicOrderStatusResp.json());
if (publicOrderStatusResp.status != 402) {
throw Error(
`expected status 402 (after claiming), but got ${publicOrderStatusResp.status}`,
@@ -116,26 +121,20 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
}
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
- publicOrderStatusResp.data,
+ publicOrderStatusResp.json(),
);
- const confirmPayRes = await wallet.client.call(
- WalletApiOperation.ConfirmPay,
- {
- proposalId: proposalId,
- },
- );
+ const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
+ proposalId: proposalId,
+ });
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
+ publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
- publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
- validateStatus: () => true,
- });
-
- console.log(publicOrderStatusResp.data);
+ console.log(publicOrderStatusResp.json());
if (publicOrderStatusResp.status != 200) {
- console.log(publicOrderStatusResp.data);
+ console.log(publicOrderStatusResp.json());
throw Error(
`expected status 200 (after paying), but got ${publicOrderStatusResp.status}`,
);
@@ -158,7 +157,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// Pay with new taler://pay URI, which should
// have the new session ID!
// Wallet should now automatically re-play payment.
- preparePayResp = await wallet.client.call(
+ preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: talerPayUriOne,
@@ -199,7 +198,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
// Here the re-purchase detection should kick in,
// and the wallet should re-pay for the old order
// under the new session ID (mysession-three).
- preparePayResp = await wallet.client.call(
+ preparePayResp = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
talerPayUri: orderStatus.taler_pay_uri,
@@ -232,19 +231,17 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
console.log("requesting public status", publicOrderStatusUrl);
// Ask the order status of the claimed-but-unpaid order
- publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
- validateStatus: () => true,
- });
+ publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
if (publicOrderStatusResp.status != 402) {
throw Error(`expected status 402, but got ${publicOrderStatusResp.status}`);
}
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
- publicOrderStatusResp.data,
+ publicOrderStatusResp.json(),
);
- console.log(publicOrderStatusResp.data);
+ console.log(publicOrderStatusResp.json());
t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId);
}