libeufin

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

commit 1cf856ce01962231460efdc135603f13b08f1014
parent 48d69b46a9a7d83af995e6e73f51f1ad86dd33d9
Author: ms <ms@taler.net>
Date:   Tue, 12 Oct 2021 11:04:46 +0200

CLI.

Adapt after what "taler-local prepare" needed in
terms of token-based authentication.  Other parts
may need to be changed

Diffstat:
Mcli/bin/libeufin-cli | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli @@ -280,6 +280,11 @@ class SandboxContext: self.sandbox_base_url = None self.username, self.password = self.require_sandbox_credentials() + def require_sandbox_admin_token(self): + token = os.environ.get("LIBEUFIN_SANDBOX_TOKEN") + if not token: + raise click.UsageError("Please define LIBEUFIN_SANDBOX_TOKEN in the environment") + return token def require_sandbox_credentials(self): sandbox_username = os.environ.get("LIBEUFIN_SANDBOX_USERNAME") sandbox_password = os.environ.get("LIBEUFIN_SANDBOX_PASSWORD") @@ -347,7 +352,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() # fetches username and password from the environment. + ctx.obj = SandboxContext() ctx.obj.sandbox_base_url = sandbox_url @@ -1052,7 +1057,7 @@ def make_ebics_host(obj, host_id): resp = post( url, json=dict(hostID=host_id, ebicsVersion="2.5"), - auth=auth.HTTPBasicAuth(obj.username, obj.password) + headers={"Authorization": "Bearer " + obj.require_sandbox_admin_token()} ) except Exception as e: print(e) @@ -1097,7 +1102,7 @@ def create_ebics_subscriber(obj, host_id, partner_id, user_id): resp = post( url, json=dict(hostID=host_id, partnerID=partner_id, userID=user_id), - auth=auth.HTTPBasicAuth(obj.username, obj.password) + headers={"Authorization": "Bearer " + obj.require_sandbox_admin_token()} ) except Exception as e: print(e) @@ -1169,8 +1174,10 @@ def associate_bank_account( ) try: - resp = post(url, json=body, - auth=auth.HTTPBasicAuth(obj.username, obj.password)) + resp = post( + url, json=body, + headers={"Authorization": "Bearer " + obj.require_sandbox_admin_token()} + ) except Exception as e: print(e) print("Could not reach sandbox")