diff options
author | MS <ms@taler.net> | 2023-03-10 17:24:18 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2023-03-10 17:24:18 +0100 |
commit | 26d382d720350498db742cd27ed65ae90596af8e (patch) | |
tree | e625c30334132d764834844471491eb7f1c72854 | |
parent | 1eec7fe3e346755731ccc69d6a7d4f7fd09f187b (diff) | |
download | libeufin-26d382d720350498db742cd27ed65ae90596af8e.tar.gz libeufin-26d382d720350498db742cd27ed65ae90596af8e.tar.bz2 libeufin-26d382d720350498db742cd27ed65ae90596af8e.zip |
Introducing TWG tests.
-rw-r--r-- | nexus/build.gradle | 4 | ||||
-rw-r--r-- | nexus/src/test/kotlin/MakeEnv.kt | 36 | ||||
-rw-r--r-- | nexus/src/test/kotlin/TalerTest.kt | 42 |
3 files changed, 60 insertions, 22 deletions
diff --git a/nexus/build.gradle b/nexus/build.gradle index dafe94c6..39e896c5 100644 --- a/nexus/build.gradle +++ b/nexus/build.gradle @@ -105,6 +105,10 @@ test { testLogging.showStandardStreams = false environment.put("LIBEUFIN_SANDBOX_ADMIN_PASSWORD", "foo") environment.put("LIBEUFIN_CASHOUT_TEST_TAN", "foo") + environment.put( + "LIBEUFIN_NEXUS_DB_CONNECTION", + "jdbc:postgresql://localhost:5432/libeufincheck?user=${System.properties["user.name"]}" + ) } application { diff --git a/nexus/src/test/kotlin/MakeEnv.kt b/nexus/src/test/kotlin/MakeEnv.kt index 8d391151..31cc5704 100644 --- a/nexus/src/test/kotlin/MakeEnv.kt +++ b/nexus/src/test/kotlin/MakeEnv.kt @@ -25,7 +25,8 @@ data class EbicsKeys( const val TEST_DB_FILE = "/tmp/nexus-test.sqlite3" // const val TEST_DB_CONN = "jdbc:sqlite:$TEST_DB_FILE" // Convenience DB connection to switch to Postgresql: -const val TEST_DB_CONN = "jdbc:postgresql://localhost:5432/talercheck?user=job" +val currentUser = System.getProperty("user.name") +val TEST_DB_CONN = "jdbc:postgresql://localhost:5432/libeufincheck?user=$currentUser" val BANK_IBAN = getIban() val FOO_USER_IBAN = getIban() val BAR_USER_IBAN = getIban() @@ -296,7 +297,7 @@ fun withSandboxTestDatabase(f: () -> Unit) { } } -fun talerIncomingForFoo(currency: String, value: String, subject: String) { +fun newNexusBankTransaction(currency: String, value: String, subject: String) { transaction { val inc = NexusBankTransactionEntity.new { bankAccount = NexusBankAccountEntity.findByName("foo")!! @@ -314,12 +315,12 @@ fun talerIncomingForFoo(currency: String, value: String, subject: String) { ) ) } - TalerIncomingPaymentEntity.new { + /*TalerIncomingPaymentEntity.new { payment = inc reservePublicKey = "mock" timestampMs = 0L debtorPaytoUri = "mock" - } + }*/ } } @@ -350,9 +351,30 @@ fun genNexusIncomingPayment( creditDebitIndicator = CreditDebitIndicator.CRDT, details = TransactionDetails( unstructuredRemittanceInformation = subject, - debtor = null, - debtorAccount = null, - debtorAgent = null, + debtor = PartyIdentification( + name = "Mock Payer", + countryOfResidence = null, + privateId = null, + organizationId = null, + postalAddress = null, + otherId = null + ), + debtorAccount = CashAccount( + iban = "MOCK-IBAN", + name = null, + currency = null, + otherId = null + ), + debtorAgent = AgentIdentification( + bic = "MOCK-BIC", + lei = null, + clearingSystemMemberId = null, + clearingSystemCode = null, + proprietaryClearingSystemCode = null, + postalAddress = null, + otherId = null, + name = null + ), creditor = null, creditorAccount = null, creditorAgent = null, diff --git a/nexus/src/test/kotlin/TalerTest.kt b/nexus/src/test/kotlin/TalerTest.kt index 36c656f1..7eadeb25 100644 --- a/nexus/src/test/kotlin/TalerTest.kt +++ b/nexus/src/test/kotlin/TalerTest.kt @@ -1,45 +1,57 @@ -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.databind.ObjectMapper +import io.ktor.client.call.* import io.ktor.client.plugins.* import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.server.testing.* import kotlinx.coroutines.* -import kotlinx.coroutines.future.future -import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.transaction import org.junit.Ignore import org.junit.Test -import tech.libeufin.nexus.* import tech.libeufin.nexus.bankaccount.fetchBankAccountTransactions -import tech.libeufin.nexus.iso20022.EntryStatus +import tech.libeufin.nexus.ingestFacadeTransactions +import tech.libeufin.nexus.maybeTalerRefunds import tech.libeufin.nexus.server.* +import tech.libeufin.nexus.talerFilter import tech.libeufin.sandbox.sandboxApp import tech.libeufin.sandbox.wireTransfer +import tech.libeufin.util.NotificationsChannelDomains // This class tests the features related to the Taler facade. class TalerTest { + val mapper = ObjectMapper() - /** - * Tests that a client (normally represented by the wire-watch) - * gets incoming transactions. - */ + // Checking that a correct wire transfer (with Taler-compatible subject) + // is responded by the Taler facade. @Test fun historyIncomingTest() { + val reservePub = "GX5H5RME193FDRCM1HZKERXXQ2K21KH7788CKQM8X6MYKYRBP8F0" withNexusAndSandboxUser { testApplication { application(nexusApp) runBlocking { - val future = async { - client.get( - "/facades/taler/taler-wire-gateway/history/incoming?delta=5" - ) { - expectSuccess = true + launch { + val r = client.get("/facades/taler/taler-wire-gateway/history/incoming?delta=5") { + expectSuccess = false contentType(ContentType.Application.Json) basicAuth("foo", "foo") } + val j = mapper.readTree(r.readBytes()) + val reservePubFromTwg = j.get("incoming_transactions").get(0).get("reserve_pub").asText() + assert(reservePubFromTwg == reservePub) } - talerIncomingForFoo("KUDOS", "10", "Invalid") + newNexusBankTransaction( + "KUDOS", + "10", + reservePub + ) + ingestFacadeTransactions( + "foo", // bank account local to Nexus. + "taler-wire-gateway", + ::talerFilter, + ::maybeTalerRefunds + ) } } } |