libeufin

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

commit 322e52178c3bbdb9d21f8bcadf6a056502440b4a
parent 6a1dc505c4c0af15b47f64fa752395af8239e9b5
Author: ms <ms@taler.net>
Date:   Mon, 22 Nov 2021 20:22:24 +0100

default demobank

default demobank creation and default demobank
own bank account moved inside the same function.

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt | 9+++++++++
Msandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt | 16++++------------
Msandbox/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 @@ -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 @@ -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 @@ -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 {})