libeufin

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

commit 411798c1a1dfcec1a66c1737f83d7de26865ef61
parent be3c1e77b2a13ac93e4800a242450ae8850450a2
Author: MS <ms@taler.net>
Date:   Sun, 15 Nov 2020 05:59:55 +0100

Testing backup generation and import.

Diffstat:
Mintegration-tests/tests.py | 22+++++++++++++++++++++-
Mintegration-tests/util.py | 37+++++++++++++++++++++----------------
2 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/integration-tests/tests.py b/integration-tests/tests.py @@ -1,12 +1,14 @@ #!/usr/bin/env python3 from requests import post, get, auth +from time import sleep from util import ( startNexus, startSandbox, assertResponse, flushTablesSandbox, - flushTablesNexus + flushTablesNexus, + makeNexusSuperuser ) # Databases @@ -66,6 +68,7 @@ def prepareSandbox(): ) def prepareNexus(): + makeNexusSuperuser(NEXUS_DB) # make a new nexus user. assertResponse( post( @@ -139,3 +142,20 @@ def test_empty_history(): ) ) assert len(resp.json().get("transactions")) == 0 + +def test_backup(): + resp = assertResponse( + post( + f"http://localhost:5001/bank-connections/{NEXUS_BANK_CONNECTION}/export-backup", + json=dict(passphrase="secret"), + auth=NEXUS_AUTH + ) + ) + sleep(3) + assertResponse( + post( + "http://localhost:5001/bank-connections", + json=dict(name="my-ebics-restored", data=resp.json(), passphrase="secret", source="backup"), + auth=NEXUS_AUTH + ) + ) diff --git a/integration-tests/util.py b/integration-tests/util.py @@ -46,10 +46,24 @@ def kill(name, s): s.terminate() s.wait() +def makeNexusSuperuser(dbName): + db_full_path = str(Path.cwd() / dbName) + check_call( + [ + "../gradlew", + "-p", + "..", + "nexus:run", + "--console=plain", + f"--args=superuser admin --password x --db-name={db_full_path}", + ] + ) + def flushTablesSandbox(dbName): + db_full_path = str(Path.cwd() / dbName) check_call( ["sqlite3", - dbName, + db_full_path, "DELETE FROM BankAccountReports", "DELETE FROM EbicsOrderSignatures", "DELETE FROM BankAccountStatements", @@ -65,9 +79,10 @@ def flushTablesSandbox(dbName): ) def flushTablesNexus(dbName): + db_full_path = str(Path.cwd() / dbName) check_call( ["sqlite3", - dbName, + db_full_path, "DELETE FROM EbicsSubscribers", "DELETE FROM NexusBankTransactions", "DELETE FROM TalerFacadeState", @@ -84,8 +99,8 @@ def flushTablesNexus(dbName): ] ) -def startSandbox(dbname="sandbox-test.sqlite3"): - db_full_path = str(Path.cwd() / dbname) +def startSandbox(dbName="sandbox-test.sqlite3"): + db_full_path = str(Path.cwd() / dbName) check_call(["rm", "-f", db_full_path]) check_call(["../gradlew", "-p", "..", "sandbox:assemble"]) checkPort(5000) @@ -110,22 +125,12 @@ def startSandbox(dbname="sandbox-test.sqlite3"): break -def startNexus(dbname="nexus-test.sqlite3"): - db_full_path = str(Path.cwd() / dbname) +def startNexus(dbName="nexus-test.sqlite3"): + db_full_path = str(Path.cwd() / dbName) check_call(["rm", "-f", "--", db_full_path]) check_call( ["../gradlew", "-p", "..", "nexus:assemble",] ) - check_call( - [ - "../gradlew", - "-p", - "..", - "nexus:run", - "--console=plain", - "--args=superuser admin --password x --db-name={}".format(db_full_path), - ] - ) checkPort(5001) nexus = Popen( [