commit e2fcf78f1b68c96ff4d7a5c021f547e0d85ee98e
parent 69e82424445fb39133ca8e4f71be6823c51399f6
Author: Antoine A <>
Date: Wed, 1 Nov 2023 13:06:57 +0000
Fix account creation and patching
Diffstat:
2 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
@@ -149,8 +149,6 @@ private fun Routing.coreBankAccountsMgmtApi(db: Database, ctx: BankConfig) {
"Username '${req.username}' is reserved.",
TalerErrorCode.BANK_RESERVED_USERNAME_CONFLICT
)
- if (req.is_taler_exchange && !isAdmin)
- throw forbidden("Only admin can create exchange accounts")
val internalPayto = req.internal_payto_uri ?: IbanPayTo(genIbanPaytoUri())
val result = db.accountCreate(
@@ -219,8 +217,6 @@ private fun Routing.coreBankAccountsMgmtApi(db: Database, ctx: BankConfig) {
if (req.is_taler_exchange != null && username == "admin")
throw forbidden("admin account cannot be an exchange")
- if (req.is_taler_exchange != null && !isAdmin)
- throw forbidden("non-admin user cannot change their exchange nature")
val res = db.accountReconfig(
login = username,
diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt b/bank/src/test/kotlin/CoreBankApiTest.kt
@@ -176,6 +176,7 @@ class CoreBankAccountsMgmtApiTest {
"name" to "Jane"
"is_public" to true
"internal_payto_uri" to ibanPayto
+ "is_taler_exchange" to true
}
// Check Ok
client.post("/accounts") {
@@ -206,20 +207,6 @@ class CoreBankAccountsMgmtApiTest {
}.assertConflict().assertErr(TalerErrorCode.BANK_RESERVED_USERNAME_CONFLICT)
}
- // Only admin can create exchange account
- val exchangeReq = json(req) {
- "username" to "better-exchange"
- "internal_payto_uri" to genIbanPaytoUri()
- "is_taler_exchange" to true
- }
- client.post("/accounts") {
- jsonBody(exchangeReq)
- }.assertForbidden()
- client.post("/accounts") {
- basicAuth("admin", "admin-password")
- jsonBody(exchangeReq)
- }.assertCreated()
-
// Testing login conflict
client.post("/accounts") {
jsonBody(json(req) {
@@ -365,6 +352,7 @@ class CoreBankAccountsMgmtApiTest {
"phone" to "+99"
"email" to "foo@example.com"
}
+ "is_taler_exchange" to true
}
client.patch("/accounts/merchant") {
basicAuth("merchant", "merchant-password")
@@ -390,7 +378,6 @@ class CoreBankAccountsMgmtApiTest {
}
checkAdminOnly(json(req) { "name" to "Another Foo" })
- checkAdminOnly(json(req) { "is_taler_exchange" to true })
checkAdminOnly(json(req) { "debit_threshold" to "KUDOS:100" })
// Check admin account cannot be exchange