libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit c9a3b09f2245ef48ee42c72aa61cd88e936b2f6a
parent 1ec8f2ccd12e69be71dd94a28427a61bda19c628
Author: ms <ms@taler.net>
Date:   Tue, 29 Jun 2021 12:40:30 +0200

drafting bank config table

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 21++++++++++++++++++++-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 10+++++-----
2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt @@ -22,10 +22,13 @@ package tech.libeufin.sandbox import org.jetbrains.exposed.dao.Entity import org.jetbrains.exposed.dao.EntityClass import org.jetbrains.exposed.dao.IntEntity +import org.jetbrains.exposed.dao.LongEntity import org.jetbrains.exposed.dao.IntEntityClass +import org.jetbrains.exposed.dao.LongEntityClass import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.IdTable import org.jetbrains.exposed.dao.id.IntIdTable +import org.jetbrains.exposed.dao.id.LongIdTable import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.transaction @@ -84,10 +87,26 @@ enum class KeyState { RELEASED } +object SandboxConfigsTable : LongIdTable() { + val currency = text("currency") + val allowRegistrations = bool("allowRegistrations") + val bankDebtLimit = integer("bankDebtLimit") + val usersDebtLimit = integer("usersDebtLimit") +} + +class SandboxConfigEntity(id: EntityID<Long>) : LongEntity(id) { + companion object : LongEntityClass<SandboxConfigEntity>(SandboxConfigsTable) + var currency by SandboxConfigsTable.currency + var allowRegistrations by SandboxConfigsTable.allowRegistrations + var bankDebtLimit by SandboxConfigsTable.bankDebtLimit + var usersDebtLimit by SandboxConfigsTable.usersDebtLimit +} + object SandboxUsersTable : LongIdTable() { val username = text("username") val passwordHash = text("password") val superuser = bool("superuser") // admin + val bankAccount = reference("bankAccout", BankAccountsTable) } class SandboxUserEntity(id: EntityID<Long>) : LongEntity(id) { @@ -95,6 +114,7 @@ class SandboxUserEntity(id: EntityID<Long>) : LongEntity(id) { var username by SandboxUsersTable.username var passwordHash by SandboxUsersTable.passwordHash var superuser by SandboxUsersTable.superuser + var bankAccount by BankAccountEntity referencedOn SandboxUsersTable.bankAccount } @@ -108,7 +128,6 @@ object EbicsSubscriberPublicKeysTable : IntIdTable() { class EbicsSubscriberPublicKeyEntity(id: EntityID<Int>) : IntEntity(id) { companion object : IntEntityClass<EbicsSubscriberPublicKeyEntity>(EbicsSubscriberPublicKeysTable) - var rsaPublicKey by EbicsSubscriberPublicKeysTable.rsaPublicKey var state by EbicsSubscriberPublicKeysTable.state } diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -331,9 +331,9 @@ fun serverMain(dbName: String, port: Int) { transaction { // check if username is taken. - val maybeUser = SandboxUserEntity.find( - SandboxUserTable.username eq username - ).firstOrNull() + var maybeUser = SandboxUserEntity.find { + SandboxUsersTable.username eq username + }.firstOrNull() // Will be converted to a HTML response. if (maybeUser != null) throw SandboxError( HttpStatusCode.Conflict, "Username not available" @@ -341,9 +341,9 @@ fun serverMain(dbName: String, port: Int) { // username is valid. Register the user + new bank account. SandboxUserEntity.new { - username = username + this.username = username passwordHash = CryptoUtil.hashpw(password) - superuser = false + this.superuser = superuser bankAccount = BankAccountEntity.new { iban = "fixme" bic = "fixme"