[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 04/08: Fixes after wallet tests harness.
From: |
gnunet |
Subject: |
[libeufin] 04/08: Fixes after wallet tests harness. |
Date: |
Wed, 10 Nov 2021 16:22:47 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit f255d6889b39eafb1ac4c951a78937fc189e8d25
Author: ms <ms@taler.net>
AuthorDate: Sat Nov 6 09:27:42 2021 +0100
Fixes after wallet tests harness.
- fix taler-uri generation
- put /config within the integration-api trunk.
---
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 60 +++++++++++++---------
1 file changed, 36 insertions(+), 24 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 9b5d4c5a..ca6ce8e9 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -951,20 +951,6 @@ val sandboxApp: Application.() -> Unit = {
return@post
}
- get("/api/config") {
- SandboxAssert(
- currencyEnv != null,
- "Currency not found. Logs should have warned"
- )
- call.respond(object {
- val name = "taler-bank-integration"
-
- // FIXME: use actual version here!
- val version = "0:0:0"
- val currency = currencyEnv
- })
- }
-
// Create a new demobank instance with a particular currency,
// debt limit and possibly other configuration
// (could also be a CLI command for now)
@@ -1000,7 +986,18 @@ val sandboxApp: Application.() -> Unit = {
// Talk to wallets.
route("/integration-api") {
- post("/api/withdrawal-operation/{wopid}") {
+
+ get("/config") {
+ val demobank = ensureDemobank(call)
+ call.respond(object {
+ val name = "taler-bank-integration"
+ // FIXME: avoid hard-coding the version!
+ val version = "0:0:0"
+ val currency = demobank.currency
+ })
+ return@get
+ }
+ post("/withdrawal-operation/{wopid}") {
val wopid: String = ensureNonNull(call.parameters["wopid"])
val body = call.receiveJson<TalerWithdrawalSelection>()
val transferDone = newSuspendedTransaction(context =
singleThreadContext) {
@@ -1048,7 +1045,7 @@ val sandboxApp: Application.() -> Unit = {
val ret = TalerWithdrawalStatus(
selection_done = wo.selectionDone,
transfer_done = wo.confirmationDone,
- amount = wo.amount,
+ amount = "${demobank.currency}:${wo.amount}",
suggested_exchange = demobank.suggestedExchange
)
call.respond(ret)
@@ -1086,8 +1083,7 @@ val sandboxApp: Application.() -> Unit = {
/**
* Check here if the user has the right over the claimed
bank account. After
* this check, the withdrawal operation will be allowed
only by providing its
- * UID.
- */
+ * UID. */
val maybeOwnedAccount = getBankAccountFromLabel(
call.getUriComponent("account_name"),
demobank
@@ -1101,21 +1097,37 @@ val sandboxApp: Application.() -> Unit = {
if (amount.currency != demobank.currency) throw badRequest(
"Currency ${amount.currency} differs from Demobank's:
${demobank.currency}"
)
- val wo: TalerWithdrawalEntity = transaction {
TalerWithdrawalEntity.new {
+ val wo: TalerWithdrawalEntity = transaction {
+ TalerWithdrawalEntity.new {
this.amount = amount.amount.toPlainString()
walletBankAccount = maybeOwnedAccount
- } }
+ }
+ }
val baseUrl = URL(call.request.getBaseUrl())
- val withdrawUri = call.url {
+ val withdrawUri = url {
protocol = URLProtocol(
"taler".plus(if (baseUrl.protocol.lowercase() ==
"http") "+http" else ""),
-1
)
- pathComponents(baseUrl.path, wo.wopid.toString())
- encodedPath += "/"
+ host = "withdraw"
+ pathComponents(
+ /**
+ * encodes the hostname(+port) of the actual
+ * bank that will serve the withdrawal request.
+ */
+ baseUrl.host.plus(
+ if (baseUrl.port != -1)
+ ":${baseUrl.port}"
+ else ""
+ ),
+ "demobanks",
+ demobank.name,
+ "integration-api",
+ wo.wopid.toString()
+ )
}
call.respond(object {
- val withdrawal_id = wo.id.value.toString()
+ val withdrawal_id = wo.wopid.toString()
val taler_withdraw_uri = withdrawUri
})
return@post
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (a6661dff -> fe229973), gnunet, 2021/11/10
- [libeufin] 02/08: fix visibility issue, gnunet, 2021/11/10
- [libeufin] 01/08: Finish basic auth implementation., gnunet, 2021/11/10
- [libeufin] 03/08: adapt after wallet tests harness, gnunet, 2021/11/10
- [libeufin] 06/08: allow longer currency names, gnunet, 2021/11/10
- [libeufin] 07/08: fixes after wallet harness, gnunet, 2021/11/10
- [libeufin] 04/08: Fixes after wallet tests harness.,
gnunet <=
- [libeufin] 05/08: fix exchange suggestion, gnunet, 2021/11/10
- [libeufin] 08/08: Fixes after wallet tests harness., gnunet, 2021/11/10