[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: GET /public-accounts
From: |
gnunet |
Subject: |
[libeufin] branch master updated: GET /public-accounts |
Date: |
Tue, 03 Oct 2023 12:09:48 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 17e0d54a GET /public-accounts
17e0d54a is described below
commit 17e0d54abad446fa252542c1d319072e16719a88
Author: MS <ms@taler.net>
AuthorDate: Tue Oct 3 12:09:32 2023 +0200
GET /public-accounts
---
.../main/kotlin/tech/libeufin/bank/BankMessages.kt | 2 +-
.../tech/libeufin/bank/CorebankApiHandlers.kt | 14 ++++++++-
bank/src/test/kotlin/LibeuFinApiTest.kt | 36 ++++++++++++++++++++++
contrib/wallet-core | 2 +-
4 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
index b9cd2998..01f4da66 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
@@ -655,7 +655,7 @@ data class TransferResponse(
*/
@Serializable
data class PublicAccountsResponse(
- val public_accounts: MutableList<PublicAccount>
+ val public_accounts: MutableList<PublicAccount> = mutableListOf()
)
@Serializable
data class PublicAccount(
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
b/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
index 00ac2dde..130609bf 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/CorebankApiHandlers.kt
@@ -222,7 +222,19 @@ fun Routing.accountsMgmtHandlers(db: Database, ctx:
BankApplicationContext) {
}
get("/public-accounts") {
// no authentication here.
- // val publicAccounts = db.accountsGetPublic()
+ val publicAccounts = db.accountsGetPublic(ctx.currency)
+ if (publicAccounts.isEmpty()) {
+ call.respond(HttpStatusCode.NoContent)
+ return@get
+ }
+ call.respond(
+ PublicAccountsResponse().apply {
+ publicAccounts.forEach {
+ this.public_accounts.add(it)
+ }
+ }
+ )
+ return@get
}
get("/accounts") {
val c = call.authenticateBankRequest(db, TokenScope.readonly) ?: throw
unauthorized()
diff --git a/bank/src/test/kotlin/LibeuFinApiTest.kt
b/bank/src/test/kotlin/LibeuFinApiTest.kt
index a66bd062..05deba30 100644
--- a/bank/src/test/kotlin/LibeuFinApiTest.kt
+++ b/bank/src/test/kotlin/LibeuFinApiTest.kt
@@ -2,6 +2,7 @@ import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
+import io.ktor.http.content.*
import io.ktor.server.engine.*
import io.ktor.server.testing.*
import kotlinx.serialization.decodeFromString
@@ -230,6 +231,41 @@ class LibeuFinApiTest {
}
}
+ @Test
+ fun publicAccountsTest() {
+ val db = initDb()
+ val ctx = getTestContext()
+ testApplication {
+ application {
+ corebankWebApp(db, ctx)
+ }
+ client.get("/public-accounts").apply {
+ assert(this.status == HttpStatusCode.NoContent)
+ }
+ // Make one public account.
+ db.customerCreate(customerBar).apply {
+ assert(this != null)
+ assert(
+ db.bankAccountCreate(
+ BankAccount(
+ isPublic = true,
+ internalPaytoUri = "payto://iban/non-used",
+ lastNexusFetchRowId = 1L,
+ owningCustomerId = this!!,
+ hasDebt = false,
+ maxDebt = TalerAmount(10, 1, "KUDOS")
+ )
+ ) != null
+ )
+ }
+ client.get("/public-accounts").apply {
+ assert(this.status == HttpStatusCode.OK)
+ val obj =
Json.decodeFromString<PublicAccountsResponse>(this.bodyAsText())
+ assert(obj.public_accounts.size == 1)
+ assert(obj.public_accounts[0].account_name == "bar")
+ }
+ }
+ }
// Creating token with "forever" duration.
@Test
fun tokenForeverTest() {
diff --git a/contrib/wallet-core b/contrib/wallet-core
index 1b5df6f0..c5a3cd4c 160000
--- a/contrib/wallet-core
+++ b/contrib/wallet-core
@@ -1 +1 @@
-Subproject commit 1b5df6f037a8d9e93a96e4c83f7e628023e4cd90
+Subproject commit c5a3cd4c50676c49fa6c67cbdeb609101c38e764
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: GET /public-accounts,
gnunet <=