gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (07f6ac85 -> 2f4ac08b)


From: gnunet
Subject: [libeufin] branch master updated (07f6ac85 -> 2f4ac08b)
Date: Tue, 06 Feb 2024 15:10:49 +0100

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

antoine pushed a change to branch master
in repository libeufin.

    from 07f6ac85 -initialize variable in script
     new cbdb013d More payto uri check on account creation
     new 2f4ac08b Use libeufin-nexus-postgres for libeufin-nexus db config

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/kotlin/tech/libeufin/bank/CoreBankApi.kt    | 10 ++++++++++
 bank/src/test/kotlin/CoreBankApiTest.kt              |  9 +++++++++
 bank/src/test/kotlin/PaytoTest.kt                    | 20 +++++++++++++++++++-
 contrib/nexus.conf                                   |  7 ++++---
 nexus/conf/test.conf                                 |  2 +-
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt    |  2 +-
 testbench/conf/integration.conf                      |  2 +-
 testbench/conf/mini.conf                             |  3 +++
 testbench/src/main/kotlin/Main.kt                    |  2 +-
 9 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
index 7007eb80..0914222e 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
@@ -188,6 +188,8 @@ suspend fun createAccount(
 
     when (cfg.wireMethod) {
         WireMethod.IBAN -> {
+            if (req.payto_uri != null && !(req.payto_uri is IbanPayto))
+                throw badRequest("Expected an IBAN payto uri")
             var retry = if (req.payto_uri == null) 
IBAN_ALLOCATION_RETRY_COUNTER else 0
 
             while (true) {
@@ -217,7 +219,15 @@ suspend fun createAccount(
             }
         }
         WireMethod.X_TALER_BANK -> {
+            if (req.payto_uri != null) {
+                if (!(req.payto_uri is XTalerBankPayto))
+                    throw badRequest("Expected an IBAN payto uri")
+                else if (req.payto_uri.username != req.username)
+                    throw badRequest("Expected a payto uri for 
'${req.username}' got one for 'req.payto_uri.username'")
+            }
+         
             val internalPayto = XTalerBankPayto.forUsername(req.username)
+        
             val res = db.account.create(
                 login = req.username,
                 name = req.name,
diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt 
b/bank/src/test/kotlin/CoreBankApiTest.kt
index 1e087a05..4dda7872 100644
--- a/bank/src/test/kotlin/CoreBankApiTest.kt
+++ b/bank/src/test/kotlin/CoreBankApiTest.kt
@@ -296,6 +296,15 @@ class CoreBankAccountsApiTest {
         client.get("/accounts/bar") {
             pwAuth("admin")
         }.assertNotFound(TalerErrorCode.BANK_UNKNOWN_ACCOUNT)
+        // Testing bad payto kind
+        client.post("/accounts") {
+            json(req) {
+                "username" to "bar"
+                "password" to "bar-password"
+                "name" to "Mr Bar"
+                "payto_uri" to "payto://x-taler-bank/bank.hostname.test/bar"
+            }
+        }.assertBadRequest()
 
         // Check cashout payto receiver name logic
         client.post("/accounts") {
diff --git a/bank/src/test/kotlin/PaytoTest.kt 
b/bank/src/test/kotlin/PaytoTest.kt
index 635d864f..a5211194 100644
--- a/bank/src/test/kotlin/PaytoTest.kt
+++ b/bank/src/test/kotlin/PaytoTest.kt
@@ -45,7 +45,7 @@ class PaytoTest {
             
assertEquals("payto://x-taler-bank/bank.hostname.test/john?receiver-name=John", 
it.internal_payto_uri)
         }
 
-        // Check payto_uri is ignored
+        // Bad IBAN payto
         client.post("/accounts") {
             json {
                 "username" to "foo"
@@ -53,6 +53,24 @@ class PaytoTest {
                 "name" to "Jane"
                 "payto_uri" to IbanPayto.rand()
             }
+        }.assertBadRequest()
+        // Bad payto username
+        client.post("/accounts") {
+            json {
+                "username" to "foo"
+                "password" to "foo-password"
+                "name" to "Jane"
+                "payto_uri" to 
"payto://x-taler-bank/bank.hostname.test/not-foo"
+            }
+        }.assertBadRequest()
+        // Check Ok
+        client.post("/accounts") {
+            json {
+                "username" to "foo"
+                "password" to "foo-password"
+                "name" to "Jane"
+                "payto_uri" to "payto://x-taler-bank/bank.hostname.test/foo"
+            }
         }.assertOkJson<RegisterAccountResponse> {
             
assertEquals("payto://x-taler-bank/bank.hostname.test/foo?receiver-name=Jane", 
it.internal_payto_uri)
         }
diff --git a/contrib/nexus.conf b/contrib/nexus.conf
index 58caad34..3854ad55 100644
--- a/contrib/nexus.conf
+++ b/contrib/nexus.conf
@@ -35,12 +35,13 @@ CLIENT_PRIVATE_KEYS_FILE = 
${LIBEUFIN_NEXUS_HOME}/client-ebics-keys.json
 # Typically, it is named after the bank itself.
 BANK_DIALECT = postfinance
 
-[nexus-postgres]
-CONFIG = postgres:///libeufin
-
 [libeufin-nexusdb-postgres]
+# Where are the SQL files to setup our tables?
 SQL_DIR = $DATADIR/sql/
 
+# DB connection string
+CONFIG = postgres:///libeufin
+
 [nexus-fetch]
 FREQUENCY = 30m
 
diff --git a/nexus/conf/test.conf b/nexus/conf/test.conf
index 0235dde1..db408af1 100644
--- a/nexus/conf/test.conf
+++ b/nexus/conf/test.conf
@@ -9,5 +9,5 @@ HOST_ID = PFEBICS
 USER_ID = PFC00563
 PARTNER_ID = PFC00563
 
-[nexus-postgres]
+[libeufin-nexusdb-postgres]
 CONFIG = postgres:///libeufincheck
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index d4fd1a99..55d44734 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -209,7 +209,7 @@ fun loadConfig(configFile: Path?): TalerConfig = 
NEXUS_CONFIG_SOURCE.fromFile(co
  */
 fun TalerConfig.dbConfig(): DatabaseConfig =
     DatabaseConfig(
-        dbConnStr = requireString("nexus-postgres", "config"),
+        dbConnStr = lookupString("libeufin-nexusdb-postgres", "config") ?: 
requireString("nexus-postgres", "config"),
         sqlDir = requirePath("libeufin-nexusdb-postgres", "sql_dir")
     )
 
diff --git a/testbench/conf/integration.conf b/testbench/conf/integration.conf
index 39056996..29e7ccf4 100644
--- a/testbench/conf/integration.conf
+++ b/testbench/conf/integration.conf
@@ -13,5 +13,5 @@ CONFIG = postgresql:///libeufincheck
 [nexus-ebics]
 currency = EUR
 
-[nexus-postgres]
+[libeufin-bankdb-postgres]
 CONFIG = postgres:///libeufincheck
diff --git a/testbench/conf/mini.conf b/testbench/conf/mini.conf
index 5244dae2..4c5e3a10 100644
--- a/testbench/conf/mini.conf
+++ b/testbench/conf/mini.conf
@@ -1,2 +1,5 @@
 [libeufin-bankdb-postgres]
+CONFIG = postgresql:///libeufincheck
+
+[libeufin-nexusdb-postgres]
 CONFIG = postgresql:///libeufincheck
\ No newline at end of file
diff --git a/testbench/src/main/kotlin/Main.kt 
b/testbench/src/main/kotlin/Main.kt
index de98d2ab..a92e7ad4 100644
--- a/testbench/src/main/kotlin/Main.kt
+++ b/testbench/src/main/kotlin/Main.kt
@@ -92,7 +92,7 @@ class Cli : CliktCommand("Run integration tests on banks 
provider") {
         [nexus-submit]
         FREQUENCY = 5s
 
-        [nexus-postgres]
+        [libeufin-nexusdb-postgres]
         CONFIG = postgres:///libeufincheck
         """)
         val cfg = loadConfig(conf)

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