gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: fix #7882


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix #7882
Date: Wed, 23 Aug 2023 15:46:17 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new ef5962cd3 fix #7882
ef5962cd3 is described below

commit ef5962cd3c78eb273acb87fec6002ba6c52dc5b3
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Aug 23 10:45:11 2023 -0300

    fix #7882
---
 packages/taler-harness/src/harness/helpers.ts      |  13 +++
 .../src/integrationtests/test-tos-format.ts        | 102 +++++++++++++++++++++
 .../src/integrationtests/testrunner.ts             |   2 +
 3 files changed, 117 insertions(+)

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 {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]