gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: TWG POST /transfer, handling wrong cur


From: gnunet
Subject: [libeufin] branch master updated: TWG POST /transfer, handling wrong currency.
Date: Thu, 21 Sep 2023 22:05:23 +0200

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 de07e380 TWG POST /transfer, handling wrong currency.
de07e380 is described below

commit de07e380ac52dc162f9844a730b3a8aff61267ae
Author: MS <ms@taler.net>
AuthorDate: Thu Sep 21 22:03:32 2023 +0200

    TWG POST /transfer, handling wrong currency.
---
 .../tech/libeufin/bank/talerWireGatewayHandlers.kt      |  4 ++++
 bank/src/test/kotlin/TalerApiTest.kt                    | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git 
a/bank/src/main/kotlin/tech/libeufin/bank/talerWireGatewayHandlers.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/talerWireGatewayHandlers.kt
index 55a97c24..5a821493 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/talerWireGatewayHandlers.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/talerWireGatewayHandlers.kt
@@ -93,6 +93,10 @@ fun Routing.talerWireGatewayHandlers() {
             )
         }
         // Legitimate request, go on.
+        val internalCurrency = db.configGet("internal_currency")
+            ?: throw internalServerError("Bank did not find own internal 
currency.")
+        if (internalCurrency != req.amount.currency)
+            throw badRequest("Currency mismatch: $internalCurrency vs 
${req.amount.currency}")
         val exchangeBankAccount = db.bankAccountGetFromOwnerId(c.expectRowId())
             ?: throw internalServerError("Exchange does not have a bank 
account")
         val transferTimestamp = getNowUs()
diff --git a/bank/src/test/kotlin/TalerApiTest.kt 
b/bank/src/test/kotlin/TalerApiTest.kt
index 5d53ff6d..ab1bf1df 100644
--- a/bank/src/test/kotlin/TalerApiTest.kt
+++ b/bank/src/test/kotlin/TalerApiTest.kt
@@ -101,6 +101,23 @@ class TalerApiTest {
                 """.trimIndent())
             }
             assert(r.status == HttpStatusCode.Conflict)
+            /* Triggering currency mismatch.  This mainly tests
+             * the TalerAmount "@Contextual" parser.  */
+            val currencyMismatchResp = 
client.post("/accounts/foo/taler-wire-gateway/transfer") {
+                basicAuth("foo", "pw")
+                contentType(ContentType.Application.Json)
+                expectSuccess = false
+                setBody("""
+                    {
+                      "request_uid": "entropic 3",
+                      "wtid": "entropic 4",
+                      "exchange_base_url": 
"http://different-exchange.example.com/";,
+                      "amount": "EUR:33",
+                      "credit_account": "BAR-IBAN-ABC"
+                    }
+                """.trimIndent())
+            }
+            assert(currencyMismatchResp.status == HttpStatusCode.BadRequest)
         }
     }
     // Testing the /history/incoming call from the TWG API.

-- 
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]