libeufin

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

commit cce6694a3bde653573d2ff0f0c88658f8cd9d612
parent cfbb0ee7ba0025e547deeca8edec0cb16d0b97bd
Author: MS <ms@taler.net>
Date:   Fri, 13 Nov 2020 14:03:29 +0100

Testing environment.

Fetch database connection string from /service-config.

Diffstat:
Mcli/libeufin-cli | 33++++++++++++++++-----------------
Mcli/setup-template.sh | 10+++-------
2 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/cli/libeufin-cli b/cli/libeufin-cli @@ -112,8 +112,7 @@ def restore_backup(obj, backup_file, passphrase, connection_name): backup = open(backup_file, "r") except Exception: print("Could not open the backup at {}".format(backup_file)) - return - + exit(1) backup_json = json.loads(backup.read()) backup.close() @@ -168,7 +167,7 @@ def sync(obj, connection_name): resp = post(url, json=dict(), auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print(f"Could not reach nexus at {url}") - return + exit(1) print(resp.content.decode("utf-8")) @connections.command(help="import one bank account, chosen from the downloaded ones") @@ -189,7 +188,7 @@ def import_bank_account(obj, connection_name, offered_account_id, nexus_bank_acc ) except Exception as e: print(f"Could not reach nexus at {url}: {e}") - return + exit(1) print(resp.content.decode("utf-8")) @connections.command(help="download bank accounts in raw format WITHOUT importing them") @@ -201,7 +200,7 @@ def download_bank_accounts(obj, connection_name): resp = post(url, json=dict(), auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus at " + url) - return + exit(1) print(resp.content.decode("utf-8")) @connections.command(help="list the connections") @@ -212,7 +211,7 @@ def list_connections(obj): resp = get(url, json=dict(), auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus at " + url) - return + exit(1) print(resp.content.decode("utf-8")) @connections.command(help="list bank accounts hosted at one connection") @@ -224,7 +223,7 @@ def list_offered_bank_accounts(obj, connection_name): resp = get(url, json=dict(), auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus at " + url) - return + exit(1) print(resp.content.decode("utf-8")) @accounts.command(help="show accounts belonging to calling user") @@ -235,7 +234,7 @@ def show(obj): resp = get(url, auth=auth.HTTPBasicAuth(obj.username, obj.password)) except Exception as e: print(f"Could not reach nexus at {url}, error: {e}") - return + exit(1) print(resp.content.decode("utf-8")) @accounts.command(help="prepare payment debiting 'account-name'") @@ -261,7 +260,7 @@ def prepare_payment(obj, account_name, credit_iban, credit_bic, credit_name, resp = post(url, json=body, auth=auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus at " + url) - return + exit(1) print(resp.content.decode("utf-8")) @accounts.command(help="submit a prepared payment") @@ -277,7 +276,7 @@ def submit_payment(obj, account_name, payment_uuid): resp = post(url, json=dict(), auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus at" + url) - return + exit(1) print(resp.content.decode("utf-8")) @accounts.command(help="fetch transactions from the bank") @@ -291,7 +290,7 @@ def fetch_transactions(obj, account_name): resp = post(url, auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus " + url) - return + exit(1) print(resp.content.decode("utf-8")) @accounts.command(help="get transactions from the simplified nexus JSON API") @@ -303,7 +302,7 @@ def transactions(obj, account_name): resp = get(url, auth = auth.HTTPBasicAuth(obj.username, obj.password)) except Exception: print("Could not reach nexus " + url) - return + exit(1) print(resp.content.decode("utf-8")) @taler_facade.command(help="create a new Taler facade") @@ -330,7 +329,7 @@ def new_facade(obj, facade_name, connection_name, account_name): ))) except Exception: print("Could not reach sandbox") - return + exit(1) print(resp.content.decode("utf-8")) @sandbox.command(help="activate a Ebics host") @@ -343,7 +342,7 @@ def make_ebics_host(obj, host_id, sandbox_base_url): resp = post(url, json=dict(hostID=host_id, ebicsVersion="2.5")) except Exception: print("Could not reach sandbox") - return + exit(1) print(resp.content.decode("utf-8")) @sandbox.command(help="activate a Ebics subscriber") @@ -358,7 +357,7 @@ def activate_ebics_subscriber(obj, host_id, partner_id, user_id, sandbox_base_ur resp = post(url, json=dict(hostID=host_id, partnerID=partner_id, userID=user_id)) except Exception: print("Could not reach sandbox") - return + exit(1) print(resp.content.decode("utf-8")) @sandbox.command(help="associate a bank account to a Ebics subscriber") @@ -383,7 +382,7 @@ def associate_bank_account(obj, iban, bic, person_name, account_name, resp = post(url, json=body) except Exception: print("Could not reach sandbox") - return + exit(1) print(resp.content.decode("utf-8")) @sandbox.command(help="book a payment in the sandbox") @@ -417,7 +416,7 @@ def book_payment(obj, creditor_iban, creditor_bic, creditor_name, debtor_iban, resp = post(url, json=body) except Exception: print("Could not reach sandbox") - return + exit(1) print(resp.content.decode("utf-8")) cli() diff --git a/cli/setup-template.sh b/cli/setup-template.sh @@ -23,11 +23,6 @@ NEXUS_USER=u NEXUS_PASSWORD=p NEXUS_BANK_CONNECTION_NAME=b -if test -z $1; then - echo usage: ./setup-template.sh PATH-TO-NEXUS-DB - exit 1 -fi - # Exports needed by the CLI. export NEXUS_BASE_URL="http://localhost:5001/" export NEXUS_USERNAME=$NEXUS_USER @@ -73,8 +68,9 @@ sleep 2 ########## setup nexus ############# # create a user -echo "Creating a nexus user (giving time to settle)" -libeufin-nexus superuser --db-name $1 --password $NEXUS_PASSWORD $NEXUS_USER +NEXUS_DATABASE=$(curl -s $NEXUS_BASE_URL/service-config | jq .dbConn | tr -d \" | awk -F: '{print $2}') +echo "Creating a nexus superuser (db: $NEXUS_DATABASE)" +libeufin-nexus superuser --db-name $NEXUS_DATABASE --password $NEXUS_PASSWORD $NEXUS_USER sleep 2 # create a bank connection