diff options
author | MS <ms@taler.net> | 2020-10-29 22:27:55 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2020-10-29 22:27:55 +0100 |
commit | 2c20308c86309fccb3843d095c89320a6995e49e (patch) | |
tree | 66732591dbc32682088b57ff3b7ed29ada1af659 /integration-tests | |
parent | d7878cb5d05c76959ca97f8fca79ea93afe0d02b (diff) | |
download | libeufin-2c20308c86309fccb3843d095c89320a6995e49e.tar.gz libeufin-2c20308c86309fccb3843d095c89320a6995e49e.tar.bz2 libeufin-2c20308c86309fccb3843d095c89320a6995e49e.zip |
checks (work in progress)
Diffstat (limited to 'integration-tests')
-rwxr-xr-x | integration-tests/all.sh | 2 | ||||
-rw-r--r-- | integration-tests/json_checks.py | 51 | ||||
-rwxr-xr-x | integration-tests/test-bankAccount.py | 2 | ||||
-rwxr-xr-x | integration-tests/test-bankConnection.py | 11 | ||||
-rwxr-xr-x | integration-tests/test-ebics-highlevel.py | 4 | ||||
-rwxr-xr-x | integration-tests/test-ebics.py | 13 | ||||
-rw-r--r-- | integration-tests/util.py | 2 |
7 files changed, 77 insertions, 8 deletions
diff --git a/integration-tests/all.sh b/integration-tests/all.sh index c8dd2152..4eb32416 100755 --- a/integration-tests/all.sh +++ b/integration-tests/all.sh @@ -6,7 +6,7 @@ set -e ./test-ebics-highlevel.py ./test-ebics.py ./test-sandbox.py -./test-taler-facade.py +./test-taler-facade.py ./test-bankConnection.py ./test-ebics-double-payment-submission.py echo "All tests passed." diff --git a/integration-tests/json_checks.py b/integration-tests/json_checks.py index a0a54bce..916712a6 100644 --- a/integration-tests/json_checks.py +++ b/integration-tests/json_checks.py @@ -10,6 +10,15 @@ def checkNewUserRequest(json): c = T(F("username"), F("password")) return c.check(json) +def checkBankAccountElement(json): + c = T( + F("nexusBankAccountId"), + F("iban"), + F("bic"), + F("ownerName") + ) + return c.check(json) + def checkPreparePayment(json): c = T( F("iban"), @@ -20,10 +29,51 @@ def checkPreparePayment(json): ) return c.check(json) +def checkBankConnection(json): + c = T( + F("bankConnectionId"), + F("bankConnectionType"), + F("ready"), + F("bankKeysReviewed") + ) + return c.check(json) + +def checkDeleteConnection(json): + c = T(F("bankConnectionId")) + return c.check(json) + +def checkConnectionListElement(json): + c = T( + F("name"), + F("type") + ) + return c.check(json) + def checkPreparedPaymentResponse(json): c = T(F("uuid")) return c.check(json) +def checkPreparedPaymentElement(json): + c = T( + F("paymentInitiationId"), + F("submitted"), + F("creditorIban"), + F("creditorBic"), + F("creditorName"), + F("amount"), + F("subject"), + F("submissionDate"), + F("preparationDate") + ) + return c.check(json) + +def checkFetchTransactions(json): + c = T( + F("rangeType"), + F("level") + ) + return c.check(json) + def checkTransaction(json): c = T( F("account"), @@ -34,6 +84,7 @@ def checkTransaction(json): F("date"), F("subject") ) + return c.check(json) def checkNewEbicsConnection(json): c = T( diff --git a/integration-tests/test-bankAccount.py b/integration-tests/test-bankAccount.py index a640aa86..29baa945 100755 --- a/integration-tests/test-bankAccount.py +++ b/integration-tests/test-bankAccount.py @@ -7,6 +7,7 @@ import hashlib import base64 from util import startNexus, startSandbox, assertResponse +from json_checks import checkNewUserRequest, checkBankAccountElement # Nexus user details USERNAME = "person" @@ -153,6 +154,7 @@ listOfferedAccountsAfter = assertResponse( ) for el in listOfferedAccountsAfter.json().get("accounts"): + checkBankAccountElement(el) if el.get("nexusBankAccountId") == "savings-at-nexus": exit(0) print("Test passed!") diff --git a/integration-tests/test-bankConnection.py b/integration-tests/test-bankConnection.py index 02571a59..954af268 100755 --- a/integration-tests/test-bankConnection.py +++ b/integration-tests/test-bankConnection.py @@ -7,6 +7,7 @@ import hashlib import base64 from util import startNexus, startSandbox, assertResponse +from json_checks import checkDeleteConnection, checkConnectionListElement, checkBankConnection # Nexus user details USERNAME = "person" @@ -119,7 +120,7 @@ assertResponse( assertResponse( post( "http://localhost:5001/bank-connections/delete-connection", - json=dict(bankConnectionId="my-ebics") + json=checkDeleteConnection(dict(bankConnectionId="my-ebics")) ) ) @@ -131,8 +132,16 @@ 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-highlevel.py b/integration-tests/test-ebics-highlevel.py index bb49e312..29069f40 100755 --- a/integration-tests/test-ebics-highlevel.py +++ b/integration-tests/test-ebics-highlevel.py @@ -181,7 +181,7 @@ resp = assertResponse( headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) -checkPreparedPaymentResponse(resp) +checkPreparedPaymentResponse(resp.json()) PREPARED_PAYMENT_UUID = resp.json().get("uuid") # 5.b, submit payment initiation @@ -213,6 +213,6 @@ if len(transactions) != 1: print(transactions) fail(f"Unexpected number of transactions ({len(transactions)}); should be 1") -checkTransactions(transactions[0]) +checkTransaction(transactions[0]) print("Test passed!") diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py index aac20d7c..c725715e 100755 --- a/integration-tests/test-ebics.py +++ b/integration-tests/test-ebics.py @@ -3,13 +3,13 @@ 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 -from util import startNexus, startSandbox, assertResponse - # Steps implemented in this test. # # 0 Prepare sandbox. @@ -212,6 +212,13 @@ 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( @@ -225,7 +232,7 @@ assertResponse( assertResponse( post( f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/fetch-transactions", - json=dict(level="all", rangeType="all"), + json=checkFetchTransactions(dict(level="all", rangeType="all")), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) diff --git a/integration-tests/util.py b/integration-tests/util.py index ab85cd66..76d68bc9 100644 --- a/integration-tests/util.py +++ b/integration-tests/util.py @@ -16,7 +16,7 @@ class CheckJsonField: def check(self, json): if self.name not in json and not self.optional: - print(f"'{self.name}' not found in the JSON.") + print(f"'{self.name}' not found in the JSON: {json}.") sys.exit(1) if self.nested: self.nested.check(json.get(self.name)) |