diff options
Diffstat (limited to 'packages/taler-harness/src/index.ts')
-rw-r--r-- | packages/taler-harness/src/index.ts | 130 |
1 files changed, 82 insertions, 48 deletions
diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts index 0f282e123..99b5502d8 100644 --- a/packages/taler-harness/src/index.ts +++ b/packages/taler-harness/src/index.ts @@ -30,11 +30,11 @@ import { TalerAuthenticationHttpClient, TalerBankConversionHttpClient, TalerCoreBankHttpClient, - TalerErrorCode, TalerMerchantInstanceHttpClient, TalerMerchantManagementHttpClient, TransactionsResponse, - createAccessToken, + createRFC8959AccessTokenEncoded, + createRFC8959AccessTokenPlain, decodeCrock, encodeCrock, generateIban, @@ -42,7 +42,6 @@ import { randomBytes, rsaBlind, setGlobalLogLevelFromString, - setPrintHttpRequestAsCurl, stringifyPayTemplateUri, } from "@gnu-taler/taler-util"; import { clk } from "@gnu-taler/taler-util/clk"; @@ -80,7 +79,6 @@ import { } from "./harness/helpers.js"; import { getTestInfo, runTests } from "./integrationtests/testrunner.js"; import { lintExchangeDeployment } from "./lint.js"; -import { randomUUID } from "crypto"; const logger = new Logger("taler-harness:index.ts"); @@ -356,25 +354,46 @@ advancedCli ); }); -const configCli = testingCli.subcommand("configArgs", "config", { - help: "Subcommands for handling the Taler configuration.", -}); +const configCli = testingCli + .subcommand("configArgs", "config", { + help: "Subcommands for handling the Taler configuration.", + }) + .maybeOption("configEntryFile", ["-c", "--config"], clk.STRING, { + help: "Configuration file to use.", + }) + .maybeOption("project", ["--project"], clk.STRING, { + help: `Selection of the project to inspect/change the config (default: taler).`, + }); -configCli.subcommand("show", "show").action(async (args) => { - const config = Configuration.load(); - const cfgStr = config.stringify({ - diagnostics: true, +configCli + .subcommand("show", "show", { + help: "Show the current configuration.", + }) + .action(async (args) => { + const config = Configuration.load( + args.configArgs.configEntryFile, + args.configArgs.project, + ); + const cfgStr = config.stringify({ + diagnostics: true, + }); + console.log(cfgStr); }); - console.log(cfgStr); -}); configCli - .subcommand("get", "get") + .subcommand("get", "get", { + help: "Get a configuration option.", + }) .requiredArgument("section", clk.STRING) .requiredArgument("option", clk.STRING) - .flag("file", ["-f"]) + .flag("file", ["-f"], { + help: "Treat the value as a filename, expanding placeholders.", + }) .action(async (args) => { - const config = Configuration.load(); + const config = Configuration.load( + args.configArgs.configEntryFile, + args.configArgs.project, + ); let res; if (args.get.file) { res = config.getPath(args.get.section, args.get.option); @@ -389,6 +408,35 @@ configCli } }); +configCli + .subcommand("set", "set", { + help: "Set a configuration option.", + }) + .requiredArgument("section", clk.STRING) + .requiredArgument("option", clk.STRING) + .requiredArgument("value", clk.STRING) + .flag("dry", ["--dry"], { + help: "Do not write the changed config to disk, only write it to stdout.", + }) + .action(async (args) => { + const config = Configuration.load( + args.configArgs.configEntryFile, + args.configArgs.project, + ); + config.setString(args.set.section, args.set.option, args.set.value); + if (args.set.dry) { + console.log( + config.stringify({ + excludeDefaults: true, + }), + ); + } else { + config.write({ + excludeDefaults: true, + }); + } + }); + const deploymentCli = testingCli.subcommand("deploymentArgs", "deployment", { help: "Subcommands for handling GNU Taler deployments.", }); @@ -643,12 +691,12 @@ deploymentCli help: "if everything worked ok, change the password of the accounts at the end", }) .action(async (args) => { - const managementToken = createAccessToken( + const managementToken = createRFC8959AccessTokenPlain( args.provisionBankMerchant.merchantToken, ); const bankAdminPassword = args.provisionBankMerchant.bankPassword; const bankAdminTokenArg = args.provisionBankMerchant.bankToken - ? createAccessToken(args.provisionBankMerchant.bankToken) + ? createRFC8959AccessTokenPlain(args.provisionBankMerchant.bankToken) : undefined; const id = args.provisionBankMerchant.id; const name = args.provisionBankMerchant.name; @@ -765,7 +813,7 @@ deploymentCli address: {}, auth: { method: "token", - token: createAccessToken(password), + token: createRFC8959AccessTokenPlain(password), }, default_pay_delay: Duration.toTalerProtocolDuration( Duration.fromSpec({ hours: 1 }), @@ -797,7 +845,7 @@ deploymentCli */ { const resp = await merchantInstance.addBankAccount( - createAccessToken(password), + createRFC8959AccessTokenEncoded(password), { payto_uri: accountPayto, credit_facade_url: bank.getRevenueAPI(id).href, @@ -840,7 +888,7 @@ deploymentCli { const resp = await merchantInstance.addTemplate( - createAccessToken(password), + createRFC8959AccessTokenEncoded(password), { template_id: "default", template_description: "First template", @@ -852,6 +900,9 @@ deploymentCli currency, summary: "Pay me!", }, + editable_defaults: { + amount: currency, + }, }, ); if (resp.type === "fail") { @@ -867,9 +918,6 @@ deploymentCli templateURI = stringifyPayTemplateUri({ merchantBaseUrl: instanceURL, templateId: "default", - templateParams: { - amount: currency, - }, }); } @@ -920,10 +968,10 @@ deploymentCli { const resp = await merchantInstance.updateCurrentInstanceAuthentication( - createAccessToken(prevPassword), + createRFC8959AccessTokenEncoded(prevPassword), { method: "token", - token: createAccessToken(randomPassword), + token: createRFC8959AccessTokenPlain(randomPassword), }, ); if (resp.type === "fail") { @@ -937,7 +985,7 @@ deploymentCli { const resp = await merchantInstance.updateBankAccount( - createAccessToken(randomPassword), + createRFC8959AccessTokenEncoded(randomPassword), wireAccount, { credit_facade_url: bank.getRevenueAPI(id).href, @@ -995,10 +1043,13 @@ deploymentCli const httpLib = createPlatformHttpLib({}); const baseUrl = args.provisionMerchantInstance.merchantApiBaseUrl; const api = new TalerMerchantManagementHttpClient(baseUrl, httpLib); - const managementToken = createAccessToken( + const managementToken = createRFC8959AccessTokenEncoded( args.provisionMerchantInstance.managementToken, ); - const instanceToken = createAccessToken( + const instanceTokenEnc = createRFC8959AccessTokenPlain( + args.provisionMerchantInstance.instanceToken, + ); + const instanceTokenPlain = createRFC8959AccessTokenPlain( args.provisionMerchantInstance.instanceToken, ); const instanceId = args.provisionMerchantInstance.id; @@ -1012,7 +1063,7 @@ deploymentCli address: {}, auth: { method: "token", - token: instanceToken, + token: instanceTokenPlain, }, default_pay_delay: Duration.toTalerProtocolDuration( Duration.fromSpec({ hours: 1 }), @@ -1035,7 +1086,7 @@ deploymentCli process.exit(2); } - const createAccountResp = await api.addBankAccount(instanceToken, { + const createAccountResp = await api.addBankAccount(instanceTokenEnc, { payto_uri: accountPayto, credit_facade_url: bankURL, credit_facade_credentials: @@ -1147,23 +1198,6 @@ deploymentCli console.log(out); }); -const deploymentConfigCli = deploymentCli.subcommand("configArgs", "config", { - help: "Subcommands the Taler configuration.", -}); - -deploymentConfigCli - .subcommand("show", "show") - .flag("diagnostics", ["-d", "--diagnostics"]) - .maybeArgument("cfgfile", clk.STRING, {}) - .action(async (args) => { - const cfg = Configuration.load(args.show.cfgfile); - console.log( - cfg.stringify({ - diagnostics: args.show.diagnostics, - }), - ); - }); - testingCli.subcommand("logtest", "logtest").action(async (args) => { logger.trace("This is a trace message."); logger.info("This is an info message."); |