commit d7d5a1e7885e6554b90623ee6fbe1b8bc34ff476
parent c185141f244125ae556cdd22fa0d71e49c43da05
Author: Florian Dold <dold@taler.net>
Date: Sat, 22 Aug 2026 21:48:59 +0200
taler-harness: use root endpoints for admin instance
Issue: https://bugs.taler.net/n/9771
Diffstat:
2 files changed, 95 insertions(+), 9 deletions(-)
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
@@ -2743,19 +2743,13 @@ export class MerchantService implements MerchantServiceInterface {
MERCHANT_DEFAULT_LOGIN_SCOPE,
);
- const accountCreateUrl = `http://localhost:${this.merchantConfig.httpPort}/instances/${instanceConfig.id}/private/accounts`;
for (const paytoUri of instanceConfig.paytoUris) {
const accountReq: TalerMerchantApi.AccountAddDetails = {
payto_uri: paytoUri as PaytoString,
};
- const acctResp = await harnessHttpLib.fetch(accountCreateUrl, {
- method: "POST",
- body: accountReq,
- headers: {
- Authorization: `Bearer ${access_token}`,
- },
- });
- await expectSuccessResponseOrThrow(acctResp);
+ succeedOrThrow(
+ await merchantApi.addBankAccount(access_token, accountReq),
+ );
}
return { accessToken: access_token };
}
diff --git a/packages/taler-harness/src/harness/merchant-service.test.ts b/packages/taler-harness/src/harness/merchant-service.test.ts
@@ -0,0 +1,92 @@
+/*
+ This file is part of GNU Taler
+ (C) 2026 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/>
+ */
+
+import assert from "node:assert";
+import { createServer } from "node:http";
+import { test } from "node:test";
+import {
+ MERCHANT_DEFAULT_AUTH,
+ MerchantService,
+ type GlobalTestState,
+} from "./harness.js";
+
+test("admin instance setup uses root merchant endpoints", async (t) => {
+ const requests: string[] = [];
+ const server = createServer((req, res) => {
+ const request = `${req.method} ${req.url}`;
+ requests.push(request);
+ res.setHeader("Content-Type", "application/json");
+
+ switch (request) {
+ case "POST /management/instances":
+ res.statusCode = 204;
+ res.end();
+ return;
+ case "POST /private/token":
+ res.end(
+ JSON.stringify({
+ access_token: "secret-token:test",
+ scope: "all:refreshable",
+ expiration: { t_s: "never" },
+ refreshable: true,
+ }),
+ );
+ return;
+ case "POST /private/accounts":
+ res.end(
+ JSON.stringify({ h_wire: "test-wire-hash", salt: "test-salt" }),
+ );
+ return;
+ default:
+ res.statusCode = 404;
+ res.end(JSON.stringify({ code: 2000 }));
+ }
+ });
+
+ await new Promise<void>((resolve) => server.listen(0, resolve));
+ t.after(
+ () =>
+ new Promise<void>((resolve, reject) => {
+ server.close((error) => (error ? reject(error) : resolve()));
+ }),
+ );
+
+ const address = server.address();
+ assert(address && typeof address !== "string");
+ const merchant = new MerchantService(
+ undefined as unknown as GlobalTestState,
+ {
+ name: "mock-merchant",
+ httpPort: address.port,
+ database: "unused",
+ },
+ "unused.conf",
+ );
+ merchant.procHttpd = {} as never;
+
+ await merchant.addInstanceWithWireAccount({
+ id: "admin",
+ name: "Admin Instance",
+ paytoUris: ["payto://iban/DE02120300000000202051?receiver-name=Merchant"],
+ auth: MERCHANT_DEFAULT_AUTH,
+ });
+
+ assert.deepEqual(requests, [
+ "POST /management/instances",
+ "POST /private/token",
+ "POST /private/accounts",
+ ]);
+});