gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/02: CLI, register accounts via Access API


From: gnunet
Subject: [libeufin] 01/02: CLI, register accounts via Access API
Date: Mon, 22 Nov 2021 20:39:03 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 6a1dc505c4c0af15b47f64fa752395af8239e9b5
Author: ms <ms@taler.net>
AuthorDate: Mon Nov 22 20:21:52 2021 +0100

    CLI, register accounts via Access API
---
 cli/bin/libeufin-cli | 88 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 84 insertions(+), 4 deletions(-)

diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli
index 52fca212..d264b5ac 100755
--- a/cli/bin/libeufin-cli
+++ b/cli/bin/libeufin-cli
@@ -20,9 +20,9 @@ from getpass import getpass
 def check_response_status(resp, expected_status_code=200):
     if resp.status_code != expected_status_code:
         print("Unexpected response status: {}".format(resp.status_code), 
file=sys.stderr)
+        print("Response: {}".format(resp.text))
         sys.exit(1)
 
-
 def tell_user(resp, expected_status_code=200, withsuccess=False):
     if resp.status_code != expected_status_code:
         print(resp.content.decode("utf-8"), file=sys.stderr)
@@ -284,9 +284,8 @@ class SandboxContext:
         sandbox_username = os.environ.get("LIBEUFIN_SANDBOX_USERNAME")
         sandbox_password = os.environ.get("LIBEUFIN_SANDBOX_PASSWORD")
         if not sandbox_username or not sandbox_password:
-            print(
-                "LIBEUFIN_SANDBOX_USERNAME and LIBEUFIN_SANDBOX_PASSWORD\n" \
-                "not found in the environment, assuming tests are being run..."
+            print("""INFO: LIBEUFIN_SANDBOX_USERNAME and 
LIBEUFIN_SANDBOX_PASSWORD
+not found in the environment, assuming tests are being run..."""
             )
         return sandbox_username, sandbox_password
 
@@ -1186,6 +1185,87 @@ def sandbox_bankaccount(ctx):
     pass
 
 
+# This group deals with the new Access API
+# and the 'demobank' model.
+@sandbox.group("demobank", help="manage customers")
+@click.pass_context
+def sandbox_demobank(ctx):
+    pass
+
+@sandbox_demobank.command("info", help="Return basic information of a bank 
account")
+@click.option(
+    "--bank-account",
+    help="Label of the bank account whose information should be returned.",
+    required=True
+)
+@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}")
+    try:
+        resp = get(
+            url,
+            auth=auth.HTTPBasicAuth(obj.username, obj.password)
+        )
+    except Exception as e:
+        print(e)
+        print("Could not reach sandbox")
+        exit(1)
+    tell_user(resp, withsuccess=True)
+
+@sandbox_demobank.command("register",
+    help="""register a new bank account.  Note that the username
+will be both the username to login at the bank and the bank account
+label"""
+)
+@click.pass_obj
+def sandbox_demobank_register(obj):
+    sandbox_base_url = obj.require_sandbox_base_url()
+    url = urljoin_nodrop(sandbox_base_url, f"/access-api/testing/register")
+    try:
+        resp = post(url,
+            json=dict(username=obj.username, password=obj.password),
+        )
+    except Exception as e:
+        print(e)
+        print("Could not reach nexus at " + url)
+        exit(1)
+    check_response_status(resp)
+
+@sandbox_demobank.command("new-ebicssubscriber",
+    help="Associate a new Ebics subscriber to a existing bank account."
+)
+@click.option("--host-id", help="Ebics host ID", required=True)
+@click.option("--partner-id", help="Ebics partner ID", required=True)
+@click.option("--user-id", help="Ebics user ID", required=True)
+@click.option(
+    "--bank-account",
+    help="Label of the bank account to associate with this Ebics subscriber",
+    required=True
+)
+@click.pass_obj
+def sandbox_demobank_ebicssubscriber(obj, host_id, partner_id, user_id, 
bank_account):
+    sandbox_base_url = obj.require_sandbox_base_url()
+    url = urljoin_nodrop(sandbox_base_url, "/ebics/subscribers")
+    try:
+        resp = post(url,
+            json=dict(
+                hostID=host_id,
+                partnerID=partner_id,
+                userID=user_id,
+                demobankAccountLabel=bank_account
+            ),
+            auth=auth.HTTPBasicAuth(
+                obj.username,
+                obj.password
+            ),
+        )
+    except Exception as e:
+        print(e)
+        print("Could not reach sandbox")
+        exit(1)
+    check_response_status(resp)
+
 @sandbox_bankaccount.command("list", help="List accounts")
 @click.pass_obj
 def bankaccount_list(obj):

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