gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/07: Make registrations optional.


From: gnunet
Subject: [libeufin] 01/07: Make registrations optional.
Date: Tue, 10 May 2022 12:41:27 +0200

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

ms pushed a commit to branch master
in repository libeufin.

commit e4746ba6a85dc2b0f05b76ea7b2542ac4a87fe5a
Author: ms <ms@taler.net>
AuthorDate: Thu May 5 13:44:47 2022 +0200

    Make registrations optional.
    
    That requires to override the --allow-registrations flag
    (to be given along the --override flag) passed to the default
    demobank, and the injection of a new LIBEUFIN_UI_ALLOW_REGISTRATIONS
    value to the SPA.
---
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 26 +++++++++++++++++++---
 sandbox/src/test/kotlin/StringsTest.kt             |  6 +++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 4311ab9a..c205bb3d 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -136,6 +136,9 @@ class Config : CliktCommand(
     private val nameArgument by argument(
         "NAME", help = "Name of this configuration"
     )
+    private val overrideOption by option(
+        "--override", help = "Override an existing demobank."
+    ).flag("--no-override", default = false)
     private val currencyOption by option("--currency").default("EUR")
     private val bankDebtLimitOption by 
option("--bank-debt-limit").int().default(1000000)
     private val usersDebtLimitOption by 
option("--users-debt-limit").int().default(1000)
@@ -153,10 +156,18 @@ class Config : CliktCommand(
         execThrowableOrTerminate {
             dbCreateTables(dbConnString)
             transaction {
-                val checkExist = DemobankConfigEntity.find {
+                val maybeDemobank = DemobankConfigEntity.find {
                     DemobankConfigsTable.name eq nameArgument
                 }.firstOrNull()
-                if (checkExist != null) {
+                if (maybeDemobank != null) {
+                    if (overrideOption) {
+                        maybeDemobank.currency = currencyOption
+                        maybeDemobank.bankDebtLimit = bankDebtLimitOption
+                        maybeDemobank.usersDebtLimit = usersDebtLimitOption
+                        maybeDemobank.allowRegistrations = 
allowRegistrationsOption
+                        maybeDemobank.withSignupBonus = withSignupBonusOption
+                        return@transaction
+                    }
                     println("Error, demobank ${nameArgument} exists already, 
not overriding it.")
                     exitProcess(1)
                 }
@@ -1006,7 +1017,10 @@ val sandboxApp: Application.() -> Unit = {
                 val surveyUrl = System.getenv(
                     "TALER_ENV_URL_MERCHANT_SURVEY") ?: 
"https://demo.taler.net/survey/";
                 content = content.replace("%DEMO_SITE_SURVEY_URL%", surveyUrl)
-                logger.debug("after links replacement + $content")
+                content = content.replace(
+                    "%LIBEUFIN_UI_ALLOW_REGISTRATIONS%",
+                    demobank.allowRegistrations.toString()
+                )
                 call.respondText(content, ContentType.Text.Html)
                 return@get
             }
@@ -1415,6 +1429,12 @@ val sandboxApp: Application.() -> Unit = {
                 post("/testing/register") {
                     // Check demobank was created.
                     val demobank = ensureDemobank(call)
+                    if (!demobank.allowRegistrations) {
+                        throw SandboxError(
+                            HttpStatusCode.UnprocessableEntity,
+                            "The bank doesn't allow new registrations at the 
moment."
+                        )
+                    }
                     val req = call.receiveJson<CustomerRegistration>()
                     val checkExist = transaction {
                         DemobankCustomerEntity.find {
diff --git a/sandbox/src/test/kotlin/StringsTest.kt 
b/sandbox/src/test/kotlin/StringsTest.kt
index eaec275b..36503f6c 100644
--- a/sandbox/src/test/kotlin/StringsTest.kt
+++ b/sandbox/src/test/kotlin/StringsTest.kt
@@ -19,4 +19,10 @@ class StringsTest {
         )
         println(content)
     }
+
+    @Test
+    fun booleanToString() {
+        assert(true.toString() == "true")
+        assert(false.toString() == "false")
+    }
 }
\ No newline at end of file

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