libeufin

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

commit a878a3350d90c7b34f7b734a63f89dec469fb528
parent 27a8fa91a81b3f8930dfe3145f8d930bb03dc545
Author: MS <ms@taler.net>
Date:   Thu, 10 Dec 2020 17:29:06 +0100

Command 'drop-tables' becomes 'reset-tables'.

This makes it possible to avoid restarting the
services between tests.

Diffstat:
Mintegration-tests/tests.py | 44+++-----------------------------------------
Mintegration-tests/util.py | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 5+++--
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 5+++--
4 files changed, 11 insertions(+), 47 deletions(-)

diff --git a/integration-tests/tests.py b/integration-tests/tests.py @@ -20,7 +20,9 @@ S = "http://localhost:5000" N = "http://localhost:5001" # Database -DB = "jdbc:postgresql://127.0.0.1:5433/libeufintestdb?user=libeufin" +DB_POSTGRES = "jdbc:postgresql://127.0.0.1:5433/libeufintestdb?user=libeufin" +DB_SQLITE = "jdbc:sqlite:/tmp/libeufintestdb" +DB = DB_SQLITE # Nexus user details NEXUS_USERNAME = "person" @@ -288,46 +290,6 @@ def test_taler_facade(): ) assert len(resp.json().get("outgoing_transactions")) == 1 -def test_payment_double_submission(): - resp = assertResponse( - post( - f"{N}/bank-accounts/{NEXUS_BANK_LABEL}/payment-initiations", - json=dict( - iban="FR7630006000011234567890189", - bic="AGRIFRPP", - name="Jacques La Fayette", - subject="integration test", - amount="EUR:1", - ), - auth=NEXUS_AUTH - ) - ) - PAYMENT_UUID = resp.json().get("uuid") - assert PAYMENT_UUID - assertResponse( - post( - f"{N}/bank-accounts/{NEXUS_BANK_LABEL}/payment-initiations/{PAYMENT_UUID}/submit", - json=dict(), - auth=NEXUS_AUTH - ) - ) - check_call([ - "psql", "-d", DB, "-h 127.0.0.1", "-U", "libeufin", - f"UPDATE PaymentInitiations SET submitted = false WHERE id = '{PAYMENT_UUID}'" - ]) - # Submit payment the _second_ time, expecting 500 from Nexus. - # FIXME: - # Sandbox does return a EBICS_PROCESSING_ERROR code, but Nexus - # (currently) is not able to extract any meaning from it. Ideally, - # Nexus should print both the error token _and_ a hint message. - assertResponse( - post( - f"{N}/bank-accounts/{NEXUS_BANK_LABEL}/payment-initiations/{PAYMENT_UUID}/submit", - json=dict(), - auth=NEXUS_AUTH - ), - [500] - ) def test_double_connection_name(): assertResponse( diff --git a/integration-tests/util.py b/integration-tests/util.py @@ -61,7 +61,7 @@ def dropSandboxTables(dbConnString): "-q", "--console=plain", "-p", "..", "sandbox:run", - f"--args=drop-tables --db-conn-string={dbConnString}" + f"--args=reset-tables --db-conn-string={dbConnString}" ]) @@ -71,7 +71,7 @@ def dropNexusTables(dbConnString): "-q", "--console=plain", "-p", "..", "nexus:run", - f"--args=drop-tables --db-conn-string={dbConnString}" + f"--args=reset-tables --db-conn-string={dbConnString}" ]) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -72,10 +72,11 @@ class ParseCamt : CliktCommand("Parse a camt file") { } } -class DropTables : CliktCommand("Drop all the tables from the database") { +class ResetTables : CliktCommand("Drop all the tables from the database") { private val dbConnString by option().default(DEFAULT_DB_CONNECTION) override fun run() { dbDropTables(dbConnString) + dbCreateTables(dbConnString) } } @@ -106,6 +107,6 @@ class Superuser : CliktCommand("Add superuser or change pw") { fun main(args: Array<String>) { NexusCommand() - .subcommands(Serve(), Superuser(), ParseCamt(), DropTables()) + .subcommands(Serve(), Superuser(), ParseCamt(), ResetTables()) .main(args) } diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -90,10 +90,11 @@ class SandboxCommand : CliktCommand() { override fun run() = Unit } -class DropTables : CliktCommand("Drop all the tables from the database") { +class ResetTables : CliktCommand("Drop all the tables from the database") { private val dbConnString by option().default(DEFAULT_DB_CONNECTION) override fun run() { dbDropTables(dbConnString) + dbCreateTables(dbConnString) } } @@ -153,7 +154,7 @@ fun BigDecimal.signToString(): String { fun main(args: Array<String>) { SandboxCommand() - .subcommands(Serve(), DropTables()) + .subcommands(Serve(), ResetTables()) .main(args) }