aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2020-11-03 15:56:02 +0100
committerFlorian Dold <florian@dold.me>2020-11-03 15:56:02 +0100
commitca343e4e0037cd986b3115079d370e61fc5897ce (patch)
treeae5ebf8fa6fdc8704272eb94151dd3f086413ec9 /packages
parente259d109efd998d0ff6197123a47b83bfe274680 (diff)
fix broken integration tests due to merchant API changes
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-integrationtests/src/merchantApiTypes.ts18
-rw-r--r--packages/taler-integrationtests/src/test-claim-loop.ts19
-rw-r--r--packages/taler-integrationtests/src/test-merchant-refund-api.ts4
-rw-r--r--packages/taler-integrationtests/src/test-pay-paid.ts32
-rw-r--r--packages/taler-integrationtests/src/test-paywall-flow.ts12
-rw-r--r--packages/taler-integrationtests/src/test-refund-auto.ts3
-rw-r--r--packages/taler-integrationtests/src/test-refund-incremental.ts3
-rw-r--r--packages/taler-integrationtests/src/test-refund.ts2
8 files changed, 64 insertions, 29 deletions
diff --git a/packages/taler-integrationtests/src/merchantApiTypes.ts b/packages/taler-integrationtests/src/merchantApiTypes.ts
index 1cfc72db1..a7d0ea2cb 100644
--- a/packages/taler-integrationtests/src/merchantApiTypes.ts
+++ b/packages/taler-integrationtests/src/merchantApiTypes.ts
@@ -107,6 +107,12 @@ export const codecForCheckPaymentUnpaidResponse = (): Codec<
.property("already_paid_order_id", codecOptional(codecForString()))
.build("CheckPaymentPaidResponse");
+export const codecForCheckPaymentClaimedResponse = (): Codec<CheckPaymentClaimedResponse> =>
+ buildCodecForObject<CheckPaymentClaimedResponse>()
+ .property("order_status", codecForConstString("claimed"))
+ .property("contract_terms", codecForContractTerms())
+ .build("CheckPaymentClaimedResponse");
+
export const codecForMerchantOrderPrivateStatusResponse = (): Codec<
MerchantOrderPrivateStatusResponse
> =>
@@ -114,11 +120,20 @@ export const codecForMerchantOrderPrivateStatusResponse = (): Codec<
.discriminateOn("order_status")
.alternative("paid", codecForCheckPaymentPaidResponse())
.alternative("unpaid", codecForCheckPaymentUnpaidResponse())
+ .alternative("claimed", codecForCheckPaymentClaimedResponse())
.build("MerchantOrderPrivateStatusResponse");
export type MerchantOrderPrivateStatusResponse =
| CheckPaymentPaidResponse
- | CheckPaymentUnpaidResponse;
+ | CheckPaymentUnpaidResponse
+ | CheckPaymentClaimedResponse;
+
+export interface CheckPaymentClaimedResponse {
+ // Wallet claimed the order, but didn't pay yet.
+ order_status: "claimed";
+
+ contract_terms: ContractTerms;
+}
export interface CheckPaymentPaidResponse {
// did the customer pay for this contract
@@ -164,6 +179,7 @@ export interface CheckPaymentPaidResponse {
order_status_url: string;
}
+
export interface CheckPaymentUnpaidResponse {
order_status: "unpaid";
diff --git a/packages/taler-integrationtests/src/test-claim-loop.ts b/packages/taler-integrationtests/src/test-claim-loop.ts
index 22a04b7df..da8f7d45d 100644
--- a/packages/taler-integrationtests/src/test-claim-loop.ts
+++ b/packages/taler-integrationtests/src/test-claim-loop.ts
@@ -24,11 +24,13 @@ import {
WalletCli,
} from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
-import { PreparePayResultType, TalerErrorCode } from "taler-wallet-core";
import { URL } from "url"
/**
- * Run test for basic, bank-integrated withdrawal.
+ * Run test for the merchant's order lifecycle.
+ *
+ * FIXME: Is this test still necessary? We initially wrote if to confirm/document
+ * assumptions about how the merchant should work.
*/
runTest(async (t: GlobalTestState) => {
// Set up test environment
@@ -55,6 +57,7 @@ runTest(async (t: GlobalTestState) => {
let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderId: orderResp.order_id,
});
+ t.assertTrue(orderStatusBefore.order_status === "unpaid");
let statusUrlBefore = new URL(orderStatusBefore.order_status_url);
// Make wallet claim the unpaid order.
@@ -68,17 +71,7 @@ runTest(async (t: GlobalTestState) => {
let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderId: orderResp.order_id,
});
- let statusUrlAfter = new URL(orderStatusAfter.order_status_url)
-
- let tokenBefore = statusUrlBefore.searchParams.get("token")
- let tokenAfter = statusUrlAfter.searchParams.get("token")
- let hashContractAfter = statusUrlAfter.searchParams.get("h_contract")
-
- // after claiming the contract, we either want its hash in the
- // status url, or at least see again its token in the status url.
- t.assertTrue(
- (hashContractAfter !== null) || (tokenBefore === tokenAfter)
- )
+ t.assertTrue(orderStatusAfter.order_status === "claimed");
await t.shutdown();
});
diff --git a/packages/taler-integrationtests/src/test-merchant-refund-api.ts b/packages/taler-integrationtests/src/test-merchant-refund-api.ts
index af7000c96..121c571d2 100644
--- a/packages/taler-integrationtests/src/test-merchant-refund-api.ts
+++ b/packages/taler-integrationtests/src/test-merchant-refund-api.ts
@@ -32,7 +32,7 @@ import {
withdrawViaBank,
SimpleTestEnvironment,
} from "./helpers";
-import { PreparePayResultType, URL } from "taler-wallet-core";
+import { durationFromSpec, PreparePayResultType, URL } from "taler-wallet-core";
import axios from "axios";
async function testRefundApiWithFulfillmentUrl(
@@ -53,6 +53,7 @@ async function testRefundApiWithFulfillmentUrl(
amount: "TESTKUDOS:5",
fulfillment_url: "https://example.com/fulfillment",
},
+ refund_delay: durationFromSpec({ minutes: 5 }),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
@@ -162,6 +163,7 @@ async function testRefundApiWithFulfillmentMessage(
amount: "TESTKUDOS:5",
fulfillment_message: "Thank you for buying foobar",
},
+ refund_delay: durationFromSpec({ minutes: 5 }),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
diff --git a/packages/taler-integrationtests/src/test-pay-paid.ts b/packages/taler-integrationtests/src/test-pay-paid.ts
index 61e8ce80f..b5dd6bd79 100644
--- a/packages/taler-integrationtests/src/test-pay-paid.ts
+++ b/packages/taler-integrationtests/src/test-pay-paid.ts
@@ -19,7 +19,6 @@
*/
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
import {
- createSimpleTestkudosEnvironment,
withdrawViaBank,
createFaultInjectedMerchantTestkudosEnvironment,
} from "./helpers";
@@ -33,7 +32,12 @@ import axios from "axios";
import { FaultInjectionRequestContext } from "./faultInjection";
/**
- * Run test for basic, bank-integrated withdrawal.
+ * Run test for the wallets repurchase detection mechanism
+ * based on the fulfillment URL.
+ *
+ * FIXME: This test is now almost the same as test-paywall-flow,
+ * since we can't initiate payment via a "claimed" private order status
+ * response.
*/
runTest(async (t: GlobalTestState) => {
// Set up test environment
@@ -146,10 +150,10 @@ runTest(async (t: GlobalTestState) => {
sessionId: "mysession-two",
});
- // Should be unpaid because of a new session ID
- t.assertTrue(orderStatus.order_status === "unpaid");
+ console.log("order status under mysession-two:", JSON.stringify(orderStatus, undefined, 2));
- publicOrderStatusUrl = orderStatus.order_status_url;
+ // Should be claimed (not paid!) because of a new session ID
+ t.assertTrue(orderStatus.order_status === "claimed");
let numPayRequested = 0;
let numPaidRequested = 0;
@@ -165,11 +169,27 @@ runTest(async (t: GlobalTestState) => {
},
});
+
+ let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", {
+ order: {
+ summary: "Buy me!",
+ amount: "TESTKUDOS:5",
+ fulfillment_url: "https://example.com/article42",
+ },
+ });
+
+ let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
+ orderId: orderRespTwo.order_id,
+ sessionId: "mysession-two",
+ });
+
+ t.assertTrue(orderStatusTwo.order_status === "unpaid");
+
// Pay with new taler://pay URI, which should
// have the new session ID!
// Wallet should now automatically re-play payment.
preparePayResp = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
+ talerPayUri: orderStatusTwo.taler_pay_uri,
});
t.assertTrue(preparePayResp.status === PreparePayResultType.AlreadyConfirmed);
diff --git a/packages/taler-integrationtests/src/test-paywall-flow.ts b/packages/taler-integrationtests/src/test-paywall-flow.ts
index 350a60dde..54c8ab463 100644
--- a/packages/taler-integrationtests/src/test-paywall-flow.ts
+++ b/packages/taler-integrationtests/src/test-paywall-flow.ts
@@ -69,6 +69,8 @@ runTest(async (t: GlobalTestState) => {
t.assertTrue(orderStatus.order_status === "unpaid");
+ const talerPayUriOne = orderStatus.taler_pay_uri;
+
t.assertTrue(orderStatus.already_paid_order_id === undefined);
let publicOrderStatusUrl = orderStatus.order_status_url;
@@ -140,16 +142,14 @@ runTest(async (t: GlobalTestState) => {
sessionId: "mysession-two",
});
- // Should be unpaid because of a new session ID
- t.assertTrue(orderStatus.order_status === "unpaid");
-
- publicOrderStatusUrl = orderStatus.order_status_url;
+ // Should be claimed (not paid!) because of a new session ID
+ t.assertTrue(orderStatus.order_status === "claimed");
// Pay with new taler://pay URI, which should
// have the new session ID!
// Wallet should now automatically re-play payment.
preparePayResp = await wallet.preparePay({
- talerPayUri: orderStatus.taler_pay_uri,
+ talerPayUri: talerPayUriOne,
});
t.assertTrue(preparePayResp.status === PreparePayResultType.AlreadyConfirmed);
@@ -208,7 +208,7 @@ runTest(async (t: GlobalTestState) => {
sessionId: "mysession-four",
});
- t.assertTrue(orderStatus.order_status === "unpaid");
+ t.assertTrue(orderStatus.order_status === "claimed");
// Now check if the public status of the new order is correct.
diff --git a/packages/taler-integrationtests/src/test-refund-auto.ts b/packages/taler-integrationtests/src/test-refund-auto.ts
index cd688a2b1..91051b22d 100644
--- a/packages/taler-integrationtests/src/test-refund-auto.ts
+++ b/packages/taler-integrationtests/src/test-refund-auto.ts
@@ -19,7 +19,7 @@
*/
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
-import { CoreApiResponse } from "taler-wallet-core";
+import { CoreApiResponse, durationFromSpec } from "taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -48,6 +48,7 @@ runTest(async (t: GlobalTestState) => {
d_ms: 3000,
},
},
+ refund_delay: durationFromSpec({ minutes: 5}),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
diff --git a/packages/taler-integrationtests/src/test-refund-incremental.ts b/packages/taler-integrationtests/src/test-refund-incremental.ts
index 661378dc8..d83fda470 100644
--- a/packages/taler-integrationtests/src/test-refund-incremental.ts
+++ b/packages/taler-integrationtests/src/test-refund-incremental.ts
@@ -24,7 +24,7 @@ import {
MerchantPrivateApi,
} from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
-import { TransactionType, Amounts } from "taler-wallet-core";
+import { TransactionType, Amounts, durationFromSpec } from "taler-wallet-core";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -51,6 +51,7 @@ runTest(async (t: GlobalTestState) => {
amount: "TESTKUDOS:10",
fulfillment_url: "taler://fulfillment-success/thx",
},
+ refund_delay: durationFromSpec({ minutes: 5}),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
diff --git a/packages/taler-integrationtests/src/test-refund.ts b/packages/taler-integrationtests/src/test-refund.ts
index bda609c95..40fadd5de 100644
--- a/packages/taler-integrationtests/src/test-refund.ts
+++ b/packages/taler-integrationtests/src/test-refund.ts
@@ -17,6 +17,7 @@
/**
* Imports.
*/
+import { durationFromSpec } from 'taler-wallet-core';
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
@@ -45,6 +46,7 @@ runTest(async (t: GlobalTestState) => {
amount: "TESTKUDOS:5",
fulfillment_url: "taler://fulfillment-success/thx",
},
+ refund_delay: durationFromSpec({ minutes: 5}),
});
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {