libeufin

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

commit 807919ca00a9fbaea9656912bb7d429a7b11e49e
parent 11b6f96a2f5ff449ac5be6de5f20b9e108b6b7aa
Author: MS <ms@taler.net>
Date:   Thu, 26 Nov 2020 16:10:43 +0100

remove bulky tests

Diffstat:
Dintegration-tests/test-bankAccount.py | 162-------------------------------------------------------------------------------
Dintegration-tests/test-bankConnection.py | 147-------------------------------------------------------------------------------
Dintegration-tests/test-ebics-backup.py | 155-------------------------------------------------------------------------------
Dintegration-tests/test-ebics-double-payment-submission.py | 153-------------------------------------------------------------------------------
Dintegration-tests/test-ebics-highlevel.py | 193-------------------------------------------------------------------------------
Dintegration-tests/test-ebics.py | 225-------------------------------------------------------------------------------
Dintegration-tests/test-sandbox.py | 87-------------------------------------------------------------------------------
Dintegration-tests/test-taler-facade.py | 201-------------------------------------------------------------------------------
8 files changed, 0 insertions(+), 1323 deletions(-)

diff --git a/integration-tests/test-bankAccount.py b/integration-tests/test-bankAccount.py @@ -1,162 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from time import sleep -import os -import hashlib -import base64 - -from util import startNexus, startSandbox, assertResponse -from json_checks import checkNewUserRequest, checkBankAccountElement - -# 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) - -startNexus(NEXUS_DB) -startSandbox() - -# make ebics host at sandbox -assertResponse( - post( - "http://localhost:5000/admin/ebics/host", - json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), - ) -) - -# make new ebics subscriber at sandbox -assertResponse( - post( - "http://localhost:5000/admin/ebics/subscribers", - json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), - ) -) - -# give a bank account to such subscriber, at sandbox -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, - ), - ) -) - -# 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/my-ebics/connect", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -## download list of offered accounts - -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/fetch-accounts", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -## show such accounts -listOfferedAccounts = assertResponse( - get( - "http://localhost:5001/bank-connections/my-ebics/accounts", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -listOfferedAccountsBefore = assertResponse( - get( - "http://localhost:5001/bank-connections/my-ebics/accounts", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -## import one - -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/import-account", - json=dict(offeredAccountId=BANK_ACCOUNT_LABEL, nexusBankAccountId="savings-at-nexus!"), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -## make sure the imported account shows up - -listOfferedAccountsAfter = assertResponse( - get( - "http://localhost:5001/bank-connections/my-ebics/accounts", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -for el in listOfferedAccountsAfter.json().get("accounts"): - checkBankAccountElement(el) - if el.get("nexusBankAccountId") == "savings-at-nexus": - exit(0) - print("Test passed!") - -exit(1) diff --git a/integration-tests/test-bankConnection.py b/integration-tests/test-bankConnection.py @@ -1,147 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from time import sleep -import os -import hashlib -import base64 - -from util import startNexus, startSandbox, assertResponse -from json_checks import checkDeleteConnection, checkConnectionListElement, checkBankConnection - -# 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) - -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=checkDeleteConnection(dict(bankConnectionId="my-ebics")) - ) -) - -resp = assertResponse( - get("http://localhost:5001/bank-connections") -) - -connectionsList = resp.json().get("bankConnections") -assert(connectionsList != None) - -for el in connectionsList: - checkConnectionListElement(el) - if el.get("name") == "my-ebics": - print("fail: account not deleted!") - exit(1) - -resp = assertResponse( - get("http://localhost:5001/bank-connections/my-ebics-new", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) -checkBankConnection(resp.json()) - -print("Test passed!") diff --git a/integration-tests/test-ebics-backup.py b/integration-tests/test-ebics-backup.py @@ -1,155 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from subprocess import call, Popen, PIPE -from time import sleep -import os -import socket -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 -) - -# 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) - -startNexus(NEXUS_DB) -startSandbox() - -# 0.a -assertResponse( - post( - "http://localhost:5000/admin/ebics/host", - json=checkSandboxEbicsHosts(dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION)), - ) -) - -# 0.b -assertResponse( - post( - "http://localhost:5000/admin/ebics/subscribers", - json=checkSandboxEbicsSubscriber(dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID)), - ) -) - -# 0.c - -assertResponse( - post( - "http://localhost:5000/admin/ebics/bank-accounts", - 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, - )), - ) -) - -# 1.a, make a new nexus user. -assertResponse( - post( - "http://localhost:5001/users", - headers=dict(Authorization=ADMIN_AUTHORIZATION_HEADER), - json=checkNewUserRequest(dict(username=USERNAME, password=PASSWORD)) - ) -) - -print("creating bank connection") - -# 1.b, make a ebics bank connection for the new user. -assertResponse( - post( - "http://localhost:5001/bank-connections", - json=checkNewEbicsConnection(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), - ) -) - -print("saving a backup copy") - -resp = assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/export-backup", - json=checkBackupDetails(dict(passphrase="secret")), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -# resp is the backup object. - -print("wait 3 seconds before restoring the backup") -sleep(3) - -assertResponse( - post( - "http://localhost:5001/bank-connections", - json=dict(name="my-ebics-restored", data=resp.json(), passphrase="secret", source="backup"), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -print("send ini & hia with restored connection") - -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics-restored/ebics/send-ini", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics-restored/ebics/send-hia", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -print("Test passed!") diff --git a/integration-tests/test-ebics-double-payment-submission.py b/integration-tests/test-ebics-double-payment-submission.py @@ -1,153 +0,0 @@ -#!/usr/bin/env python3 - -from subprocess import check_call -from requests import post, get -from time import sleep -import os -import hashlib -import base64 - -from util import startNexus, startSandbox, assertResponse - -# 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) - - -startNexus(NEXUS_DB) -startSandbox() - -assertResponse( - post( - "http://localhost:5000/admin/ebics/host", - json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), - ) -) -assertResponse( - post( - "http://localhost:5000/admin/ebics/subscribers", - json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), - ) -) -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, - ), - ) -) -assertResponse( - post( - "http://localhost:5001/users", - headers=dict(Authorization=ADMIN_AUTHORIZATION_HEADER), - json=dict(username=USERNAME, password=PASSWORD), - ) -) -print("creating bank connection") -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), - ) -) -print("connecting") -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/connect", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/ebics/import-accounts", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) -resp = assertResponse( - post( - "http://localhost:5001/bank-accounts/{}/payment-initiations".format( - 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") - -assertResponse( - post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{PREPARED_PAYMENT_UUID}/submit", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) -print("First payment done") -# mark the payment as not submitted directly -# into the database. -check_call(["sqlite3", NEXUS_DB, f"UPDATE PaymentInitiations SET submitted = false WHERE id = '{PREPARED_PAYMENT_UUID}'"]) - -# Re-submission of the same payment. Fails with 500 now, -# because nexus doesn't know the EBICS error code reported -# by the sandbox. -assertResponse( - post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{PREPARED_PAYMENT_UUID}/submit", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ), - acceptedResponses = [500] -) - -print("Test passed!") diff --git a/integration-tests/test-ebics-highlevel.py b/integration-tests/test-ebics-highlevel.py @@ -1,193 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from time import sleep -import os -import hashlib -import base64 - -from util import startNexus, startSandbox, assertResponse -from json_checks import checkNewEbicsConnection, checkPreparePayment, checkTransaction, checkPreparedPaymentResponse - -# 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) - -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") - -# 1.b, make a ebics bank connection for the new user. -assertResponse( - post( - "http://localhost:5001/bank-connections", - json=checkNewEbicsConnection(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), - ) -) - -print("connecting") - -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/connect", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - - -# 2.c, fetch bank account information -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/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/{}/payment-initiations".format( - BANK_ACCOUNT_LABEL - ), - json=checkPreparePayment(dict( - iban="FR7630006000011234567890189", - bic="AGRIFRPP", - name="Jacques La Fayette", - subject="integration test", - amount="EUR:1", - )), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) -checkPreparedPaymentResponse(resp.json()) -PREPARED_PAYMENT_UUID = resp.json().get("uuid") - -# 5.b, submit payment initiation -assertResponse( - post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{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/{BANK_ACCOUNT_LABEL}/fetch-transactions", - 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), - ) -) - -transactions = resp.json().get("transactions") -if len(transactions) != 1: - print(transactions) - fail(f"Unexpected number of transactions ({len(transactions)}); should be 1") - -checkTransaction(transactions[0]) - -print("Test passed!") diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py @@ -1,225 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from subprocess import call, Popen, PIPE -from time import sleep -from util import startNexus, startSandbox, assertResponse -from json_checks import checkFetchTransactions, checkPreparedPaymentElement -import os -import socket -import hashlib -import base64 - -# 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) - -startSandbox() -startNexus(NEXUS_DB) - -# 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") - -# 1.b, 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), - ) -) - -print("sending ini & hia") - -# 2.a, upload keys to the bank (INI & HIA) -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/ebics/send-ini", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/ebics/send-hia", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -# 2.b, download keys from the bank (HPB) -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/ebics/send-hpb", - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -# Test download transaction (TSD, LibEuFin-specific test order type) -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/ebics/download/tsd", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -# 2.c, fetch bank account information -assertResponse( - post( - "http://localhost:5001/bank-connections/my-ebics/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", - json=dict(level="all", rangeType="all"), - 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/{}/payment-initiations".format( - 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") - -resp = assertResponse( - get(f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{PREPARED_PAYMENT_UUID}", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) -checkPreparedPaymentElement(resp.json()) - -# 5.b, submit prepared statement -assertResponse( - post( - f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{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/{BANK_ACCOUNT_LABEL}/fetch-transactions", - json=checkFetchTransactions(dict(level="all", rangeType="all")), - 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), - ) -) - -if len(resp.json().get("transactions")) != 1: - fail("Unexpected number of transactions; should be 1") - -print("Test passed!") diff --git a/integration-tests/test-sandbox.py b/integration-tests/test-sandbox.py @@ -1,87 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from subprocess import call, Popen, PIPE -from time import sleep -import os -import socket -import hashlib -import base64 - -from util import startSandbox, assertResponse - -# 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" - - -def fail(msg): - print(msg) - exit(1) - -startSandbox() - -# Create a Ebics host. -assertResponse( - post( - "http://localhost:5000/admin/ebics/host", - json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), - ) -) - -# Create a new subscriber. -assertResponse( - post( - "http://localhost:5000/admin/ebics/subscribers", - json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), - ) -) - -# Assign a bank account to such subscriber. -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, - ), - ) -) - -# Generate a few payments related to such account. -for i in range(1, 3): - assertResponse( - post( - "http://localhost:5000/admin/payments", - json=dict( - creditorIban="ES9121000418450200051332", - creditorBic="BIC", - creditorName="Creditor Name", - debitorIban="GB33BUKB20201555555555", - debitorBic="BIC", - debitorName="Debitor Name", - amount="0.99", - currency="EUR", - subject="test service #{}".format(i) - ) - ) - ) - -resp = assertResponse( - get("http://localhost:5000/admin/payments") -) - -print(resp.text) -print("\nTest passed!") diff --git a/integration-tests/test-taler-facade.py b/integration-tests/test-taler-facade.py @@ -1,201 +0,0 @@ -#!/usr/bin/env python3 - -from requests import post, get -from subprocess import call, Popen -from time import sleep -import os -import socket -import hashlib -import base64 - -from util import startNexus, startSandbox, assertResponse - -# 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" -BANK_CONNECTION_LABEL = "my-ebics" - -# Databases -NEXUS_DB="test-nexus.sqlite3" -SANDBOX_DB="test-sandbox.sqlite3" - -def fail(msg): - print(msg) - exit(1) - -startNexus(NEXUS_DB) -startSandbox(SANDBOX_DB) - -# make ebics host at sandbox -assertResponse( - post( - "http://localhost:5000/admin/ebics/host", - json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION), - ) -) - -# make ebics subscriber at sandbox -assertResponse( - post( - "http://localhost:5000/admin/ebics/subscribers", - json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID), - ) -) - -# link bank account to ebics subscriber at sandbox -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, - ), - ) -) - -# 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=BANK_CONNECTION_LABEL, - source="new", - type="ebics", - data=dict( - ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID - ), - ), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -print("connecting") - -assertResponse( - post( - "http://localhost:5001/bank-connections/{}/connect".format(BANK_CONNECTION_LABEL), - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - - -# fetch bank account information -assertResponse( - post( - "http://localhost:5001/bank-connections/{}/ebics/import-accounts".format(BANK_CONNECTION_LABEL), - json=dict(), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER), - ) -) - -# create new facade -assertResponse( - post( - "http://localhost:5001/facades", - json=dict( - name="my-facade", - type="taler-wire-gateway", - creator=USERNAME, - config=dict( - bankAccount=BANK_ACCOUNT_LABEL, - bankConnection=BANK_CONNECTION_LABEL, - reserveTransferLevel="UNUSED", - intervalIncremental="UNUSED" - ) - ), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -# todo: call /transfer + call /history/outgoing - -assertResponse( - post( - "http://localhost:5001/facades/my-facade/taler/transfer", - json=dict( - request_uid="0", - amount="EUR:1", - exchange_base_url="http//url", - wtid="nice", - credit_account="payto://iban/THEBIC/THEIBAN?receiver-name=theName" - ), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) - -) - -assertResponse( - post( - "http://localhost:5001/facades/my-facade/taler/transfer", - json=dict( - request_uid="1", - amount="EUR:2", - exchange_base_url="http//url", - wtid="more nice", - credit_account="payto://iban/THEBIC/THEIBAN?receiver-name=theName" - ), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) - -) - -print("Sleeping 5s, to let the automatic tasks ingest the history.") -sleep(5) - -resp = assertResponse( - get( - "http://localhost:5001/facades/my-facade/taler/history/outgoing?delta=5", - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -) - -print(resp.text) - -# Checks if that crashes the _incoming_ history too. It does NOT! -resp = assertResponse( - post( - "http://localhost:5001/facades/my-facade/taler/admin/add-incoming", - json=dict( - amount="EUR:1", - reserve_pub="my-reserve-pub", - debit_account="payto://iban/DONATOR/MONEY?sender-name=TheDonator" - ), - headers=dict(Authorization=USER_AUTHORIZATION_HEADER) - ) -)