libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 390504f66ba70eb5ccdda885a86570da10cf8fc3
parent 42c62f26b4fe0e5cc2fc3f29f8b79f25b2c49ee0
Author: ms <ms@taler.net>
Date:   Fri, 17 Sep 2021 16:27:45 +0200

Adapt CLI to Sandbox' auth.

For now, only adapting those commands used to
deploy libeufin.

Diffstat:
Mcli/bin/libeufin-cli | 25+++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli @@ -272,6 +272,16 @@ def accounts(ctx): class SandboxContext: def __init__(self): self.sandbox_base_url = None + self.username, self.password = self.require_sandbox_credentials() + + def require_sandbox_credentials(self): + sandbox_username = os.environ.get("LIBEUFIN_SANDBOX_USERNAME") + sandbox_password = os.environ.get("LIBEUFIN_SANDBOX_PASSWORD") + if not sandbox_username or not sandbox_password: + raise click.UsageError( + "Please define LIBEUFIN_SANDBOX_USERNAME and LIBEUFIN_SANDBOX_PASSWORD in the environment" + ) + return sandbox_username, sandbox_password def require_sandbox_base_url(self): if self.sandbox_base_url: @@ -331,7 +341,7 @@ class NexusContext: @click.option("--sandbox-url", help="URL for the sandbox", required=False) @click.pass_context def sandbox(ctx, sandbox_url): - ctx.obj = SandboxContext() + ctx.obj = SandboxContext() # fetches username and password from the environment. ctx.obj.sandbox_base_url = sandbox_url @@ -1010,7 +1020,11 @@ def make_ebics_host(obj, host_id): sandbox_base_url = obj.require_sandbox_base_url() url = urljoin(sandbox_base_url, "/admin/ebics/hosts") try: - resp = post(url, json=dict(hostID=host_id, ebicsVersion="2.5")) + resp = post( + url, + json=dict(hostID=host_id, ebicsVersion="2.5"), + auth=auth.HTTPBasicAuth(obj.username, obj.password) + ) except Exception: print("Could not reach sandbox") exit(1) @@ -1050,7 +1064,9 @@ def create_ebics_subscriber(obj, host_id, partner_id, user_id): url = urljoin(sandbox_base_url, "/admin/ebics/subscribers") try: resp = post( - url, json=dict(hostID=host_id, partnerID=partner_id, userID=user_id) + url, + json=dict(hostID=host_id, partnerID=partner_id, userID=user_id), + auth=auth.HTTPBasicAuth(obj.username, obj.password) ) except Exception: print("Could not reach sandbox") @@ -1120,7 +1136,8 @@ def associate_bank_account( ) try: - resp = post(url, json=body) + resp = post(url, json=body, + auth=auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach sandbox") exit(1)