aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-09-02 09:29:13 +0000
committerMS <ms@taler.net>2021-09-02 09:29:13 +0000
commit311f89c8ba30856f382d3a77d6787b7c039e8f58 (patch)
tree8dff8cdc4d824e1c3314e5b744440a8b48554fb4 /packages/taler-wallet-cli
parent4e9d59e6f66b22e42734043c9c0f164038eec57a (diff)
testing c52/c53 coordination,
and allow passing query parameters to the "fetch transactions" API from Nexus.
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/libeufin.ts10
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts2
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts2
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-c5x.ts137
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-facade-anastasis.ts6
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-keyrotation.ts4
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund-multiple-users.ts2
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts2
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/testrunner.ts2
9 files changed, 154 insertions, 13 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
index 35ce93ec9..a38a69ed9 100644
--- a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
@@ -245,7 +245,7 @@ export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
async makeTransaction(
debit: string,
credit: string,
- amount: string,
+ amount: string, // $currency:x.y
subject: string,): Promise<string> {
const stdout = await sh(
this.globalTestState,
@@ -1237,9 +1237,11 @@ export namespace LibeufinNexusApi {
return response;
}
- export async function fetchAllTransactions(
+ export async function fetchTransactions(
libeufinNexusService: LibeufinNexusService,
accountName: string,
+ rangeType: string = "all",
+ level: string = "report",
username: string = "admin",
password: string = "test",
): Promise<any> {
@@ -1251,8 +1253,8 @@ export namespace LibeufinNexusApi {
return await axios.post(
url.href,
{
- rangeType: "all",
- level: "report",
+ rangeType: rangeType,
+ level: level,
},
{
auth: {
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts
index 7b5971480..8e079caa4 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-api-bankaccount.ts
@@ -99,7 +99,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
subject: "mock subject",
}
);
- await LibeufinNexusApi.fetchAllTransactions(nexus, "local-mock");
+ await LibeufinNexusApi.fetchTransactions(nexus, "local-mock");
let transactions = await LibeufinNexusApi.getAccountTransactions(
nexus,
"local-mock",
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
index 4a6b22539..b284d7299 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
@@ -264,7 +264,7 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
},
);
- await LibeufinNexusApi.fetchAllTransactions(libeufinNexus, "myacct");
+ await LibeufinNexusApi.fetchTransactions(libeufinNexus, "myacct");
await exchange.runWirewatchOnce();
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-c5x.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-c5x.ts
new file mode 100644
index 000000000..ebde5206d
--- /dev/null
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-c5x.ts
@@ -0,0 +1,137 @@
+/*
+ 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, delayMs } from "./harness";
+import {
+ SandboxUserBundle,
+ NexusUserBundle,
+ launchLibeufinServices,
+ LibeufinSandboxApi,
+ LibeufinNexusApi,
+} from "./libeufin";
+
+/**
+ * This test checks how the C52 and C53 coordinate. It'll test
+ * whether fresh transactions stop showing as C52 after they get
+ * included in a bank statement.
+ */
+export async function runLibeufinC5xTest(t: GlobalTestState) {
+ /**
+ * User saltetd "01"
+ */
+ const user01nexus = new NexusUserBundle(
+ "01",
+ "http://localhost:5010/ebicsweb",
+ );
+ const user01sandbox = new SandboxUserBundle("01");
+
+ /**
+ * User saltetd "02".
+ */
+ const user02nexus = new NexusUserBundle(
+ "02",
+ "http://localhost:5010/ebicsweb",
+ );
+ const user02sandbox = new SandboxUserBundle("02");
+
+ /**
+ * Launch Sandbox and Nexus.
+ */
+ const libeufinServices = await launchLibeufinServices(
+ t,
+ [user01nexus, user02nexus],
+ [user01sandbox, user02sandbox],
+ ["twg"],
+ );
+
+ // Check that C52 and C53 have zero entries.
+
+ // C52
+ await LibeufinNexusApi.fetchTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ "all", // range
+ "report", // level
+ );
+ // C53
+ await LibeufinNexusApi.fetchTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ "all", // range
+ "statement", // level
+ );
+ const nexusTxs = await LibeufinNexusApi.getAccountTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ );
+ t.assertTrue(nexusTxs.data["transactions"].length == 0);
+
+ // Addressing one payment to user 01
+ await libeufinServices.libeufinSandbox.makeTransaction(
+ user02sandbox.ebicsBankAccount.label, // debit
+ user01sandbox.ebicsBankAccount.label, // credit
+ "EUR:10",
+ "first payment",
+ );
+
+ // Checking that C52 has one and C53 has zero.
+
+ let expectOne = await LibeufinNexusApi.fetchTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ "all", // range
+ "report", // C52
+ );
+ t.assertTrue(expectOne.data.newTransactions == 1);
+ t.assertTrue(expectOne.data.downloadedTransactions == 1);
+ let expectZero = await LibeufinNexusApi.fetchTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ "all", // range
+ "statement", // C53
+ );
+ t.assertTrue(expectZero.data.newTransactions == 0);
+ t.assertTrue(expectZero.data.downloadedTransactions == 0);
+
+ // Ticking now: the one payment should be downloaded
+ // in a C53 but not in a C52. In any case, the payment
+ // is not new anymore, because it was already ingested
+ // when it was downloaded for the first time along the
+ // c52 above.
+ await libeufinServices.libeufinSandbox.c53tick();
+
+ expectOne = await LibeufinNexusApi.fetchTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ "all", // range
+ "statement", // C53
+ );
+ t.assertTrue(expectOne.data.downloadedTransactions == 1);
+ t.assertTrue(expectOne.data.newTransactions == 0);
+
+ expectZero = await LibeufinNexusApi.fetchTransactions(
+ libeufinServices.libeufinNexus,
+ user01nexus.localAccountName,
+ "all", // range
+ "report", // C52
+ );
+ t.assertTrue(expectZero.data.downloadedTransactions == 0);
+ t.assertTrue(expectZero.data.newTransactions == 0);
+}
+runLibeufinC5xTest.suites = ["libeufin"];
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-facade-anastasis.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-facade-anastasis.ts
index 4afaacd3c..143870128 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-facade-anastasis.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-facade-anastasis.ts
@@ -58,7 +58,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
t.assertTrue(anastasisBaseUrl.startsWith("http://"));
t.assertTrue(anastasisBaseUrl.endsWith("/"));
- await LibeufinNexusApi.fetchAllTransactions(
+ await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
@@ -107,7 +107,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
},
)
- await LibeufinNexusApi.fetchAllTransactions(
+ await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
@@ -140,7 +140,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
},
)
- await LibeufinNexusApi.fetchAllTransactions(
+ await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-keyrotation.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-keyrotation.ts
index 97135267a..6a5e5c204 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-keyrotation.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-keyrotation.ts
@@ -46,7 +46,7 @@ export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
t, [user01nexus], [user01sandbox],
);
- await LibeufinNexusApi.fetchAllTransactions(
+ await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
@@ -57,7 +57,7 @@ export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
user01sandbox.ebicsBankAccount.subscriber.hostID,
);
- const resp = await LibeufinNexusApi.fetchAllTransactions(
+ const resp = await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund-multiple-users.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund-multiple-users.ts
index 1159ddf48..234a7bae8 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund-multiple-users.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund-multiple-users.ts
@@ -77,7 +77,7 @@ export async function runLibeufinRefundMultipleUsersTest(t: GlobalTestState) {
);
// user 01 fetches the payments
- await LibeufinNexusApi.fetchAllTransactions(
+ await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
index 5f6619de5..5d5370d02 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
@@ -68,7 +68,7 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
// The bad payment should be now ingested and prepared as
// a reimbursement.
- await LibeufinNexusApi.fetchAllTransactions(
+ await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus,
user01nexus.localAccountName,
);
diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
index 71f92095a..384f08438 100644
--- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
@@ -57,6 +57,7 @@ import { runWithdrawalAbortBankTest } from "./test-withdrawal-abort-bank";
import { runWithdrawalBankIntegratedTest } from "./test-withdrawal-bank-integrated";
import { runMerchantExchangeConfusionTest } from "./test-merchant-exchange-confusion";
import { runLibeufinBasicTest } from "./test-libeufin-basic";
+import { runLibeufinC5xTest } from "./test-libeufin-c5x";
import { runLibeufinKeyrotationTest } from "./test-libeufin-keyrotation";
import { runLibeufinRefundTest } from "./test-libeufin-refund";
import { runLibeufinRefundMultipleUsersTest } from "./test-libeufin-refund-multiple-users";
@@ -111,6 +112,7 @@ const allTests: TestMainFunction[] = [
runLibeufinKeyrotationTest,
runLibeufinTutorialTest,
runLibeufinRefundTest,
+ runLibeufinC5xTest,
runLibeufinRefundMultipleUsersTest,
runLibeufinApiPermissionsTest,
runLibeufinApiFacadeTest,