From f262b288123d4198223274a3382b9a1110d3ca33 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 4 Feb 2021 17:13:31 +0100 Subject: use new auth token for merchant in integration tests --- .../src/integrationtests/harness.ts | 2 + .../src/integrationtests/test-tipping.ts | 2 +- .../src/integrationtests/test-wallettesting.ts | 98 +++++++++++++++++++--- 3 files changed, 91 insertions(+), 11 deletions(-) (limited to 'packages/taler-wallet-cli') diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts b/packages/taler-wallet-cli/src/integrationtests/harness.ts index aa09d5f74..ba02776e9 100644 --- a/packages/taler-wallet-cli/src/integrationtests/harness.ts +++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts @@ -1427,6 +1427,7 @@ export class MerchantService implements MerchantServiceInterface { console.log("adding instance"); const url = `http://localhost:${this.merchantConfig.httpPort}/private/instances`; await axios.post(url, { + auth_token: instanceConfig.authToken, payto_uris: instanceConfig.paytoUris, id: instanceConfig.id, name: instanceConfig.name, @@ -1462,6 +1463,7 @@ export class MerchantService implements MerchantServiceInterface { } export interface MerchantInstanceConfig { + authToken?: string; id: string; name: string; paytoUris: string[]; diff --git a/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts b/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts index 21422c42c..a89473313 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-tipping.ts @@ -18,7 +18,7 @@ * Imports. */ import { GlobalTestState, MerchantPrivateApi, BankApi } from "./harness"; -import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; +import { createSimpleTestkudosEnvironment } from "./helpers"; /** * Run test for basic, bank-integrated withdrawal. diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts index cdb954858..65d8aea25 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts @@ -22,26 +22,104 @@ /** * Imports. */ -import { GlobalTestState } from "./harness"; -import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; +import { CoinConfig, defaultCoinConfig } from "./denomStructures"; +import { + BankService, + ExchangeService, + GlobalTestState, + MerchantService, + setupDb, + WalletCli, +} from "./harness"; +import { SimpleTestEnvironment } from "./helpers"; + +const merchantAuthToken = "secret-token:sandbox"; /** - * Run test for basic, bank-integrated withdrawal. + * Run a test case with a simple TESTKUDOS Taler environment, consisting + * of one exchange, one bank and one merchant. */ -export async function runWallettestingTest(t: GlobalTestState) { - const { - wallet, - bank, +export async function createMyEnvironment( + t: GlobalTestState, + coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")), +): Promise { + const db = await setupDb(t); + + const bank = await BankService.create(t, { + allowRegistrations: true, + currency: "TESTKUDOS", + database: db.connStr, + httpPort: 8082, + }); + + const exchange = ExchangeService.create(t, { + name: "testexchange-1", + currency: "TESTKUDOS", + httpPort: 8081, + database: db.connStr, + }); + + const merchant = await MerchantService.create(t, { + name: "testmerchant-1", + currency: "TESTKUDOS", + httpPort: 8083, + database: db.connStr, + }); + + const exchangeBankAccount = await bank.createExchangeAccount( + "MyExchange", + "x", + ); + exchange.addBankAccount("1", exchangeBankAccount); + + bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); + + await bank.start(); + + await bank.pingUntilAvailable(); + + exchange.addCoinConfigList(coinConfig); + + await exchange.start(); + await exchange.pingUntilAvailable(); + + merchant.addExchange(exchange); + + await merchant.start(); + await merchant.pingUntilAvailable(); + + await merchant.addInstance({ + id: "default", + name: "Default Instance", + paytoUris: [`payto://x-taler-bank/merchant-default`], + }); + + console.log("setup done!"); + + const wallet = new WalletCli(t); + + return { + commonDb: db, exchange, merchant, - } = await createSimpleTestkudosEnvironment(t); + wallet, + bank, + exchangeBankAccount, + }; +} + +/** + * Run test for basic, bank-integrated withdrawal. + */ +export async function runWallettestingTest(t: GlobalTestState) { + const { wallet, bank, exchange, merchant } = await createMyEnvironment(t); await wallet.runIntegrationTest({ amountToSpend: "TESTKUDOS:5", amountToWithdraw: "TESTKUDOS:10", bankBaseUrl: bank.baseUrl, exchangeBaseUrl: exchange.baseUrl, - merchantApiKey: "sandbox", + merchantAuthToken: merchantAuthToken, merchantBaseUrl: merchant.makeInstanceBaseUrl(), }); @@ -70,7 +148,7 @@ export async function runWallettestingTest(t: GlobalTestState) { await wallet.testPay({ amount: "TESTKUDOS:5", - merchantApiKey: "sandbox", + merchantAuthToken: merchantAuthToken, merchantBaseUrl: merchant.makeInstanceBaseUrl(), summary: "foo", }); -- cgit v1.2.3