summaryrefslogtreecommitdiff
path: root/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-06-07 16:50:03 +0200
committerMS <ms@taler.net>2023-06-07 16:50:03 +0200
commit939840d0082588075ea68bb6c58562558e80e3dc (patch)
tree113e3563f55ff07c1dfdb7be7d3a8038a6cb5542 /sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
parenta05943bd4c442ede649de793e8f87a6768520dec (diff)
downloadlibeufin-939840d0082588075ea68bb6c58562558e80e3dc.tar.gz
libeufin-939840d0082588075ea68bb6c58562558e80e3dc.tar.bz2
libeufin-939840d0082588075ea68bb6c58562558e80e3dc.zip
Fixing tests.
Addressing libeufin-tutorial TypeScript test failure.
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt')
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt57
1 files changed, 17 insertions, 40 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index dfb20ffc..1f16da78 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -852,48 +852,25 @@ val sandboxApp: Application.() -> Unit = {
post("/admin/ebics/bank-accounts") {
call.request.basicAuth(onlyAdmin = true)
val body = call.receive<EbicsBankAccountRequest>()
- if (!validateBic(body.bic)) {
- throw SandboxError(HttpStatusCode.BadRequest, "invalid BIC (${body.bic})")
- }
- transaction {
- val subscriber = getEbicsSubscriberFromDetails(
- body.subscriber.userID,
- body.subscriber.partnerID,
- body.subscriber.hostID
- )
- if (subscriber.bankAccount != null)
- throw conflict("subscriber has already a bank account: ${subscriber.bankAccount?.label}")
- val demobank = getDefaultDemobank()
- // Forbid institutional names for bank account.
- if (body.label == "admin" || body.label == "bank") throw forbidden(
- "Requested bank account label '${body.label}' not allowed."
- )
+ val subscriber = getEbicsSubscriberFromDetails(
+ body.subscriber.userID,
+ body.subscriber.partnerID,
+ body.subscriber.hostID
+ )
+ val res = insertNewAccount(
+ username = body.label,
/**
- * Checking that the default demobank doesn't have already the
- * requested IBAN and bank account label.
+ * This value makes only happy the account creator helper.
+ * Logic using this OBSOLETE HTTP handler would NOT expect
+ * to use this password anyway. The reason is that such obsolete
+ * tests access their banking data always through the EBICS
+ * subscriber, needing therefore no HTTP basic password to operate.
*/
- val check = BankAccountEntity.find {
- BankAccountsTable.iban eq body.iban or (
- (BankAccountsTable.label eq body.label) and (
- BankAccountsTable.demoBank eq demobank.id
- )
- )
- }.count()
- if (check > 0) throw SandboxError(
- HttpStatusCode.BadRequest,
- "Either IBAN or account label were already taken; please choose fresh ones"
- )
- subscriber.bankAccount = BankAccountEntity.new {
- iban = body.iban
- bic = body.bic
- label = body.label
- /* Current version invariant:
- owner's username == bank account label. */
- owner = body.label
- demoBank = demobank
- }
- }
- call.respondText("Bank account created")
+ password = "not-used",
+ iban = body.iban
+ )
+ transaction { subscriber.bankAccount = res.bankAccount }
+ call.respond({})
return@post
}