gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: TWG: testing /history/outgoing and /tr


From: gnunet
Subject: [libeufin] branch master updated: TWG: testing /history/outgoing and /transfer.
Date: Mon, 13 Mar 2023 12:58:21 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 5678ec87 TWG: testing /history/outgoing and /transfer.
5678ec87 is described below

commit 5678ec87a3718c5a232372855280960be8504208
Author: MS <ms@taler.net>
AuthorDate: Mon Mar 13 12:57:40 2023 +0100

    TWG: testing /history/outgoing and /transfer.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt |  2 +-
 nexus/src/test/kotlin/TalerTest.kt                 | 63 ++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index 8f1d32f2..4b325def 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -464,7 +464,7 @@ private suspend fun historyOutgoing(call: ApplicationCall) {
                             subscriberBankAccount.bankCode,
                             subscriberBankAccount.accountHolder,
                         ),
-                        exchange_base_url = 
"FIXME-to-request-along-subscriber-registration"
+                        exchange_base_url = it.exchangeBaseUrl
                     )
                 )
             }
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

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]