fix #7882
This commit is contained in:
parent
d0d19c2e88
commit
ef5962cd3c
@ -95,6 +95,10 @@ export interface EnvOptions {
|
|||||||
ageMaskSpec?: string;
|
ageMaskSpec?: string;
|
||||||
|
|
||||||
mixedAgeRestriction?: boolean;
|
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);
|
bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
|
||||||
|
|
||||||
|
if (opts.additionalBankConfig) {
|
||||||
|
opts.additionalBankConfig(bank)
|
||||||
|
}
|
||||||
await bank.start();
|
await bank.start();
|
||||||
|
|
||||||
await bank.pingUntilAvailable();
|
await bank.pingUntilAvailable();
|
||||||
@ -357,11 +364,17 @@ export async function createSimpleTestkudosEnvironmentV2(
|
|||||||
exchange.addCoinConfigList(coinConfig);
|
exchange.addCoinConfigList(coinConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.additionalExchangeConfig) {
|
||||||
|
opts.additionalExchangeConfig(exchange)
|
||||||
|
}
|
||||||
await exchange.start();
|
await exchange.start();
|
||||||
await exchange.pingUntilAvailable();
|
await exchange.pingUntilAvailable();
|
||||||
|
|
||||||
merchant.addExchange(exchange);
|
merchant.addExchange(exchange);
|
||||||
|
|
||||||
|
if (opts.additionalMerchantConfig) {
|
||||||
|
opts.additionalMerchantConfig(merchant)
|
||||||
|
}
|
||||||
await merchant.start();
|
await merchant.start();
|
||||||
await merchant.pingUntilAvailable();
|
await merchant.pingUntilAvailable();
|
||||||
|
|
||||||
|
102
packages/taler-harness/src/integrationtests/test-tos-format.ts
Normal file
102
packages/taler-harness/src/integrationtests/test-tos-format.ts
Normal file
@ -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"];
|
@ -104,6 +104,7 @@ import { runExchangeDepositTest } from "./test-exchange-deposit.js";
|
|||||||
import { runPeerRepairTest } from "./test-peer-repair.js";
|
import { runPeerRepairTest } from "./test-peer-repair.js";
|
||||||
import { runPaymentShareTest } from "./test-payment-share.js";
|
import { runPaymentShareTest } from "./test-payment-share.js";
|
||||||
import { runSimplePaymentTest } from "./test-simple-payment.js";
|
import { runSimplePaymentTest } from "./test-simple-payment.js";
|
||||||
|
import { runTermOfServiceFormatTest } from "./test-tos-format.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test runner.
|
* Test runner.
|
||||||
@ -200,6 +201,7 @@ const allTests: TestMainFunction[] = [
|
|||||||
runWithdrawalFakebankTest,
|
runWithdrawalFakebankTest,
|
||||||
runWithdrawalFeesTest,
|
runWithdrawalFeesTest,
|
||||||
runWithdrawalHugeTest,
|
runWithdrawalHugeTest,
|
||||||
|
runTermOfServiceFormatTest,
|
||||||
];
|
];
|
||||||
|
|
||||||
export interface TestRunSpec {
|
export interface TestRunSpec {
|
||||||
|
Loading…
Reference in New Issue
Block a user