gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Add abstraction: SandboxContext.access


From: gnunet
Subject: [libeufin] branch master updated: Add abstraction: SandboxContext.access_api_url
Date: Wed, 02 Feb 2022 10:37:42 +0100

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

ttn pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new d87965f2 Add abstraction: SandboxContext.access_api_url
d87965f2 is described below

commit d87965f2b3166a5a627e0ac4daa9ea70c6cc5c1c
Author: Thien-Thi Nguyen <ttn@gnuvola.org>
AuthorDate: Wed Feb 2 00:17:13 2022 -0500

    Add abstraction: SandboxContext.access_api_url
    
    This function constructs a proper URL for the Acesss API endpoints.
    There are currently three of them that have been modified to use it:
     - sandbox demobank register
     - sandbox demobank info
     - sandbox demobank new-transaction
    Note that their functionality has not changed.
    
    The change merely centralizes the URL construction, and
    (in comments) documents the assumptions re Access API base URL.
---
 cli/bin/libeufin-cli | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli
index 3f6f9cca..956859ff 100755
--- a/cli/bin/libeufin-cli
+++ b/cli/bin/libeufin-cli
@@ -299,6 +299,17 @@ 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)
+
 
 class NexusContext:
     def __init__(self):
@@ -1216,9 +1227,7 @@ def sandbox_demobank(ctx):
 )
 @click.pass_obj
 def sandbox_demobank_new_transaction(obj, bank_account, payto_with_subject, 
amount):
-    # expected to include the demobank name.
-    sandbox_base_url = obj.require_sandbox_base_url()
-    url = urljoin_nodrop(sandbox_base_url, 
f"/access-api/accounts/{bank_account}/transactions")
+    url = obj.access_api_url (f"/accounts/{bank_account}/transactions")
     try:
         body = dict(paytoUri=payto_with_subject, amount=amount)
         resp = post(
@@ -1241,8 +1250,7 @@ def sandbox_demobank_new_transaction(obj, bank_account, 
payto_with_subject, amou
 )
 @click.pass_obj
 def sandbox_demobank_info(obj, bank_account):
-    sandbox_base_url = obj.require_sandbox_base_url()
-    url = urljoin_nodrop(sandbox_base_url, 
f"/access-api/accounts/{bank_account}")
+    url = obj.access_api_url (f"/accounts/{bank_account}")
     try:
         resp = get(
             url,
@@ -1267,8 +1275,7 @@ def sandbox_demobank_info(obj, bank_account):
 )
 @click.pass_obj
 def sandbox_demobank_register(obj, public):
-    sandbox_base_url = obj.require_sandbox_base_url()
-    url = urljoin_nodrop(sandbox_base_url, f"/access-api/testing/register")
+    url = obj.access_api_url ("/testing/register")
     try:
         resp = post(
             url,

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