harness: adjust to merchant API breaking changes, remove test that doesn't belong

This commit is contained in:
Florian Dold 2023-04-23 23:08:37 +02:00
parent eff3920bd5
commit b81ea1b4b7
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
4 changed files with 46 additions and 120 deletions

View File

@ -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;

View File

@ -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",

View File

@ -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"];

View File

@ -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,