libeufin

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

commit 29ee48d6961283946079e3a75ae60dd6abbe80a8
parent f373c3a6b62e33ebf0fb3e01bc3607ed0c157ce3
Author: MS <ms@taler.net>
Date:   Tue, 30 Jun 2020 17:49:51 +0200

testing account deletion

Diffstat:
Aintegration-tests/test-bankConnection.py | 148+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 6+++---
2 files changed, 151 insertions(+), 3 deletions(-)

diff --git a/integration-tests/test-bankConnection.py b/integration-tests/test-bankConnection.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 + +from requests import post, get +from time import sleep +import os +import hashlib +import base64 + +from util import startNexus, startSandbox + +# Nexus user details +USERNAME = "person" +PASSWORD = "y" +USER_AUTHORIZATION_HEADER = "basic {}".format( + base64.b64encode(b"person:y").decode("utf-8") +) + +# Admin authentication +ADMIN_AUTHORIZATION_HEADER = "basic {}".format( + base64.b64encode(b"admin:x").decode("utf-8") +) + +# EBICS details +EBICS_URL = "http://localhost:5000/ebicsweb" +HOST_ID = "HOST01" +PARTNER_ID = "PARTNER1" +USER_ID = "USER1" +EBICS_VERSION = "H004" + +# Subscriber's bank account +SUBSCRIBER_IBAN = "GB33BUKB20201555555555" +SUBSCRIBER_BIC = "BUKBGB22" +SUBSCRIBER_NAME = "Oliver Smith" +BANK_ACCOUNT_LABEL = "savings" + +# Databases +NEXUS_DB = "test-nexus.sqlite3" + + +def fail(msg): + print(msg) + exit(1) + + +def assertResponse(response): + if response.status_code != 200: + print("Test failed on URL: {}".format(response.url)) + # stdout/stderr from both services is A LOT of text. + # Confusing to dump all that to console. + print("Check nexus.log and sandbox.log, probably under /tmp") + exit(1) + # Allows for finer grained checks. + return response + + +startNexus(NEXUS_DB) +startSandbox() + +# 0.a +assertResponse( + post( + "http://localhost:5000/admin/ebics/host", + json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), + ) +) + +# 0.b +assertResponse( + post( + "http://localhost:5000/admin/ebics/subscribers", + json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), + ) +) + +# 0.c +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), + iban=SUBSCRIBER_IBAN, + bic=SUBSCRIBER_BIC, + name=SUBSCRIBER_NAME, + label=BANK_ACCOUNT_LABEL, + ), + ) +) + +# 1.a, make a new nexus user. +assertResponse( + post( + "http://localhost:5001/users", + headers=dict(Authorization=ADMIN_AUTHORIZATION_HEADER), + json=dict(username=USERNAME, password=PASSWORD), + ) +) + +print("creating bank connection") + +# make a ebics bank connection for the new user. +assertResponse( + post( + "http://localhost:5001/bank-connections", + json=dict( + name="my-ebics", + source="new", + type="ebics", + data=dict( + ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID + ), + ), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER), + ) +) + +assertResponse( + post( + "http://localhost:5001/bank-connections", + json=dict( + name="my-ebics-new", + source="new", + type="ebics", + data=dict( + ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID + ), + ), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER), + ) +) + +assertResponse( + post( + "http://localhost:5001/bank-connections/delete-connection", + json=dict(bankConnectionId="my-ebics") + ) +) + +connectionsList = assertResponse( + get("http://localhost:5001/bank-connections") +) + +for el in connectionsList.json(): + print(el) + if el.get("name") == "my-ebics": + print("fail: account not deleted!") + exit(1) + +print("Test passed!") diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -642,13 +642,13 @@ fun serverMain(dbName: String, host: String) { NexusBankConnectionEntity.all().forEach { connList.add( BankConnectionInfo( - it.id.value, - it.type + name = it.id.value, + type = it.type ) ) } } - call.respond(BankConnectionsList(connList)) + call.respond(connList) } get("/bank-connections/{connid}") {