From 324d9f871c356f48f64c170a793024139ae2694d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 6 Sep 2023 11:44:07 +0200 Subject: move merchant API client to taler-util --- packages/taler-harness/src/harness/harness.ts | 299 +-------------------- packages/taler-harness/src/harness/helpers.ts | 2 +- packages/taler-harness/src/index.ts | 7 +- .../test-age-restrictions-merchant.ts | 12 +- .../src/integrationtests/test-claim-loop.ts | 6 +- .../src/integrationtests/test-denom-unoffered.ts | 9 +- .../taler-harness/src/integrationtests/test-kyc.ts | 4 +- .../test-merchant-exchange-confusion.ts | 2 +- .../test-merchant-instances-delete.ts | 10 +- .../test-merchant-instances-urls.ts | 6 +- .../integrationtests/test-merchant-instances.ts | 4 +- .../integrationtests/test-merchant-longpolling.ts | 7 +- .../integrationtests/test-merchant-refund-api.ts | 26 +- .../test-merchant-spec-public-orders.ts | 2 +- .../src/integrationtests/test-pay-paid.ts | 19 +- .../src/integrationtests/test-payment-abort.ts | 21 +- .../src/integrationtests/test-payment-claim.ts | 8 +- .../src/integrationtests/test-payment-expired.ts | 15 +- .../src/integrationtests/test-payment-fault.ts | 29 +- .../integrationtests/test-payment-idempotency.ts | 4 +- .../src/integrationtests/test-payment-multiple.ts | 10 +- .../src/integrationtests/test-payment-share.ts | 3 +- .../src/integrationtests/test-payment-template.ts | 3 +- .../src/integrationtests/test-payment-transient.ts | 7 +- .../src/integrationtests/test-paywall-flow.ts | 9 +- .../src/integrationtests/test-refund-auto.ts | 8 +- .../src/integrationtests/test-refund-gone.ts | 13 +- .../integrationtests/test-refund-incremental.ts | 7 +- .../src/integrationtests/test-refund.ts | 3 +- .../test-timetravel-autorefresh.ts | 4 +- .../src/integrationtests/test-tipping.ts | 11 +- .../test-wallet-backup-doublespend.ts | 12 +- .../src/integrationtests/test-wallet-balance.ts | 8 +- 33 files changed, 138 insertions(+), 452 deletions(-) (limited to 'packages/taler-harness') diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index a16cef7ba..df3c9b215 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -57,6 +57,8 @@ import { WalletNotification, codecForAny, AccountAddDetails, + MerchantInstanceConfig, + PartialMerchantInstanceConfig, } from "@gnu-taler/taler-util"; import { createPlatformHttpLib, @@ -1339,23 +1341,12 @@ export interface MerchantConfig { overrideTestDir?: string; } -export interface PrivateOrderStatusQuery { - instance?: string; - orderId: string; - sessionId?: string; -} - export interface MerchantServiceInterface { makeInstanceBaseUrl(instanceName?: string): string; readonly port: number; readonly name: string; } -export interface DeleteTippingReserveArgs { - reservePub: string; - purge?: boolean; -} - /** * Default HTTP client handle for the integration test harness. */ @@ -1364,232 +1355,6 @@ export const harnessHttpLib = createPlatformHttpLib({ enableThrottling: false, }); -/** - * FIXME: Move this out of the harness. - */ -export class MerchantApiClient { - /** - * Base URL for the particular instance that this merchant API client - * is for. - */ - private baseUrl: string; - - readonly auth: MerchantAuthConfiguration; - - constructor(baseUrl: string, auth?: MerchantAuthConfiguration) { - this.baseUrl = baseUrl; - - this.auth = auth ?? { - method: "external", - }; - } - - httpClient = createPlatformHttpLib({ - allowHttp: true, - enableThrottling: false, - }); - - async changeAuth(auth: MerchantAuthConfiguration): Promise { - const url = new URL("private/auth", this.baseUrl); - const res = await this.httpClient.fetch(url.href, { - method: "POST", - body: auth, - headers: this.makeAuthHeader(), - }); - await expectSuccessResponseOrThrow(res); - } - - async deleteTippingReserve(req: DeleteTippingReserveArgs): Promise { - const url = new URL(`private/reserves/${req.reservePub}`, this.baseUrl); - if (req.purge) { - url.searchParams.set("purge", "YES"); - } - const resp = await this.httpClient.fetch(url.href, { - method: "DELETE", - headers: this.makeAuthHeader(), - }); - logger.info(`delete status: ${resp.status}`); - return; - } - - async createTippingReserve( - req: CreateMerchantTippingReserveRequest, - ): Promise { - const url = new URL("private/reserves", this.baseUrl); - const resp = await this.httpClient.fetch(url.href, { - method: "POST", - body: req, - headers: this.makeAuthHeader(), - }); - const respData = readSuccessResponseJsonOrThrow( - resp, - codecForMerchantReserveCreateConfirmation(), - ); - return respData; - } - - async getPrivateInstanceInfo(): Promise { - const url = new URL("private", this.baseUrl); - const resp = await this.httpClient.fetch(url.href, { - method: "GET", - headers: this.makeAuthHeader(), - }); - return await resp.json(); - } - - async getPrivateTipReserves(): Promise { - const url = new URL("private/reserves", this.baseUrl); - const resp = await this.httpClient.fetch(url.href, { - method: "GET", - headers: this.makeAuthHeader(), - }); - // FIXME: Validate! - return await resp.json(); - } - - async deleteInstance(instanceId: string) { - const url = new URL(`management/instances/${instanceId}`, this.baseUrl); - const resp = await this.httpClient.fetch(url.href, { - method: "DELETE", - headers: this.makeAuthHeader(), - }); - await expectSuccessResponseOrThrow(resp); - } - - async createInstance(req: MerchantInstanceConfig): Promise { - const url = new URL("management/instances", this.baseUrl); - await this.httpClient.fetch(url.href, { - method: "POST", - body: req, - headers: this.makeAuthHeader(), - }); - } - - async getInstances(): Promise { - const url = new URL("management/instances", this.baseUrl); - const resp = await this.httpClient.fetch(url.href, { - headers: this.makeAuthHeader(), - }); - return resp.json(); - } - - async getInstanceFullDetails(instanceId: string): Promise { - const url = new URL(`management/instances/${instanceId}`, this.baseUrl); - try { - const resp = await this.httpClient.fetch(url.href, { - headers: this.makeAuthHeader(), - }); - return resp.json(); - } catch (e) { - throw e; - } - } - - async createOrder( - req: MerchantPostOrderRequest, - ): Promise { - let url = new URL("private/orders", this.baseUrl); - const resp = await harnessHttpLib.fetch(url.href, { - method: "POST", - body: req, - headers: this.makeAuthHeader(), - }); - return readSuccessResponseJsonOrThrow( - resp, - codecForMerchantPostOrderResponse(), - ); - } - - async queryPrivateOrderStatus( - query: PrivateOrderStatusQuery, - ): Promise { - const reqUrl = new URL(`private/orders/${query.orderId}`, this.baseUrl); - if (query.sessionId) { - reqUrl.searchParams.set("session_id", query.sessionId); - } - const resp = await harnessHttpLib.fetch(reqUrl.href, { - headers: this.makeAuthHeader(), - }); - return readSuccessResponseJsonOrThrow( - resp, - codecForMerchantOrderPrivateStatusResponse(), - ); - } - - async giveTip(req: RewardCreateRequest): Promise { - const reqUrl = new URL(`private/tips`, this.baseUrl); - const resp = await harnessHttpLib.fetch(reqUrl.href, { - method: "POST", - body: req, - }); - // FIXME: validate - return resp.json(); - } - - async queryTippingReserves(): Promise { - const reqUrl = new URL(`private/reserves`, this.baseUrl); - const resp = await harnessHttpLib.fetch(reqUrl.href, { - headers: this.makeAuthHeader(), - }); - // FIXME: validate - return resp.json(); - } - - async giveRefund(r: { - instance: string; - orderId: string; - amount: string; - justification: string; - }): Promise<{ talerRefundUri: string }> { - const reqUrl = new URL(`private/orders/${r.orderId}/refund`, this.baseUrl); - const resp = await harnessHttpLib.fetch(reqUrl.href, { - method: "POST", - body: { - refund: r.amount, - reason: r.justification, - }, - }); - const respBody = await resp.json(); - return { - talerRefundUri: respBody.taler_refund_uri, - }; - } - - async createTemplate(req: MerchantTemplateAddDetails) { - let url = new URL("private/templates", this.baseUrl); - const resp = await harnessHttpLib.fetch(url.href, { - method: "POST", - body: req, - headers: this.makeAuthHeader(), - }); - if (resp.status !== 204) { - throw Error("failed to create template"); - } - } - - private makeAuthHeader(): Record { - switch (this.auth.method) { - case "external": - return {}; - case "token": - return { - Authorization: `Bearer ${this.auth.token}`, - }; - } - } -} - -export interface CreateMerchantTippingReserveRequest { - // Amount that the merchant promises to put into the reserve - initial_balance: AmountString; - - // Exchange the merchant intends to use for tipping - exchange_url: string; - - // Desired wire method, for example "iban" or "x-taler-bank" - wire_method: string; -} - export class MerchantService implements MerchantServiceInterface { static fromExistingConfig( gc: GlobalTestState, @@ -1814,66 +1579,6 @@ export class MerchantService implements MerchantServiceInterface { } } -export interface MerchantAuthConfiguration { - method: "external" | "token"; - token?: string; -} - -// FIXME: Why do we need this? Describe / fix! -export interface PartialMerchantInstanceConfig { - auth?: MerchantAuthConfiguration; - id: string; - name: string; - paytoUris: string[]; - address?: unknown; - jurisdiction?: unknown; - defaultWireTransferDelay?: TalerProtocolDuration; - 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; - address: unknown; - jurisdiction: unknown; - use_stefan: boolean; - default_wire_transfer_delay: TalerProtocolDuration; - default_pay_delay: TalerProtocolDuration; -} - type TestStatus = "pass" | "fail" | "skip"; export interface TestRunResult { diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index 485e1baba..7b2f7d8f1 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -33,6 +33,7 @@ import { WalletNotification, TransactionMajorState, Logger, + MerchantApiClient, } from "@gnu-taler/taler-util"; import { BankAccessApi, @@ -53,7 +54,6 @@ import { FakebankService, getPayto, GlobalTestState, - MerchantApiClient, MerchantService, MerchantServiceInterface, setupDb, diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts index 3b50acf75..ed2e545f7 100644 --- a/packages/taler-harness/src/index.ts +++ b/packages/taler-harness/src/index.ts @@ -24,6 +24,7 @@ import { decodeCrock, j2s, Logger, + MerchantApiClient, rsaBlind, setGlobalLogLevelFromString, } from "@gnu-taler/taler-util"; @@ -45,11 +46,7 @@ import { runBench2 } from "./bench2.js"; import { runBench3 } from "./bench3.js"; import { runEnvFull } from "./env-full.js"; import { runEnv1 } from "./env1.js"; -import { - GlobalTestState, - MerchantApiClient, - runTestWithState, -} from "./harness/harness.js"; +import { GlobalTestState, runTestWithState } from "./harness/harness.js"; import { getTestInfo, runTests } from "./integrationtests/testrunner.js"; import { lintExchangeDeployment } from "./lint.js"; diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts index 45a035cc4..4e096e0ea 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2023 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 @@ -23,17 +23,14 @@ import { WireGatewayApiClient, } from "@gnu-taler/taler-wallet-core"; import { defaultCoinConfig } from "../harness/denomStructures.js"; -import { - getWireMethodForTest, - GlobalTestState, - MerchantApiClient, -} from "../harness/harness.js"; +import { getWireMethodForTest, GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, createWalletDaemonWithClient, makeTestPaymentV2, withdrawViaBankV2, } from "../harness/helpers.js"; +import { MerchantApiClient } from "@gnu-taler/taler-util"; /** * Run test for basic, bank-integrated withdrawal and payment. @@ -57,9 +54,6 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { const merchantClient = new MerchantApiClient( merchant.makeInstanceBaseUrl("default"), - { - method: "external", - }, ); const { walletClient: walletClientTwo } = await createWalletDaemonWithClient( diff --git a/packages/taler-harness/src/integrationtests/test-claim-loop.ts b/packages/taler-harness/src/integrationtests/test-claim-loop.ts index 52841dbab..652df72ec 100644 --- a/packages/taler-harness/src/integrationtests/test-claim-loop.ts +++ b/packages/taler-harness/src/integrationtests/test-claim-loop.ts @@ -19,14 +19,12 @@ */ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { URL } from "url"; -import { - GlobalTestState, - MerchantApiClient, -} from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, } from "../harness/helpers.js"; +import { MerchantApiClient } from "@gnu-taler/taler-util"; /** * Run test for the merchant's order lifecycle. diff --git a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts index a9282f394..afd0c901b 100644 --- a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts +++ b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts @@ -17,12 +17,13 @@ /** * Imports. */ -import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util"; -import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { - GlobalTestState, MerchantApiClient, -} from "../harness/harness.js"; + PreparePayResultType, + TalerErrorCode, +} from "@gnu-taler/taler-util"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index 34ad46e03..22c8ce03c 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -26,11 +26,13 @@ import { TransactionMinorState, TransactionType, } from "@gnu-taler/taler-util"; +import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; import { BankAccessApi, BankApi, WalletApiOperation, } from "@gnu-taler/taler-wallet-core"; +import * as http from "node:http"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { BankService, @@ -43,8 +45,6 @@ import { WalletService, } from "../harness/harness.js"; import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js"; -import * as http from "node:http"; -import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; const logger = new Logger("test-kyc.ts"); diff --git a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts index 3c71e0f7e..e8f5a435a 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts @@ -20,6 +20,7 @@ import { codecForMerchantOrderStatusUnpaid, ConfirmPayResultType, + MerchantApiClient, PreparePayResultType, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -35,7 +36,6 @@ import { getPayto, GlobalTestState, harnessHttpLib, - MerchantApiClient, MerchantService, setupDb, } from "../harness/harness.js"; diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts index 1c99dda76..ff567d33d 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts @@ -17,17 +17,15 @@ /** * Imports. */ -import { TalerError, URL } from "@gnu-taler/taler-util"; +import { MerchantApiClient, TalerError, URL } from "@gnu-taler/taler-util"; import { ExchangeService, GlobalTestState, - MerchantApiClient, MerchantService, - setupDb, getPayto, harnessHttpLib, + setupDb, } from "../harness/harness.js"; -import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; /** * Test instance deletion and authentication for it @@ -69,7 +67,9 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) { // Instances should initially be empty { - const r = await harnessHttpLib.fetch(new URL("management/instances", baseUrl).href); + const r = await harnessHttpLib.fetch( + new URL("management/instances", baseUrl).href, + ); const data = await r.json(); t.assertDeepEqual(data.instances, []); } 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 18a09c76b..071288b0f 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts @@ -17,17 +17,15 @@ /** * Imports. */ -import { Duration } from "@gnu-taler/taler-util"; +import { Duration, MerchantApiClient } from "@gnu-taler/taler-util"; import { ExchangeService, GlobalTestState, - MerchantApiClient, MerchantService, - setupDb, getPayto, harnessHttpLib, + setupDb, } from "../harness/harness.js"; -import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; /** * Do basic checks on instance management and authentication. diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts index 54205e9f2..fd7a8ca3a 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts @@ -17,17 +17,15 @@ /** * Imports. */ -import { URL } from "@gnu-taler/taler-util"; +import { MerchantApiClient, URL } from "@gnu-taler/taler-util"; import { ExchangeService, GlobalTestState, - MerchantApiClient, MerchantService, setupDb, getPayto, harnessHttpLib, } from "../harness/harness.js"; -import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; /** * Do basic checks on instance management and authentication. diff --git a/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts b/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts index d7ffa28d5..bd63a8445 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts @@ -19,16 +19,13 @@ */ import { ConfirmPayResultType, + MerchantApiClient, PreparePayResultType, URL, codecForMerchantOrderStatusUnpaid, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { - GlobalTestState, - MerchantApiClient, - harnessHttpLib, -} from "../harness/harness.js"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts b/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts index ebca4f769..369f261dd 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts @@ -18,27 +18,27 @@ * Imports. */ import { + Duration, + MerchantApiClient, + PreparePayResultType, + URL, + durationFromSpec, +} from "@gnu-taler/taler-util"; +import { + BankServiceHandle, + WalletApiOperation, +} from "@gnu-taler/taler-wallet-core"; +import { + ExchangeServiceInterface, GlobalTestState, MerchantServiceInterface, - ExchangeServiceInterface, - harnessHttpLib, WalletClient, - MerchantApiClient, + harnessHttpLib, } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, } from "../harness/helpers.js"; -import { - URL, - durationFromSpec, - PreparePayResultType, - Duration, -} from "@gnu-taler/taler-util"; -import { - WalletApiOperation, - BankServiceHandle, -} from "@gnu-taler/taler-wallet-core"; async function testRefundApiWithFulfillmentUrl( t: GlobalTestState, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts index 599a3fc16..afae8a899 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts @@ -19,6 +19,7 @@ */ import { ConfirmPayResultType, + MerchantApiClient, PreparePayResultType, URL, encodeCrock, @@ -29,7 +30,6 @@ import { BankService, ExchangeService, GlobalTestState, - MerchantApiClient, MerchantService, harnessHttpLib, } from "../harness/harness.js"; diff --git a/packages/taler-harness/src/integrationtests/test-pay-paid.ts b/packages/taler-harness/src/integrationtests/test-pay-paid.ts index 4fe13b3ae..3d93f6e29 100644 --- a/packages/taler-harness/src/integrationtests/test-pay-paid.ts +++ b/packages/taler-harness/src/integrationtests/test-pay-paid.ts @@ -18,22 +18,19 @@ * Imports. */ import { - GlobalTestState, + ConfirmPayResultType, MerchantApiClient, - harnessHttpLib, -} from "../harness/harness.js"; -import { - createFaultInjectedMerchantTestkudosEnvironment, - withdrawViaBankV2, -} from "../harness/helpers.js"; -import { PreparePayResultType, - codecForMerchantOrderStatusUnpaid, - ConfirmPayResultType, URL, + codecForMerchantOrderStatusUnpaid, } from "@gnu-taler/taler-util"; -import { FaultInjectionRequestContext } from "../harness/faultInjection.js"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { FaultInjectionRequestContext } from "../harness/faultInjection.js"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; +import { + createFaultInjectedMerchantTestkudosEnvironment, + withdrawViaBankV2, +} from "../harness/helpers.js"; /** * Run test for the wallets repurchase detection mechanism diff --git a/packages/taler-harness/src/integrationtests/test-payment-abort.ts b/packages/taler-harness/src/integrationtests/test-payment-abort.ts index 22e087161..3164bbaf3 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-abort.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-abort.ts @@ -18,25 +18,22 @@ * Imports. */ import { - GlobalTestState, - MerchantApiClient, - harnessHttpLib, -} from "../harness/harness.js"; -import { - createFaultInjectedMerchantTestkudosEnvironment, - withdrawViaBankV2, -} from "../harness/helpers.js"; -import { FaultInjectionRequestContext } from "../harness/faultInjection.js"; -import { - codecForMerchantOrderStatusUnpaid, ConfirmPayResultType, - j2s, + MerchantApiClient, PreparePayResultType, TalerErrorCode, TalerErrorDetail, URL, + codecForMerchantOrderStatusUnpaid, + j2s, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { FaultInjectionRequestContext } from "../harness/faultInjection.js"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; +import { + createFaultInjectedMerchantTestkudosEnvironment, + withdrawViaBankV2, +} from "../harness/helpers.js"; export async function runPaymentAbortTest(t: GlobalTestState) { // Set up test environment diff --git a/packages/taler-harness/src/integrationtests/test-payment-claim.ts b/packages/taler-harness/src/integrationtests/test-payment-claim.ts index df86b3cbf..b5ed89ec3 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-claim.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-claim.ts @@ -17,9 +17,13 @@ /** * Imports. */ -import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util"; +import { + MerchantApiClient, + PreparePayResultType, + TalerErrorCode, +} from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient, WalletCli } from "../harness/harness.js"; +import { GlobalTestState, WalletCli } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-payment-expired.ts b/packages/taler-harness/src/integrationtests/test-payment-expired.ts index 4817efba5..176fc74f7 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-expired.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-expired.ts @@ -17,21 +17,22 @@ /** * Imports. */ -import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; -import { - applyTimeTravelV2, - createSimpleTestkudosEnvironmentV2, - withdrawViaBankV2, -} from "../harness/helpers.js"; import { AbsoluteTime, ConfirmPayResultType, Duration, + MerchantApiClient, MerchantContractTerms, PreparePayResultType, j2s, } from "@gnu-taler/taler-util"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; +import { + applyTimeTravelV2, + createSimpleTestkudosEnvironmentV2, + withdrawViaBankV2, +} from "../harness/helpers.js"; /** * Run a test for the following scenario: diff --git a/packages/taler-harness/src/integrationtests/test-payment-fault.ts b/packages/taler-harness/src/integrationtests/test-payment-fault.ts index 5d0fe6e13..70fa587e7 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-fault.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-fault.ts @@ -21,28 +21,27 @@ /** * Imports. */ +import { CoreApiResponse, MerchantApiClient } from "@gnu-taler/taler-util"; import { - GlobalTestState, - MerchantService, - ExchangeService, - setupDb, - BankService, - WalletCli, - getPayto, - MerchantApiClient, -} from "../harness/harness.js"; + BankAccessApi, + BankApi, + WalletApiOperation, +} from "@gnu-taler/taler-wallet-core"; +import { defaultCoinConfig } from "../harness/denomStructures.js"; import { FaultInjectedExchangeService, FaultInjectionRequestContext, FaultInjectionResponseContext, } from "../harness/faultInjection.js"; -import { CoreApiResponse } from "@gnu-taler/taler-util"; -import { defaultCoinConfig } from "../harness/denomStructures.js"; import { - WalletApiOperation, - BankApi, - BankAccessApi, -} from "@gnu-taler/taler-wallet-core"; + BankService, + ExchangeService, + GlobalTestState, + MerchantService, + WalletCli, + getPayto, + setupDb, +} from "../harness/harness.js"; /** * Run test for basic, bank-integrated withdrawal. diff --git a/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts b/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts index e06ef1322..65fd3a562 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-idempotency.ts @@ -17,9 +17,9 @@ /** * Imports. */ -import { PreparePayResultType } from "@gnu-taler/taler-util"; +import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts index b22bba43f..23972ed63 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts @@ -17,17 +17,17 @@ /** * Imports. */ +import { MerchantApiClient } from "@gnu-taler/taler-util"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { coin_ct10, coin_u1 } from "../harness/denomStructures.js"; import { - GlobalTestState, - setupDb, BankService, ExchangeService, + GlobalTestState, MerchantService, getPayto, - MerchantApiClient, + setupDb, } from "../harness/harness.js"; -import { coin_ct10, coin_u1 } from "../harness/denomStructures.js"; -import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { createWalletDaemonWithClient, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-payment-share.ts b/packages/taler-harness/src/integrationtests/test-payment-share.ts index c12140d06..c4a82c917 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-share.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-share.ts @@ -19,10 +19,11 @@ */ import { ConfirmPayResultType, + MerchantApiClient, PreparePayResultType, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, createWalletDaemonWithClient, diff --git a/packages/taler-harness/src/integrationtests/test-payment-template.ts b/packages/taler-harness/src/integrationtests/test-payment-template.ts index 2058991d0..e77236a9a 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-template.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-template.ts @@ -20,10 +20,11 @@ import { ConfirmPayResultType, Duration, + MerchantApiClient, PreparePayResultType, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-payment-transient.ts b/packages/taler-harness/src/integrationtests/test-payment-transient.ts index 3bc59aa8f..46e57735f 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-transient.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-transient.ts @@ -19,6 +19,7 @@ */ import { ConfirmPayResultType, + MerchantApiClient, PreparePayResultType, TalerErrorCode, TalerErrorDetail, @@ -27,11 +28,7 @@ import { } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { FaultInjectionResponseContext } from "../harness/faultInjection.js"; -import { - GlobalTestState, - MerchantApiClient, - harnessHttpLib, -} from "../harness/harness.js"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; import { createFaultInjectedMerchantTestkudosEnvironment, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts index fd13f37d6..247ec9cad 100644 --- a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts +++ b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts @@ -18,17 +18,14 @@ * Imports. */ import { - GlobalTestState, + ConfirmPayResultType, MerchantApiClient, - harnessHttpLib, -} from "../harness/harness.js"; -import { PreparePayResultType, - codecForMerchantOrderStatusUnpaid, - ConfirmPayResultType, URL, + codecForMerchantOrderStatusUnpaid, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-refund-auto.ts b/packages/taler-harness/src/integrationtests/test-refund-auto.ts index 9e1f31af2..e8bfecefa 100644 --- a/packages/taler-harness/src/integrationtests/test-refund-auto.ts +++ b/packages/taler-harness/src/integrationtests/test-refund-auto.ts @@ -17,9 +17,13 @@ /** * Imports. */ -import { Duration, durationFromSpec } from "@gnu-taler/taler-util"; +import { + Duration, + MerchantApiClient, + durationFromSpec, +} from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-refund-gone.ts b/packages/taler-harness/src/integrationtests/test-refund-gone.ts index 954262826..9ba078a6d 100644 --- a/packages/taler-harness/src/integrationtests/test-refund-gone.ts +++ b/packages/taler-harness/src/integrationtests/test-refund-gone.ts @@ -17,18 +17,19 @@ /** * Imports. */ -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; -import { - applyTimeTravelV2, - createSimpleTestkudosEnvironmentV2, - withdrawViaBankV2, -} from "../harness/helpers.js"; import { AbsoluteTime, Duration, + MerchantApiClient, durationFromSpec, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; +import { + applyTimeTravelV2, + createSimpleTestkudosEnvironmentV2, + withdrawViaBankV2, +} from "../harness/helpers.js"; /** * Run test for basic, bank-integrated withdrawal. diff --git a/packages/taler-harness/src/integrationtests/test-refund-incremental.ts b/packages/taler-harness/src/integrationtests/test-refund-incremental.ts index 7c895ad2b..e7e041ce6 100644 --- a/packages/taler-harness/src/integrationtests/test-refund-incremental.ts +++ b/packages/taler-harness/src/integrationtests/test-refund-incremental.ts @@ -20,15 +20,12 @@ import { Amounts, Duration, + MerchantApiClient, TransactionType, durationFromSpec, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { - GlobalTestState, - MerchantApiClient, - delayMs, -} from "../harness/harness.js"; +import { GlobalTestState, delayMs } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-refund.ts b/packages/taler-harness/src/integrationtests/test-refund.ts index 3dc2748fe..aeeb91f38 100644 --- a/packages/taler-harness/src/integrationtests/test-refund.ts +++ b/packages/taler-harness/src/integrationtests/test-refund.ts @@ -20,11 +20,12 @@ import { Duration, durationFromSpec, + MerchantApiClient, NotificationType, TransactionMajorState, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts index 420e4fddc..b94f7757c 100644 --- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts +++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts @@ -21,6 +21,7 @@ import { ConfirmPayResultType, Duration, durationFromSpec, + MerchantApiClient, PreparePayResultType, } from "@gnu-taler/taler-util"; import { @@ -31,11 +32,10 @@ import { makeNoFeeCoinConfig } from "../harness/denomStructures.js"; import { BankService, ExchangeService, + getPayto, GlobalTestState, MerchantService, setupDb, - getPayto, - MerchantApiClient, } from "../harness/harness.js"; import { applyTimeTravelV2, diff --git a/packages/taler-harness/src/integrationtests/test-tipping.ts b/packages/taler-harness/src/integrationtests/test-tipping.ts index 93855f546..f4a7c020e 100644 --- a/packages/taler-harness/src/integrationtests/test-tipping.ts +++ b/packages/taler-harness/src/integrationtests/test-tipping.ts @@ -17,18 +17,17 @@ /** * Imports. */ +import { + MerchantApiClient, + TransactionMajorState, +} from "@gnu-taler/taler-util"; import { BankAccessApiClient, WalletApiOperation, WireGatewayApiClient, } from "@gnu-taler/taler-wallet-core"; -import { - GlobalTestState, - MerchantApiClient, - getWireMethodForTest, -} from "../harness/harness.js"; +import { GlobalTestState, getWireMethodForTest } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js"; -import { TransactionMajorState } from "@gnu-taler/taler-util"; /** * Run test for basic, bank-integrated withdrawal. diff --git a/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts b/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts index 62ae89137..c761c4fb0 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts @@ -17,9 +17,9 @@ /** * Imports. */ -import { PreparePayResultType } from "@gnu-taler/taler-util"; +import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, createWalletDaemonWithClient, @@ -126,11 +126,9 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { }, }); - let orderStatus = await merchantClient.queryPrivateOrderStatus( - { - orderId: orderResp.order_id, - }, - ); + let orderStatus = await merchantClient.queryPrivateOrderStatus({ + orderId: orderResp.order_id, + }); t.assertTrue(orderStatus.order_status === "unpaid"); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-balance.ts b/packages/taler-harness/src/integrationtests/test-wallet-balance.ts index 9711aff26..243c90e2e 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-balance.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-balance.ts @@ -17,9 +17,13 @@ /** * Imports. */ -import { Amounts, PreparePayResultType } from "@gnu-taler/taler-util"; +import { + Amounts, + MerchantApiClient, + PreparePayResultType, +} from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2, -- cgit v1.2.3