aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/harness.ts10
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/helpers.ts8
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-payment-on-demo.ts99
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/testrunner.ts2
4 files changed, 114 insertions, 5 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts b/packages/taler-wallet-cli/src/integrationtests/harness.ts
index ffaffca1a..f5ce0f1a5 100644
--- a/packages/taler-wallet-cli/src/integrationtests/harness.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts
@@ -118,6 +118,10 @@ export async function delayMs(ms: number): Promise<void> {
});
}
+export interface WithAuthorization {
+ Authorization?: string,
+} ;
+
interface WaitResult {
code: number | null;
signal: NodeJS.Signals | null;
@@ -1258,16 +1262,18 @@ export namespace MerchantPrivateApi {
merchantService: MerchantServiceInterface,
instanceName: string,
req: PostOrderRequest,
+ withAuthorization: WithAuthorization = {},
): Promise<PostOrderResponse> {
const baseUrl = merchantService.makeInstanceBaseUrl(instanceName);
let url = new URL("private/orders", baseUrl);
- const resp = await axios.post(url.href, req);
+ const resp = await axios.post(url.href, req, { headers: withAuthorization });
return codecForPostOrderResponse().decode(resp.data);
}
export async function queryPrivateOrderStatus(
merchantService: MerchantServiceInterface,
query: PrivateOrderStatusQuery,
+ withAuthorization: WithAuthorization = {},
): Promise<MerchantOrderPrivateStatusResponse> {
const reqUrl = new URL(
`private/orders/${query.orderId}`,
@@ -1276,7 +1282,7 @@ export namespace MerchantPrivateApi {
if (query.sessionId) {
reqUrl.searchParams.set("session_id", query.sessionId);
}
- const resp = await axios.get(reqUrl.href);
+ const resp = await axios.get(reqUrl.href, { headers: withAuthorization });
return codecForMerchantOrderPrivateStatusResponse().decode(resp.data);
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/helpers.ts b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
index aa9164c19..215c0629f 100644
--- a/packages/taler-wallet-cli/src/integrationtests/helpers.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
@@ -49,6 +49,7 @@ import {
MerchantServiceInterface,
MerchantPrivateApi,
HarnessExchangeBankAccount,
+ WithAuthorization,
} from "./harness.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@@ -345,6 +346,7 @@ export async function makeTestPayment(
order: Partial<ContractTerms>;
instance?: string;
},
+ auth: WithAuthorization = {},
): Promise<void> {
// Set up order.
@@ -353,11 +355,11 @@ export async function makeTestPayment(
const orderResp = await MerchantPrivateApi.createOrder(merchant, instance, {
order: args.order,
- });
+ }, auth);
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderId: orderResp.order_id,
- });
+ }, auth);
t.assertTrue(orderStatus.order_status === "unpaid");
@@ -385,7 +387,7 @@ export async function makeTestPayment(
orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderId: orderResp.order_id,
instance,
- });
+ }, auth);
t.assertTrue(orderStatus.order_status === "paid");
}
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-payment-on-demo.ts b/packages/taler-wallet-cli/src/integrationtests/test-payment-on-demo.ts
new file mode 100644
index 000000000..666ff5984
--- /dev/null
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-on-demo.ts
@@ -0,0 +1,99 @@
+/*
+ This file is part of GNU Taler
+ (C) 2020 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Imports.
+ */
+import {
+ GlobalTestState,
+ BankApi,
+ WalletCli,
+ BankAccessApi
+} from "./harness";
+import {
+ createSimpleTestkudosEnvironment,
+ withdrawViaBank,
+ makeTestPayment,
+} from "./helpers";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+
+/**
+ * Run test for basic, bank-integrated withdrawal and payment.
+ */
+export async function runPaymentDemoTest(t: GlobalTestState) {
+
+ // Withdraw digital cash into the wallet.
+ let bankInterface = {
+ baseUrl: "https://bank.demo.taler.net/",
+ port: 0 // unused.
+ };
+ let user = await BankApi.createRandomBankUser(bankInterface);
+ let wop = await BankAccessApi.createWithdrawalOperation(bankInterface, user, "KUDOS:20");
+
+ let wallet = new WalletCli(t);
+ await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ });
+
+ await wallet.runPending();
+
+ // Confirm it
+
+ await BankApi.confirmWithdrawalOperation(bankInterface, user, wop);
+
+ // Withdraw
+
+ await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
+ exchangeBaseUrl: "https://exchange.demo.taler.net/",
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ });
+ await wallet.runUntilDone();
+
+ let balanceBefore = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ t.assertTrue(balanceBefore["balances"].length == 1);
+
+ const order = {
+ summary: "Buy me!",
+ amount: "KUDOS:5",
+ fulfillment_url: "taler://fulfillment-success/thx",
+ };
+
+ let merchant = {
+ makeInstanceBaseUrl: function(instanceName?: string) {
+ return "https://backend.demo.taler.net/instances/donations/";
+ },
+ port: 0,
+ name: "donations",
+ };
+
+ t.assertTrue("TALER_MERCHANT_TOKEN" in process.env);
+
+ await makeTestPayment(
+ t,
+ {
+ merchant, wallet, order
+ },
+ {
+ "Authorization": `Bearer ${process.env["TALER_MERCHANT_TOKEN"]}`,
+ });
+
+ await wallet.runUntilDone();
+
+ let balanceAfter = await wallet.client.call(WalletApiOperation.GetBalances, {});
+ t.assertTrue(balanceAfter["balances"].length == 1);
+ t.assertTrue(balanceBefore["balances"][0]["available"] > balanceAfter["balances"][0]["available"]);
+}
+runPaymentDemoTest.suites = ["buildbot"];
diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
index a42c79ac7..82fbe8bff 100644
--- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
@@ -22,6 +22,7 @@ import {
TestRunResult,
} from "./harness";
import { runPaymentTest } from "./test-payment";
+import { runPaymentDemoTest } from "./test-payment-on-demo";
import * as fs from "fs";
import * as path from "path";
import * as os from "os";
@@ -115,6 +116,7 @@ const allTests: TestMainFunction[] = [
runPaymentIdempotencyTest,
runPaymentMultipleTest,
runPaymentTest,
+ runPaymentDemoTest,
runPaymentTransientTest,
runPayPaidTest,
runPaywallFlowTest,