libeufin

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

commit b2e05de586957ecfdde08d3a2af5a9db54675646
parent ad7c9eb3548990941ea68803c15d4d735eb25a8a
Author: MS <ms@taler.net>
Date:   Thu, 22 Oct 2020 15:21:06 +0200

documentation checks

Diffstat:
Mintegration-tests/json_checks.py | 28+++++++++++++++++++++++++++-
Mintegration-tests/test-ebics-backup.py | 31++++++++++++++++---------------
Mintegration-tests/util.py | 6+++---
3 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/integration-tests/json_checks.py b/integration-tests/json_checks.py @@ -25,5 +25,31 @@ def checkNewEbicsConnection(json): return c.check(json) def checkImportAccount(json): - c = T(F("nexusBankAccountId"), F("offeredAccountId")) + c = T(F("nexusBankAccountId"), + F("offeredAccountId")) return c.check(json) + +def checkSandboxEbicsHosts(json): + c = T(F("hostID"), + F("ebicsVersion")) + return c.check(json) + +def checkSandboxEbicsSubscriber(json): + c = T(F("hostID"), + F("userID"), + F("partnerID"), + F("systemID", optional=True)) + return c.check(json) + +def checkSandboxBankAccount(json): + c = T( + F("iban"), + F("bic"), + F("name"), + F("subscriber"), + F("label") + ) + return c.check(json) + +def checkBackupDetails(json): + return T(F("passphrase")).check(json) diff --git a/integration-tests/test-ebics-backup.py b/integration-tests/test-ebics-backup.py @@ -9,6 +9,14 @@ import hashlib import base64 from util import startNexus, startSandbox, CheckJsonTop as T, CheckJsonField as F, assertResponse +from json_checks import ( + checkSandboxEbicsHosts, + checkSandboxEbicsSubscriber, + checkSandboxBankAccount, + checkNewEbicsConnection, + checkNewUserRequest, + checkBackupDetails +) # Steps implemented in this test. # @@ -63,7 +71,7 @@ startSandbox() assertResponse( post( "http://localhost:5000/admin/ebics/host", - json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), + json=checkSandboxEbicsHosts(dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION)), ) ) @@ -71,21 +79,22 @@ assertResponse( assertResponse( post( "http://localhost:5000/admin/ebics/subscribers", - json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), + json=checkSandboxEbicsSubscriber(dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID)), ) ) # 0.c + assertResponse( post( "http://localhost:5000/admin/ebics/bank-accounts", - json=dict( + json=checkSandboxBankAccount(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, - ), + )), ) ) @@ -94,25 +103,17 @@ assertResponse( post( "http://localhost:5001/users", headers=dict(Authorization=ADMIN_AUTHORIZATION_HEADER), - json=T(F("username"), F("password")).check( - dict(username=USERNAME, password=PASSWORD)), + json=checkNewUserRequest(dict(username=USERNAME, password=PASSWORD)) ) ) print("creating bank connection") # 1.b, make a ebics bank connection for the new user. -check_bankConnection_request = T( - F("source"), - F("name"), - F("data", T( - F("ebicsURL"), F("hostID"), F("partnerID"), F("userID") - )) -) assertResponse( post( "http://localhost:5001/bank-connections", - json=check_bankConnection_request.check(dict( + json=checkNewEbicsConnection(dict( name="my-ebics", source="new", type="ebics", @@ -129,7 +130,7 @@ print("saving a backup copy") resp = assertResponse( post( "http://localhost:5001/bank-connections/my-ebics/export-backup", - json=dict(passphrase="secret"), + json=checkBackupDetails(dict(passphrase="secret")), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) diff --git a/integration-tests/util.py b/integration-tests/util.py @@ -9,12 +9,13 @@ from pathlib import Path import sys class CheckJsonField: - def __init__(self, name, nested = None): + def __init__(self, name, nested=None, optional=False): self.name = name self.nested = nested + self.optional = optional def check(self, json): - if self.name not in json: + if self.name not in json and not self.optional: print(f"'{self.name}' not found in the JSON.") sys.exit(1) if self.nested: @@ -44,7 +45,6 @@ def kill(name, s): print(f"terminating {name} ...") s.terminate() s.wait() - print("terminated!") def startSandbox(dbname="sandbox-test.sqlite3"):