summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-08-23 10:45:11 -0300
committerSebastian <sebasjm@gmail.com>2023-08-23 10:46:06 -0300
commitef5962cd3c78eb273acb87fec6002ba6c52dc5b3 (patch)
tree092fa8912c276b923ed4a48c0fb3dba65434f559
parentd0d19c2e88c1443feeeec45abbc575f14489f02e (diff)
downloadwallet-core-ef5962cd3c78eb273acb87fec6002ba6c52dc5b3.tar.gz
wallet-core-ef5962cd3c78eb273acb87fec6002ba6c52dc5b3.tar.bz2
wallet-core-ef5962cd3c78eb273acb87fec6002ba6c52dc5b3.zip
fix #7882
-rw-r--r--packages/taler-harness/src/harness/helpers.ts13
-rw-r--r--packages/taler-harness/src/integrationtests/test-tos-format.ts102
-rw-r--r--packages/taler-harness/src/integrationtests/testrunner.ts2
3 files changed, 117 insertions, 0 deletions
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts
index dd2c85ce1..9ad46e587 100644
--- a/packages/taler-harness/src/harness/helpers.ts
+++ b/packages/taler-harness/src/harness/helpers.ts
@@ -95,6 +95,10 @@ export interface EnvOptions {
ageMaskSpec?: string;
mixedAgeRestriction?: boolean;
+
+ additionalExchangeConfig?(e: ExchangeService): void;
+ additionalMerchantConfig?(m: MerchantService): void;
+ additionalBankConfig?(b: BankService): void;
}
/**
@@ -331,6 +335,9 @@ export async function createSimpleTestkudosEnvironmentV2(
bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
+ if (opts.additionalBankConfig) {
+ opts.additionalBankConfig(bank)
+ }
await bank.start();
await bank.pingUntilAvailable();
@@ -357,11 +364,17 @@ export async function createSimpleTestkudosEnvironmentV2(
exchange.addCoinConfigList(coinConfig);
}
+ if (opts.additionalExchangeConfig) {
+ opts.additionalExchangeConfig(exchange)
+ }
await exchange.start();
await exchange.pingUntilAvailable();
merchant.addExchange(exchange);
+ if (opts.additionalMerchantConfig) {
+ opts.additionalMerchantConfig(merchant)
+ }
await merchant.start();
await merchant.pingUntilAvailable();
diff --git a/packages/taler-harness/src/integrationtests/test-tos-format.ts b/packages/taler-harness/src/integrationtests/test-tos-format.ts
new file mode 100644
index 000000000..ebe9c403a
--- /dev/null
+++ b/packages/taler-harness/src/integrationtests/test-tos-format.ts
@@ -0,0 +1,102 @@
+/*
+ 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 { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState } from "../harness/harness.js";
+import {
+ createSimpleTestkudosEnvironmentV2,
+} from "../harness/helpers.js";
+import * as fs from "fs";
+import * as path from "path";
+
+/**
+ * Run test for basic, bank-integrated withdrawal and payment.
+ */
+export async function runTermOfServiceFormatTest(t: GlobalTestState) {
+ // Set up test environment
+ const tosDir = t.testDir + `/tos/`;
+ const langs = ["es", "en", "de"]
+
+ langs.forEach(l => {
+ const langDir = tosDir + l + "/"
+ fs.mkdirSync(langDir, { recursive: true });
+ fs.writeFileSync(langDir + "v1.txt", "text content");
+ fs.writeFileSync(langDir + "v1.md", "markdown content");
+ fs.writeFileSync(langDir + "v1.html", "html content");
+ });
+
+ const { walletClient, exchange, } =
+ await createSimpleTestkudosEnvironmentV2(t, undefined, {
+ additionalExchangeConfig: (ex) => {
+ ex.changeConfig((cfg) => {
+ cfg.setString("exchange", "terms_etag", "v1")
+ cfg.setString("exchange", "terms_dir", tosDir)
+ })
+ }
+ });
+
+
+ {
+ const tos = await walletClient.client.call(WalletApiOperation.GetExchangeTos, {
+ exchangeBaseUrl: exchange.baseUrl,
+ })
+
+ t.assertDeepEqual(tos.content, "text content");
+ }
+
+ {
+ const tos = await walletClient.client.call(WalletApiOperation.GetExchangeTos, {
+ exchangeBaseUrl: exchange.baseUrl,
+ acceptedFormat: ["text/html"]
+ })
+
+ t.assertDeepEqual(tos.content, "html content");
+ }
+
+ {
+ const tos = await walletClient.client.call(WalletApiOperation.GetExchangeTos, {
+ exchangeBaseUrl: exchange.baseUrl,
+ acceptedFormat: ["text/markdown"]
+ })
+
+ t.assertDeepEqual(tos.content, "markdown content");
+ }
+
+ {
+ const tos = await walletClient.client.call(WalletApiOperation.GetExchangeTos, {
+ exchangeBaseUrl: exchange.baseUrl,
+ acceptedFormat: ["text/markdown", "text/html"]
+ })
+
+ // prefer markdown since its the first one in the list
+ t.assertDeepEqual(tos.content, "markdown content");
+ }
+
+ {
+ const tos = await walletClient.client.call(WalletApiOperation.GetExchangeTos, {
+ exchangeBaseUrl: exchange.baseUrl,
+ acceptedFormat: ["text/pdf", "text/html"]
+ })
+
+ // there is no pdf so fallback in html
+ t.assertDeepEqual(tos.content, "html content");
+ }
+}
+
+runTermOfServiceFormatTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts
index 58e2a20f7..a9b6d1304 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -104,6 +104,7 @@ import { runExchangeDepositTest } from "./test-exchange-deposit.js";
import { runPeerRepairTest } from "./test-peer-repair.js";
import { runPaymentShareTest } from "./test-payment-share.js";
import { runSimplePaymentTest } from "./test-simple-payment.js";
+import { runTermOfServiceFormatTest } from "./test-tos-format.js";
/**
* Test runner.
@@ -200,6 +201,7 @@ const allTests: TestMainFunction[] = [
runWithdrawalFakebankTest,
runWithdrawalFeesTest,
runWithdrawalHugeTest,
+ runTermOfServiceFormatTest,
];
export interface TestRunSpec {