commit 67f1f5cb2cc5191049215d2acd74f5b611a0e654
parent bb80e9552dc3f8cf202cbb94252a3106b7afec8a
Author: Florian Dold <florian@dold.me>
Date: Fri, 25 Jul 2025 17:22:56 +0200
harness: merchant login command
Diffstat:
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts
@@ -72,8 +72,10 @@ import {
topupReserveWithBank,
} from "@gnu-taler/taler-wallet-core/dbless";
import { deepStrictEqual } from "assert";
+import { AML_PROGRAM_FAIL_RECOVER } from "integrationtests/test-kyc-fail-recover-simple.js";
import { AML_PROGRAM_FROM_ATTRIBUTES_TO_CONTEXT } from "integrationtests/test-kyc-skip-expiration.js";
import { AML_PROGRAM_NEXT_MEASURE_FORM } from "integrationtests/test-kyc-two-forms.js";
+import { execSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
@@ -98,8 +100,6 @@ import {
import { AML_PROGRAM_TEST_KYC_NEW_MEASURES_PROG } from "./integrationtests/test-kyc-new-measures-prog.js";
import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
import { lintExchangeDeployment, lintExchangeUrl } from "./lint.js";
-import { execSync } from "node:child_process";
-import { AML_PROGRAM_FAIL_RECOVER } from "integrationtests/test-kyc-fail-recover-simple.js";
const logger = new Logger("taler-harness:index.ts");
@@ -1189,8 +1189,10 @@ deploymentCli
help: "Provision a merchant backend instance.",
})
.requiredArgument("merchantApiBaseUrl", clk.STRING)
- .requiredOption("managementToken", ["--management-token"], clk.STRING)
- .requiredOption("instancePassword", ["--instance-password"], clk.STRING)
+ .requiredOption("managementToken", ["--management-token"], clk.STRING, {})
+ .requiredOption("instancePassword", ["--instance-password"], clk.STRING, {
+ help: "New password to set for the provisioned instance.",
+ })
.requiredOption("name", ["--name"], clk.STRING)
.requiredOption("id", ["--id"], clk.STRING)
.requiredOption("payto", ["--payto"], clk.STRING)
@@ -1648,7 +1650,7 @@ const allAmlPrograms: TalerKycAml.AmlProgramDefinition[] = [
name: "fail-exec-child-error",
logic: async (_input, _config) => {
execSync("something-that-doesnt-exists make-this-fail");
- throw Error("unreachable")
+ throw Error("unreachable");
},
requiredAttributes: [],
requiredInputs: [],
@@ -1776,6 +1778,37 @@ export const merchantCli = talerHarnessCli.subcommand("merchant", "merchant", {
});
merchantCli
+ .subcommand("token", "token", {
+ help: "Obtain login token from merchant.",
+ })
+ .requiredArgument("merchantBaseUrl", clk.STRING)
+ .requiredArgument("instance", clk.STRING)
+ .requiredOption("password", ["--password"], clk.STRING)
+ .maybeOption("scope", ["--scope"], clk.STRING)
+ .maybeOption("duration", ["--duration"], clk.STRING)
+ .action(async (args) => {
+ const merchantApi = new TalerMerchantInstanceHttpClient(
+ args.token.merchantBaseUrl,
+ );
+ const instance = args.token.instance;
+ const password = args.token.password;
+ const scope = args.token.scope ?? "all";
+ const duration = args.token.duration
+ ? Duration.toTalerProtocolDuration(
+ Duration.fromPrettyString(args.token.duration),
+ )
+ : undefined;
+ const tokResp = await merchantApi.createAccessToken(instance, password, {
+ scope: scope as LoginTokenScope,
+ duration,
+ });
+ const tok = succeedOrThrow(tokResp);
+ logger.info(`refreshable: ${tok.refreshable}`);
+ logger.info(`scope: ${tok.scope}`);
+ console.log(tok.access_token);
+ });
+
+merchantCli
.subcommand("checkKyc", "check-kyc", {
help: "gets updated information about the kyc state",
})