diff options
author | Florian Dold <florian@dold.me> | 2023-04-23 23:08:37 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-04-23 23:08:37 +0200 |
commit | b81ea1b4b75c6f326d331c5c23d94e807b895563 (patch) | |
tree | 0cf6d1dddafe1b10d7515b3d785acbdbc8da4bf6 /packages | |
parent | eff3920bd5a2bff58d66ac72ba8bd2c1577f452f (diff) | |
download | wallet-core-b81ea1b4b75c6f326d331c5c23d94e807b895563.tar.xz |
harness: adjust to merchant API breaking changes, remove test that doesn't belong
Diffstat (limited to 'packages')
4 files changed, 46 insertions, 120 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 8b74c9e9f..b6e80cfb7 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -1884,7 +1884,9 @@ export class MerchantService implements MerchantServiceInterface { const body: MerchantInstanceConfig = { auth, - payto_uris: instanceConfig.paytoUris, + accounts: instanceConfig.paytoUris.map((x) => ({ + payto_uri: x, + })), id: instanceConfig.id, name: instanceConfig.name, address: instanceConfig.address ?? {}, @@ -1930,6 +1932,7 @@ export interface MerchantAuthConfiguration { token?: string; } +// FIXME: Why do we need this? Describe / fix! export interface PartialMerchantInstanceConfig { auth?: MerchantAuthConfiguration; id: string; @@ -1944,11 +1947,42 @@ export interface PartialMerchantInstanceConfig { defaultPayDelay?: TalerProtocolDuration; } +// FIXME: Move all these types into merchant-api-types.ts! + +type FacadeCredentials = NoFacadeCredentials | BasicAuthFacadeCredentials; +interface NoFacadeCredentials { + type: "none"; +} +interface BasicAuthFacadeCredentials { + type: "basic"; + + // Username to use to authenticate + username: string; + + // Password to use to authenticate + password: string; +} + +interface MerchantBankAccount { + // The payto:// URI where the wallet will send coins. + payto_uri: string; + + // Optional base URL for a facade where the + // merchant backend can see incoming wire + // transfers to reconcile its accounting + // with that of the exchange. Used by + // taler-merchant-wirewatch. + credit_facade_url?: string; + + // Credentials for accessing the credit facade. + credit_facade_credentials?: FacadeCredentials; +} + export interface MerchantInstanceConfig { + accounts: MerchantBankAccount[]; auth: MerchantAuthConfiguration; id: string; name: string; - payto_uris: string[]; address: unknown; jurisdiction: unknown; default_max_wire_fee: string; diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts index a4e44c7f3..1b5d50fd1 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts @@ -78,7 +78,11 @@ export async function runMerchantInstancesUrlsTest(t: GlobalTestState) { ), jurisdiction: {}, name: "My Default Instance", - payto_uris: [getPayto("bar")], + accounts: [ + { + payto_uri: getPayto("bar"), + }, + ], auth: { method: "token", token: "secret-token:i-am-default", @@ -99,7 +103,11 @@ export async function runMerchantInstancesUrlsTest(t: GlobalTestState) { ), jurisdiction: {}, name: "My Second Instance", - payto_uris: [getPayto("bar")], + accounts: [ + { + payto_uri: getPayto("bar"), + }, + ], auth: { method: "token", token: "secret-token:i-am-myinst", diff --git a/packages/taler-harness/src/integrationtests/test-payment-on-demo.ts b/packages/taler-harness/src/integrationtests/test-payment-on-demo.ts deleted file mode 100644 index 22e88c8a0..000000000 --- a/packages/taler-harness/src/integrationtests/test-payment-on-demo.ts +++ /dev/null @@ -1,114 +0,0 @@ -/* - 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, WalletCli } from "../harness/harness.js"; -import { makeTestPayment } from "../harness/helpers.js"; -import { - WalletApiOperation, - BankApi, - BankAccessApi, - BankServiceHandle, -} from "@gnu-taler/taler-wallet-core"; -import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; - -/** - * Run test for basic, bank-integrated withdrawal and payment. - */ -export async function runPaymentDemoTest(t: GlobalTestState) { - // Withdraw digital cash into the wallet. - let bankInterface: BankServiceHandle = { - baseUrl: "https://bank.demo.taler.net/", - bankAccessApiBaseUrl: "https://bank.demo.taler.net/", - http: createPlatformHttpLib(), - }; - let user = await BankApi.createRandomBankUser(bankInterface); - let wop = await BankAccessApi.createWithdrawalOperation( - bankInterface, - user, - "KUDOS:20", - ); - - let wallet = new WalletCli(t); - await wallet.client.call(WalletApiOperation.GetWithdrawalDetailsForUri, { - talerWithdrawUri: wop.taler_withdraw_uri, - }); - - await wallet.runPending(); - - // Confirm it - - await BankApi.confirmWithdrawalOperation(bankInterface, user, wop); - - // Withdraw - - await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, { - exchangeBaseUrl: "https://exchange.demo.taler.net/", - talerWithdrawUri: wop.taler_withdraw_uri, - }); - await wallet.runUntilDone(); - - let balanceBefore = await wallet.client.call( - WalletApiOperation.GetBalances, - {}, - ); - t.assertTrue(balanceBefore["balances"].length == 1); - - const order = { - summary: "Buy me!", - amount: "KUDOS:5", - fulfillment_url: "taler://fulfillment-success/thx", - }; - - let merchant = { - makeInstanceBaseUrl: function (instanceName?: string) { - return "https://backend.demo.taler.net/instances/donations/"; - }, - port: 0, - name: "donations", - }; - - t.assertTrue("TALER_ENV_FRONTENDS_APITOKEN" in process.env); - - await makeTestPayment( - t, - { - merchant, - wallet, - order, - }, - { - Authorization: `Bearer ${process.env["TALER_ENV_FRONTENDS_APITOKEN"]}`, - }, - ); - - await wallet.runUntilDone(); - - let balanceAfter = await wallet.client.call( - WalletApiOperation.GetBalances, - {}, - ); - t.assertTrue(balanceAfter["balances"].length == 1); - t.assertTrue( - balanceBefore["balances"][0]["available"] > - balanceAfter["balances"][0]["available"], - ); -} - -runPaymentDemoTest.excludeByDefault = true; -runPaymentDemoTest.suites = ["buildbot"]; diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index 38047a850..f845f4e99 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -69,7 +69,6 @@ import { runPaymentFaultTest } from "./test-payment-fault.js"; import { runPaymentForgettableTest } from "./test-payment-forgettable.js"; import { runPaymentIdempotencyTest } from "./test-payment-idempotency.js"; import { runPaymentMultipleTest } from "./test-payment-multiple.js"; -import { runPaymentDemoTest } from "./test-payment-on-demo.js"; import { runPaymentTransientTest } from "./test-payment-transient.js"; import { runPaymentZeroTest } from "./test-payment-zero.js"; import { runPaywallFlowTest } from "./test-paywall-flow.js"; @@ -160,7 +159,6 @@ const allTests: TestMainFunction[] = [ runMerchantRefundApiTest, runMerchantSpecPublicOrdersTest, runPaymentClaimTest, - runPaymentDemoTest, runPaymentFaultTest, runPaymentForgettableTest, runPaymentIdempotencyTest, |