summaryrefslogtreecommitdiff
path: root/nexus/src/test/kotlin/TalerTest.kt
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-03-13 12:57:40 +0100
committerMS <ms@taler.net>2023-03-13 12:57:40 +0100
commit5678ec87a3718c5a232372855280960be8504208 (patch)
tree6dd3bce3898c859a022161796f23f57234333e9b /nexus/src/test/kotlin/TalerTest.kt
parentb585b1bc588b1e4599d03f8bfecf11471aa6b258 (diff)
downloadlibeufin-5678ec87a3718c5a232372855280960be8504208.tar.gz
libeufin-5678ec87a3718c5a232372855280960be8504208.tar.bz2
libeufin-5678ec87a3718c5a232372855280960be8504208.zip
TWG: testing /history/outgoing and /transfer.
Diffstat (limited to 'nexus/src/test/kotlin/TalerTest.kt')
-rw-r--r--nexus/src/test/kotlin/TalerTest.kt63
1 files changed, 63 insertions, 0 deletions
diff --git a/nexus/src/test/kotlin/TalerTest.kt b/nexus/src/test/kotlin/TalerTest.kt
index 22493606..c433284a 100644
--- a/nexus/src/test/kotlin/TalerTest.kt
+++ b/nexus/src/test/kotlin/TalerTest.kt
@@ -10,6 +10,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
import org.junit.Ignore
import org.junit.Test
import tech.libeufin.nexus.bankaccount.fetchBankAccountTransactions
+import tech.libeufin.nexus.bankaccount.submitAllPaymentInitiations
import tech.libeufin.nexus.ingestFacadeTransactions
import tech.libeufin.nexus.maybeTalerRefunds
import tech.libeufin.nexus.server.*
@@ -22,6 +23,68 @@ import tech.libeufin.util.NotificationsChannelDomains
class TalerTest {
val mapper = ObjectMapper()
+ // Checking that a call to POST /transfer results in
+ // an outgoing payment in GET /history/outgoing.
+ @Test
+ fun historyOutgoingTest() {
+ withNexusAndSandboxUser {
+ testApplication {
+ application(nexusApp)
+ client.post("/facades/taler/taler-wire-gateway/transfer") {
+ contentType(ContentType.Application.Json)
+ basicAuth("foo", "foo") // exchange's credentials
+ expectSuccess = true
+ setBody("""
+ { "request_uid": "twg_transfer_0",
+ "amount": "TESTKUDOS:3",
+ "exchange_base_url": "http://exchange.example.com/",
+ "wtid": "T0",
+ "credit_account": "payto://iban/${BAR_USER_IBAN}?receiver-name=Bar"
+
+ }
+ """.trimIndent())
+ }
+ }
+ /* The EBICS layer sends the payment instruction to the bank here.
+ * and the reconciliation mechanism in Nexus should detect that one
+ * outgoing payment was indeed the one instructed via the TWG. The
+ * reconciliation will make the outgoing payment visible via /history/outgoing.
+ * The following block achieve this by starting Sandbox and sending all
+ * the prepared payments to it.
+ */
+ testApplication {
+ application(sandboxApp)
+ submitAllPaymentInitiations(client, "foo")
+ /* Now downloads transactions from the bank, where the payment
+ submitted in the previous block is expected to appear as outgoing.
+ */
+ fetchBankAccountTransactions(
+ client,
+ fetchSpec = FetchSpecAllJson(
+ level = FetchLevel.REPORT,
+ "foo"
+ ),
+ "foo"
+ )
+ }
+ /**
+ * Now Nexus starts again, in order to serve /history/outgoing
+ * along the TWG.
+ */
+ testApplication {
+ application(nexusApp)
+ val r = client.get("/facades/taler/taler-wire-gateway/history/outgoing?delta=5") {
+ expectSuccess = true
+ contentType(ContentType.Application.Json)
+ basicAuth("foo", "foo")
+ }
+ val j = mapper.readTree(r.readBytes())
+ val wtidFromTwg = j.get("outgoing_transactions").get(0).get("wtid").asText()
+ assert(wtidFromTwg == "T0")
+ }
+ }
+ }
+
// Checking that a correct wire transfer (with Taler-compatible subject)
// is responded by the Taler facade.
@Test