[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 06/07: CLI command to configure the Sandbox
From: |
gnunet |
Subject: |
[libeufin] 06/07: CLI command to configure the Sandbox |
Date: |
Tue, 29 Jun 2021 15:59:17 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit 5b881469b7e92b39fc0d745ee48c43d4e533aeb9
Author: ms <ms@taler.net>
AuthorDate: Tue Jun 29 13:37:49 2021 +0200
CLI command to configure the Sandbox
---
.idea/libraries-with-intellij-classes.xml | 65 ++++++++++++++++++++++
.../src/main/kotlin/tech/libeufin/sandbox/DB.kt | 6 +-
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 43 +++++++++++++-
3 files changed, 112 insertions(+), 2 deletions(-)
diff --git a/.idea/libraries-with-intellij-classes.xml
b/.idea/libraries-with-intellij-classes.xml
new file mode 100644
index 0000000..9fa3156
--- /dev/null
+++ b/.idea/libraries-with-intellij-classes.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="libraries-with-intellij-classes">
+ <option name="intellijApiContainingLibraries">
+ <list>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="ideaIU" />
+ <option name="groupId" value="com.jetbrains.intellij.idea" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="ideaIU" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="ideaIC" />
+ <option name="groupId" value="com.jetbrains.intellij.idea" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="ideaIC" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="pycharmPY" />
+ <option name="groupId" value="com.jetbrains.intellij.pycharm" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="pycharmPY" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="pycharmPC" />
+ <option name="groupId" value="com.jetbrains.intellij.pycharm" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="pycharmPC" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="clion" />
+ <option name="groupId" value="com.jetbrains.intellij.clion" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="clion" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="riderRD" />
+ <option name="groupId" value="com.jetbrains.intellij.rider" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="riderRD" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="goland" />
+ <option name="groupId" value="com.jetbrains.intellij.goland" />
+ </LibraryCoordinatesState>
+ <LibraryCoordinatesState>
+ <option name="artifactId" value="goland" />
+ <option name="groupId" value="com.jetbrains" />
+ </LibraryCoordinatesState>
+ </list>
+ </option>
+ </component>
+</project>
\ No newline at end of file
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index a210163..9878790 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -362,7 +362,9 @@ fun dbDropTables(dbConnectionString: String) {
BankAccountTransactionsTable,
BankAccountsTable,
BankAccountReportsTable,
- BankAccountStatementsTable
+ BankAccountStatementsTable,
+ SandboxConfigsTable,
+ SandboxUsersTable
)
}
}
@@ -372,6 +374,8 @@ fun dbCreateTables(dbConnectionString: String) {
TransactionManager.manager.defaultIsolationLevel =
Connection.TRANSACTION_SERIALIZABLE
transaction {
SchemaUtils.create(
+ SandboxConfigsTable,
+ SandboxUsersTable,
EbicsSubscribersTable,
EbicsHostsTable,
EbicsDownloadTransactionsTable,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 2d024db..2f41e58 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -62,6 +62,7 @@ import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.output.CliktHelpFormatter
import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.versionOption
import com.github.ajalt.clikt.parameters.types.int
@@ -86,6 +87,7 @@ import
tech.libeufin.sandbox.BankAccountTransactionsTable.debtorIban
import tech.libeufin.sandbox.BankAccountTransactionsTable.debtorName
import tech.libeufin.sandbox.BankAccountTransactionsTable.direction
import tech.libeufin.sandbox.BankAccountTransactionsTable.pmtInfId
+import tech.libeufin.sandbox.SandboxConfigEntity
import tech.libeufin.util.*
import tech.libeufin.util.ebics_h004.EbicsResponse
import tech.libeufin.util.ebics_h004.EbicsTypes
@@ -102,6 +104,34 @@ data class SandboxError(val statusCode: HttpStatusCode,
val reason: String) : Ex
data class SandboxErrorJson(val error: SandboxErrorDetailJson)
data class SandboxErrorDetailJson(val type: String, val description: String)
+class Config : CliktCommand("Insert one configuration into the database") {
+ init {
+ context {
+ helpFormatter = CliktHelpFormatter(showDefaultValues = true)
+ }
+ }
+
+ private val currencyOption by option().default("EUR")
+ private val bankDebtLimitOption by option().int().default(1000000)
+ private val usersDebtLimitOption by option().int().default(1000)
+ private val allowRegistrationsOption by option().flag(default = true)
+
+ override fun run() {
+ val dbConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME)
+ execThrowableOrTerminate {
+ dbCreateTables(dbConnString)
+ transaction {
+ SandboxConfigEntity.new {
+ currency = currencyOption
+ bankDebtLimit = bankDebtLimitOption
+ usersDebtLimit = usersDebtLimitOption
+ allowRegistrations = allowRegistrationsOption
+ }
+ }
+ }
+ }
+}
+
class ResetTables : CliktCommand("Drop all the tables from the database") {
init {
context {
@@ -201,7 +231,7 @@ class SandboxCommand : CliktCommand(invokeWithoutSubcommand
= true, printHelpOnE
}
fun main(args: Array<String>) {
- SandboxCommand().subcommands(Serve(), ResetTables()).main(args)
+ SandboxCommand().subcommands(Serve(), ResetTables(), Config()).main(args)
}
suspend inline fun <reified T : Any> ApplicationCall.receiveJson(): T {
@@ -664,6 +694,17 @@ fun serverMain(dbName: String, port: Int) {
}
}
}
+ val configs = transaction {
+ SandboxConfigEntity.all().firstOrNull()
+ }
+ if (configs == null) {
+ logger.error("""
+ Sandbox cannot run without at least one configuration.
+ See "libeufin-sandbox config --help"
+ """.trimIndent()
+ )
+ exitProcess(1)
+ }
logger.info("LibEuFin Sandbox running on port $port")
try {
server.start(wait = true)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (62d0490 -> 786b70a), gnunet, 2021/06/29
- [libeufin] 05/07: drafting bank config table, gnunet, 2021/06/29
- [libeufin] 07/07: helper that returns a bank configuration, given the hostname., gnunet, 2021/06/29
- [libeufin] 06/07: CLI command to configure the Sandbox,
gnunet <=
- [libeufin] 01/07: DB: making Ebics subscriber point at bank accounts., gnunet, 2021/06/29
- [libeufin] 02/07: Commenting out Jinja initialization., gnunet, 2021/06/29
- [libeufin] 03/07: Jinja and form-auth experiments, gnunet, 2021/06/29
- [libeufin] 04/07: drafting user creation, gnunet, 2021/06/29