gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: CLI: provide demobank URL default.


From: gnunet
Subject: [libeufin] branch master updated: CLI: provide demobank URL default.
Date: Wed, 04 Jan 2023 09:57:24 +0100

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

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 7ee451ec CLI: provide demobank URL default.
7ee451ec is described below

commit 7ee451ec4c7dcb3256186ae446ee2d8b15ce94bb
Author: MS <ms@taler.net>
AuthorDate: Wed Jan 4 09:56:01 2023 +0100

    CLI: provide demobank URL default.
    
    That allows users to export only once the Sandbox
    URL, as opposed to export it once for the Legacy API
    and once for the Access API sub-commands.
---
 cli/bin/libeufin-cli | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli
index 49388038..6bdd795e 100755
--- a/cli/bin/libeufin-cli
+++ b/cli/bin/libeufin-cli
@@ -278,6 +278,7 @@ def accounts(ctx):
 class SandboxContext:
     def __init__(self):
         self.sandbox_base_url = None
+        self.demobank_name = None
         self.username, self.password = self.require_sandbox_credentials()
 
     def require_sandbox_credentials(self):
@@ -299,17 +300,14 @@ not found in the environment, assuming tests are being 
run..."""
             )
         return sandbox_base_url
 
-    # For the Access-API endpoints, the user must choose exactly *one* bank
-    # and include that in ‘LIBEUFIN_SANDBOX_URL’ (or ‘--sandbox-url’).
     def access_api_url(self, upath):
-        # NB: We expect that ‘base’ ends w/ f"demobanks/{bank}".
-        # This means that base for non-Access-API endpoints
-        # is incompatible w/ that for Access-API endpoints.
-        # (Using one for the other will result in 404.)  But that's
-        # OK because the non-Access-API endspoints are going away.
-        base = self.require_sandbox_base_url ()
-        return urljoin_nodrop (base, "/access-api" + upath)
+        base = self.require_sandbox_base_url()
+        # return urljoin_nodrop(demobank_base, "/access-api" + upath)
+        return urljoin_nodrop(self.demobank_base_url(), "/access-api" + upath)
 
+    def demobank_base_url(self):
+        base = self.require_sandbox_base_url()
+        return  urljoin_nodrop(base, f"demobanks/{self.demobank_name}")
 
 class NexusContext:
     def __init__(self):
@@ -1210,8 +1208,15 @@ def sandbox_bankaccount(ctx):
     "demobank",
     help="Subcommands for the 'demobank' model and the Access API."
 )
+@click.option(
+    "--demobank-name",
+    help="Defaults to 'default'",
+    required=False,
+    default="default"
+    )
 @click.pass_context
-def sandbox_demobank(ctx):
+def sandbox_demobank(ctx, demobank_name):
+    ctx.obj.demobank_name = demobank_name
     pass
 
 @sandbox_demobank.command("list-transactions", help="List transactions.")
@@ -1292,6 +1297,16 @@ def sandbox_demobank_info(obj, bank_account):
         exit(1)
     tell_user(resp, withsuccess=True)
 
+
+@sandbox_demobank.command(
+  "debug-url",
+  help="Prints the base URL for the demobank to address, according to the 
related values passed via the environment or the command line."
+)
+@click.pass_obj
+def debug_url(obj):
+    print("demobank URL", obj.demobank_base_url())
+    print("access API registration URL", 
obj.access_api_url("/testing/register"))
+
 @sandbox_demobank.command("delete",
     help="""delete bank account"""
 )

-- 
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]