libeufin

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

commit 30984f746dc5bfa246bb97bed4016e28b5ad5ec7
parent f81d6bd521ce29b0e801703da7a635c0390a9df3
Author: tanhengyeow <E0032242@u.nus.edu>
Date:   Tue, 16 Jun 2020 16:11:53 +0800

Update script file to add more bank connections/accounts

Diffstat:
Mintegration-tests/start-testenv.py | 328+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 256 insertions(+), 72 deletions(-)

diff --git a/integration-tests/start-testenv.py b/integration-tests/start-testenv.py @@ -23,16 +23,66 @@ ADMIN_AUTHORIZATION_HEADER = "basic {}".format( # 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" +# Bank connection 1 details +BC1_HOST_ID = "HOST01" +BC1_PARTNER_ID = "PARTNER1" +BC1_USER_ID = "USER1" + +# Bank connection 1 subscribers' bank accounts +BC1_SUBSCRIBER1_IBAN = "GB33BUKB20201222222222" +BC1_SUBSCRIBER1_BIC = "BUKBGB11" +BC1_SUBSCRIBER1_NAME = "Oliver Smith" +BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL = "bc1sub1savings" + +BC1_SUBSCRIBER2_IBAN = "GB33BUKB20201333333333" +BC1_SUBSCRIBER2_BIC = "BUKBGB22" +BC1_SUBSCRIBER2_NAME = "John Doe" +BC1_SUBSCRIBER2_BANK_ACCOUNT_LABEL = "bc1sub2savings" + +BC1_SUBSCRIBER3_IBAN = "GB33BUKB20201444444444" +BC1_SUBSCRIBER3_BIC = "BUKBGB33" +BC1_SUBSCRIBER3_NAME = "Peter John" +BC1_SUBSCRIBER3_BANK_ACCOUNT_LABEL = "bc1sub3savings" + +# Bank connection 2 details +BC2_HOST_ID = "HOST02" +BC2_PARTNER_ID = "PARTNER2" +BC2_USER_ID = "USER2" + +# Bank connection 2 subscribers' bank accounts +BC2_SUBSCRIBER1_IBAN = "GB33BUKB20201555555555" +BC2_SUBSCRIBER1_BIC = "BUKBGB44" +BC2_SUBSCRIBER1_NAME = "Mary Smith" +BC2_SUBSCRIBER1_BANK_ACCOUNT_LABEL = "bc2sub1savings" + +BC2_SUBSCRIBER2_IBAN = "GB33BUKB20201666666666" +BC2_SUBSCRIBER2_BIC = "BUKBGB55" +BC2_SUBSCRIBER2_NAME = "David Doe" +BC2_SUBSCRIBER2_BANK_ACCOUNT_LABEL = "bc2sub2savings" + +# Bank connection 3 details +BC3_HOST_ID = "HOST03" +BC3_PARTNER_ID = "PARTNER3" +BC3_USER_ID = "USER3" + +# Bank connection 3 subscribers' bank accounts +BC3_SUBSCRIBER1_IBAN = "GB33BUKB20201777777777" +BC3_SUBSCRIBER1_BIC = "BUKBGB66" +BC3_SUBSCRIBER1_NAME = "Zack Low" +BC3_SUBSCRIBER1_BANK_ACCOUNT_LABEL = "bc3sub1savings" + +# Bank connection 4 details +BC4_HOST_ID = "HOST04" +BC4_PARTNER_ID = "PARTNER4" +BC4_USER_ID = "USER4" + +# Bank connection 4 subscribers' bank accounts +BC4_SUBSCRIBER1_IBAN = "GB33BUKB20201888888888" +BC4_SUBSCRIBER1_BIC = "BUKBGB77" +BC4_SUBSCRIBER1_NAME = "Sally Go" +BC4_SUBSCRIBER1_BANK_ACCOUNT_LABEL = "bc4sub1savings" # Databases NEXUS_DB="test-nexus.sqlite3" @@ -56,32 +106,145 @@ def assertResponse(response): startNexus("nexus-testenv.sqlite3") startSandbox() -# 0.a +# 0.a Create EBICS hosts assertResponse( post( "http://localhost:5000/admin/ebics/host", - json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), + json=dict(hostID=BC1_HOST_ID, ebicsVersion=EBICS_VERSION), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/host", + json=dict(hostID=BC2_HOST_ID, ebicsVersion=EBICS_VERSION), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/host", + json=dict(hostID=BC3_HOST_ID, ebicsVersion=EBICS_VERSION), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/host", + json=dict(hostID=BC4_HOST_ID, ebicsVersion=EBICS_VERSION), ) ) -# 0.b +# 0.b Create EBICS subscribers +assertResponse( + post( + "http://localhost:5000/admin/ebics/subscribers", + json=dict(hostID=BC1_HOST_ID, partnerID=BC1_PARTNER_ID, userID=BC1_USER_ID), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/subscribers", + json=dict(hostID=BC2_HOST_ID, partnerID=BC2_PARTNER_ID, userID=BC2_USER_ID), + ) +) assertResponse( post( "http://localhost:5000/admin/ebics/subscribers", - json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), + json=dict(hostID=BC3_HOST_ID, partnerID=BC3_PARTNER_ID, userID=BC3_USER_ID), ) ) +assertResponse( + post( + "http://localhost:5000/admin/ebics/subscribers", + json=dict(hostID=BC4_HOST_ID, partnerID=BC4_PARTNER_ID, userID=BC4_USER_ID), + ) +) + +# 0.c Associates new bank accounts to subscribers. -# 0.c +# BC1 +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=BC1_HOST_ID, partnerID=BC1_PARTNER_ID, userID=BC1_USER_ID), + iban=BC1_SUBSCRIBER1_IBAN, + bic=BC1_SUBSCRIBER1_BIC, + name=BC1_SUBSCRIBER1_NAME, + label=BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL + ), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=BC1_HOST_ID, partnerID=BC1_PARTNER_ID, userID=BC1_USER_ID), + iban=BC1_SUBSCRIBER2_IBAN, + bic=BC1_SUBSCRIBER2_BIC, + name=BC1_SUBSCRIBER2_NAME, + label=BC1_SUBSCRIBER2_BANK_ACCOUNT_LABEL, + ), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=BC1_HOST_ID, partnerID=BC1_PARTNER_ID, userID=BC1_USER_ID), + iban=BC1_SUBSCRIBER3_IBAN, + bic=BC1_SUBSCRIBER3_BIC, + name=BC1_SUBSCRIBER3_NAME, + label=BC1_SUBSCRIBER3_BANK_ACCOUNT_LABEL, + ), + ) +) +# BC2 +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=BC2_HOST_ID, partnerID=BC2_PARTNER_ID, userID=BC2_USER_ID), + iban=BC2_SUBSCRIBER1_IBAN, + bic=BC2_SUBSCRIBER1_BIC, + name=BC2_SUBSCRIBER1_NAME, + label=BC2_SUBSCRIBER1_BANK_ACCOUNT_LABEL, + ), + ) +) +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=BC2_HOST_ID, partnerID=BC2_PARTNER_ID, userID=BC2_USER_ID), + iban=BC2_SUBSCRIBER2_IBAN, + bic=BC2_SUBSCRIBER2_BIC, + name=BC2_SUBSCRIBER2_NAME, + label=BC2_SUBSCRIBER2_BANK_ACCOUNT_LABEL, + ), + ) +) +# BC3 +assertResponse( + post( + "http://localhost:5000/admin/ebics/bank-accounts", + json=dict( + subscriber=dict(hostID=BC3_HOST_ID, partnerID=BC3_PARTNER_ID, userID=BC3_USER_ID), + iban=BC3_SUBSCRIBER1_IBAN, + bic=BC3_SUBSCRIBER1_BIC, + name=BC3_SUBSCRIBER1_NAME, + label=BC3_SUBSCRIBER1_BANK_ACCOUNT_LABEL, + ), + ) +) +# BC4 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, + subscriber=dict(hostID=BC4_HOST_ID, partnerID=BC4_PARTNER_ID, userID=BC4_USER_ID), + iban=BC4_SUBSCRIBER1_IBAN, + bic=BC4_SUBSCRIBER1_BIC, + name=BC4_SUBSCRIBER1_NAME, + label=BC4_SUBSCRIBER1_BANK_ACCOUNT_LABEL, ), ) ) @@ -103,11 +266,11 @@ assertResponse( post( "http://localhost:5001/bank-connections", json=dict( - name="my-ebics", + name="my-ebics-1", source="new", type="ebics", data=dict( - ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID + ebicsURL=EBICS_URL, hostID=BC1_HOST_ID, partnerID=BC1_PARTNER_ID, userID=BC1_USER_ID ), ), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), @@ -121,7 +284,7 @@ assertResponse( source="new", type="ebics", data=dict( - ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID + ebicsURL=EBICS_URL, hostID=BC2_HOST_ID, partnerID=BC2_PARTNER_ID, userID=BC2_USER_ID ), ), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), @@ -135,7 +298,7 @@ assertResponse( source="new", type="ebics", data=dict( - ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID + ebicsURL=EBICS_URL, hostID=BC3_HOST_ID, partnerID=BC3_PARTNER_ID, userID=BC3_USER_ID ), ), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), @@ -149,7 +312,7 @@ assertResponse( source="new", type="ebics", data=dict( - ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID + ebicsURL=EBICS_URL, hostID=BC4_HOST_ID, partnerID=BC4_PARTNER_ID, userID=BC4_USER_ID ), ), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), @@ -160,7 +323,7 @@ print("connecting") assertResponse( post( - "http://localhost:5001/bank-connections/my-ebics/connect", + "http://localhost:5001/bank-connections/my-ebics-1/connect", json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) @@ -191,76 +354,97 @@ assertResponse( # 2.c, fetch bank account information assertResponse( post( - "http://localhost:5001/bank-connections/my-ebics/ebics/import-accounts", + "http://localhost:5001/bank-connections/my-ebics-1/ebics/import-accounts", json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) - -# 3, ask nexus to download history assertResponse( post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/fetch-transactions", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -# 4, make sure history is empty -resp = assertResponse( - get( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/transactions", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) -if len(resp.json().get("transactions")) != 0: - fail("unexpected number of transactions") - -# 5.a, prepare a payment -resp = assertResponse( - post( - "http://localhost:5001/bank-accounts/{}/prepared-payments".format( - BANK_ACCOUNT_LABEL - ), - json=dict( - iban="FR7630006000011234567890189", - bic="AGRIFRPP", - name="Jacques La Fayette", - subject="integration test", - amount="EUR:1", - ), + "http://localhost:5001/bank-connections/my-ebics-2/ebics/import-accounts", + json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) -PREPARED_PAYMENT_UUID = resp.json().get("uuid") -if PREPARED_PAYMENT_UUID == None: - fail("Payment UUID not received") - -# 5.b, submit prepared statement assertResponse( post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/prepared-payments/{PREPARED_PAYMENT_UUID}/submit", + "http://localhost:5001/bank-connections/my-ebics-3/ebics/import-accounts", json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) - -# 6, request history after payment submission assertResponse( post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/fetch-transactions", + "http://localhost:5001/bank-connections/my-ebics-4/ebics/import-accounts", + json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) -resp = assertResponse( - get( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/transactions", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) +# # 3, ask nexus to download history +# assertResponse( +# post( +# f"http://localhost:5001/bank-accounts/{BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL}/fetch-transactions", +# headers=dict(Authorization=USER_AUTHORIZATION_HEADER), +# ) +# ) + +# # 4, make sure history is empty +# resp = assertResponse( +# get( +# f"http://localhost:5001/bank-accounts/{BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL}/transactions", +# headers=dict(Authorization=USER_AUTHORIZATION_HEADER), +# ) +# ) +# if len(resp.json().get("transactions")) != 0: +# fail("unexpected number of transactions") + +# # 5.a, prepare a payment +# resp = assertResponse( +# post( +# "http://localhost:5001/bank-accounts/{}/prepared-payments".format( +# BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL +# ), +# json=dict( +# iban="FR7630006000011234567890189", +# bic="AGRIFRPP", +# name="Jacques La Fayette", +# subject="integration test", +# amount="EUR:1", +# ), +# headers=dict(Authorization=USER_AUTHORIZATION_HEADER), +# ) +# ) +# PREPARED_PAYMENT_UUID = resp.json().get("uuid") +# if PREPARED_PAYMENT_UUID == None: +# fail("Payment UUID not received") + +# # 5.b, submit prepared statement +# assertResponse( +# post( +# f"http://localhost:5001/bank-accounts/{BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL}/prepared-payments/{PREPARED_PAYMENT_UUID}/submit", +# json=dict(), +# headers=dict(Authorization=USER_AUTHORIZATION_HEADER), +# ) +# ) + +# # 6, request history after payment submission +# assertResponse( +# post( +# f"http://localhost:5001/bank-accounts/{BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL}/fetch-transactions", +# headers=dict(Authorization=USER_AUTHORIZATION_HEADER), +# ) +# ) + +# resp = assertResponse( +# get( +# f"http://localhost:5001/bank-accounts/{BC1_SUBSCRIBER1_BANK_ACCOUNT_LABEL}/transactions", +# headers=dict(Authorization=USER_AUTHORIZATION_HEADER), +# ) +# ) -if len(resp.json().get("transactions")) != 1: - fail("Unexpected number of transactions; should be 1") +# if len(resp.json().get("transactions")) != 1: +# fail("Unexpected number of transactions; should be 1") try: