gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 02/02: default demobank


From: gnunet
Subject: [libeufin] 02/02: default demobank
Date: Mon, 22 Nov 2021 20:39:04 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 322e52178c3bbdb9d21f8bcadf6a056502440b4a
Author: ms <ms@taler.net>
AuthorDate: Mon Nov 22 20:22:24 2021 +0100

    default demobank
    
    default demobank creation and default demobank
    own bank account moved inside the same function.
---
 .../main/kotlin/tech/libeufin/sandbox/Helpers.kt    |  9 +++++++++
 .../src/main/kotlin/tech/libeufin/sandbox/JSON.kt   | 16 ++++------------
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt   | 21 +++------------------
 3 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
index 5451ca25..29d93e4f 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -175,6 +175,15 @@ fun maybeCreateDefaultDemobank() {
                 allowRegistrations = true
                 name = "default"
             }
+            // Give one demobank a own bank account, mainly to award
+            // customer upon registration.
+            BankAccountEntity.new {
+                iban = getIban()
+                label = "bank" // used by the wire helper
+                owner = "bank" // used by the person name finder
+                // For now, the model assumes always one demobank
+                demoBank = getFirstDemobank()
+            }
         }
     }
 }
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
index e85e3fbb..a25503b8 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -57,7 +57,7 @@ data class AccountTransactions(
 )
 
 /**
- * Used to create AND show one Ebics subscriber in the system.
+ * Used to create AND show one Ebics subscriber.
  */
 data class EbicsSubscriberInfo(
     val hostID: String,
@@ -72,17 +72,9 @@ data class AdminGetSubscribers(
 )
 
 /**
- * Some obsolete code creates a bank account and after the
- * Ebics subscriber.  This doesn't allow to have bank accounts
- * without a subscriber associated to it.  Demobank should allow
- * this instead, because only one user - the exchange - will
- * ever need a Ebics subscription at the Sandbox.
- *
- * The code is obsoleted by a new endpoint that's defined within
- * the /demobanks/${demobankId} trunk.  This one allows to first create
- * a bank account, and only optionally later give a Ebics account to
- * it.
- */
+ * The following definition is obsolete because it
+ * doesn't allow to specify a demobank that will host
+ * the Ebics subscriber.  */
 data class EbicsSubscriberObsoleteApi(
     val hostID: String,
     val partnerID: String,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 04c99eba..5cdd8cd5 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -310,18 +310,6 @@ class Serve : CliktCommand("Run sandbox HTTP server") {
             )
             exitProcess(0)
         }
-        /**
-         * Create the bank's bank account, to award the 100 Kudos
-         * when new customers open bank account.  */
-        transaction {
-            BankAccountEntity.new {
-                iban = getIban()
-                label = "bank" // used by the wire helper
-                owner = "bank" // used by the person name finder
-                // For now, the model assumes always one demobank
-                demoBank = getFirstDemobank()
-            }
-        }
         serverMain(port)
     }
 }
@@ -1340,11 +1328,11 @@ val sandboxApp: Application.() -> Unit = {
             }
             route("/ebics") {
                 post("/subscribers") {
+                    // Only the admin can create Ebics subscribers.
                     val user = call.request.basicAuth()
+                    if (user != "admin") throw forbidden("Only the Admin can 
create Ebics subscribers.")
                     val body = call.receiveJson<EbicsSubscriberInfo>()
-                    /**
-                     * Create or get the Ebics subscriber that is found.
-                     */
+                    // Create or get the Ebics subscriber that is found.
                     transaction {
                         val subscriber: EbicsSubscriberEntity = 
EbicsSubscriberEntity.find {
                             (EbicsSubscribersTable.partnerId eq 
body.partnerID).and(
@@ -1362,9 +1350,6 @@ val sandboxApp: Application.() -> Unit = {
                             body.demobankAccountLabel,
                             ensureDemobank(call)
                         )
-                        if ((user != "admin") && (bankAccount.owner != user)) 
throw forbidden(
-                            "User ${bankAccount.owner} cannot access bank 
account '${bankAccount.label}'"
-                        )
                         subscriber.bankAccount = bankAccount
                     }
                     call.respond(object {})

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