libeufin

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

commit f373c3a6b62e33ebf0fb3e01bc3607ed0c157ce3
parent be89bc87d74fd01d78bebb809c022319c322e763
Author: MS <ms@taler.net>
Date:   Tue, 30 Jun 2020 17:06:47 +0200

test connection deletion (with cli)

Diffstat:
Mcli/libeufin-cli | 21+++++++++++++++++++++
Mcli/setup-template.sh | 17++++++++++-------
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 2+-
3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/cli/libeufin-cli b/cli/libeufin-cli @@ -59,6 +59,27 @@ def export_backup(obj, connection_name, nexus_user_id, nexus_password, passphras print("Backup stored in {}".format(output_file)) +@bank_connection.command(help="delete bank connection") +@click.option("--connection-name", help="Name of the bank connection to backup", required=True) +@click.option("--nexus-user-id", help="Nexus user ID", required=True) +@click.option("--nexus-password", help="Nexus password", required=True) +@click.argument("nexus-base-url") +@click.pass_obj +def delete(obj, connection_name, nexus_user_id, nexus_password, nexus_base_url): + + url = urljoin(nexus_base_url, "/bank-connections/delete-connection".format(connection_name)) + try: + resp = post( + url, + json=dict(bankConnectionId=connection_name), + auth=auth.HTTPBasicAuth(nexus_user_id, nexus_password) + ) + except Exception: + print("Could not reach nexus") + exit(1) + + print(resp.content.decode("utf-8")) + @bank_connection.command(help="restore backup") @click.option("--connection-name", help="Name of the bank connection to backup", required=True) @click.option("--nexus-user-id", help="Nexus user ID", required=True) diff --git a/cli/setup-template.sh b/cli/setup-template.sh @@ -3,7 +3,7 @@ # Such template sets an env up using the Python CLI. # The setup goes until exchanging keys with the sandbox. -set -eu +set -e EBICS_HOST_ID=ebicshost EBICS_PARTNER_ID=ebicspartner @@ -19,14 +19,17 @@ NEXUS_USER=u NEXUS_PASSWORD=p NEXUS_BANK_CONNECTION_NAME=b -echo Nexus DB: $1 +if test -z $1; then + echo usage: ./setup-template.sh PATH-TO-NEXUS-DB + exit 1 +fi ########## setup sandbox ############# # make ebics host at sandbox echo Making a ebics host at the sandbox sleep 2 -./libeufin-cli-new \ +./libeufin-cli \ sandbox \ make-ebics-host \ --host-id=$EBICS_HOST_ID \ @@ -35,7 +38,7 @@ sleep 2 # activate a ebics subscriber on that host echo Activating the ebics subscriber at the sandbox sleep 2 -./libeufin-cli-new \ +./libeufin-cli \ sandbox \ activate-ebics-subscriber \ --host-id=$EBICS_HOST_ID \ @@ -45,7 +48,7 @@ sleep 2 # give a bank account to such user echo Giving a bank account to such subscriber -./libeufin-cli-new \ +./libeufin-cli \ sandbox \ associate-bank-account \ --iban=$IBAN \ @@ -67,7 +70,7 @@ sleep 2 # create a bank connection echo Creating a bank connection for such user -./libeufin-cli-new \ +./libeufin-cli \ bank-connection \ new-ebics-connection \ --connection-name $NEXUS_BANK_CONNECTION_NAME \ @@ -82,7 +85,7 @@ sleep 2 # Bootstrapping such connection echo Bootstrapping the bank connection -./libeufin-cli-new \ +./libeufin-cli \ bank-connection \ bootstrap-bank-connection \ --connection-name $NEXUS_BANK_CONNECTION_NAME \ diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -624,7 +624,7 @@ fun serverMain(dbName: String, host: String) { call.respond(object {}) } - post("/bank-connections/delete") { + post("/bank-connections/delete-connection") { val body = call.receive<BankConnectionDeletion>() transaction { val conn = NexusBankConnectionEntity.findById(body.bankConnectionId) ?: throw NexusError(