gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: harness: helper to provision


From: gnunet
Subject: [taler-wallet-core] branch master updated: harness: helper to provision corebank account
Date: Mon, 09 Oct 2023 23:16:17 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new a45f45b61 harness: helper to provision corebank account
a45f45b61 is described below

commit a45f45b61bf0e70c04695f5de0c9b799fa96d2d6
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Oct 9 23:16:22 2023 +0200

    harness: helper to provision corebank account
---
 packages/taler-harness/src/index.ts | 44 +++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/packages/taler-harness/src/index.ts 
b/packages/taler-harness/src/index.ts
index 8ed67b162..b8e0cfca1 100644
--- a/packages/taler-harness/src/index.ts
+++ b/packages/taler-harness/src/index.ts
@@ -28,6 +28,8 @@ import {
   MerchantApiClient,
   rsaBlind,
   setGlobalLogLevelFromString,
+  RegisterAccountRequest,
+  HttpStatusCode,
 } from "@gnu-taler/taler-util";
 import { clk } from "@gnu-taler/taler-util/clk";
 import {
@@ -519,6 +521,48 @@ deploymentCli
     }
   });
 
+deploymentCli
+  .subcommand("provisionBankAccount", "provision-bank-account", {
+    help: "Provision a corebank account.",
+  })
+  .requiredArgument("corebankApiBaseUrl", clk.STRING)
+  .flag("exchange", ["--exchange"])
+  .flag("public", ["--public"])
+  .requiredOption("login", ["--login"], clk.STRING)
+  .requiredOption("name", ["--name"], clk.STRING)
+  .requiredOption("password", ["--password"], clk.STRING)
+  .maybeOption("internalPayto", ["--payto"], clk.STRING)
+  .action(async (args) => {
+    const httpLib = createPlatformHttpLib();
+    const corebankApiBaseUrl = args.provisionBankAccount.corebankApiBaseUrl;
+    const url = new URL("accounts", corebankApiBaseUrl);
+    const accountLogin = args.provisionBankAccount.login;
+    const body: RegisterAccountRequest = {
+      name: args.provisionBankAccount.name,
+      password: args.provisionBankAccount.password,
+      username: accountLogin,
+      is_public: !!args.provisionBankAccount.public,
+      is_taler_exchange: !!args.provisionBankAccount.exchange,
+      internal_payto_uri: args.provisionBankAccount.internalPayto,
+    };
+    const resp = await httpLib.fetch(url.href, {
+      method: "POST",
+      body,
+    });
+    if (resp.status >= 200 && resp.status <= 299) {
+      logger.info(`account ${accountLogin} successfully provisioned`);
+      return;
+    }
+    if (resp.status === HttpStatusCode.Conflict) {
+      logger.info(`account ${accountLogin} already provisioned`);
+      return;
+    }
+    logger.error(
+      `unable to provision bank account, HTTP response status ${resp.status}`,
+    );
+    process.exit(2);
+  });
+
 deploymentCli
   .subcommand("coincfg", "gen-coin-config", {
     help: "Generate a coin/denomination configuration for the exchange.",

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]