[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Debug transactions creation (via Web U
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Debug transactions creation (via Web UI). |
Date: |
Mon, 31 Jan 2022 15:03:41 +0100 |
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 5fdd3bb2 Debug transactions creation (via Web UI).
5fdd3bb2 is described below
commit 5fdd3bb2bbf2021845e25f43e997e59afe490421
Author: ms <ms@taler.net>
AuthorDate: Mon Jan 31 15:03:02 2022 +0100
Debug transactions creation (via Web UI).
---
.../kotlin/tech/libeufin/nexus/server/NexusServer.kt | 2 +-
.../src/main/kotlin/tech/libeufin/sandbox/Helpers.kt | 3 +++
sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt | 1 +
sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 8 ++++----
sandbox/src/main/resources/static/spa.html | 2 +-
util/src/main/kotlin/Errors.kt | 4 ++--
util/src/main/kotlin/Payto.kt | 19 +++++++++++--------
7 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 51b0a1d0..e9d7fb3a 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -543,7 +543,7 @@ val nexusApp: Application.() -> Unit = {
if (bankAccount == null) {
throw NexusError(HttpStatusCode.NotFound, "unknown bank
account")
}
- val holderEnc = URLEncoder.encode(bankAccount.accountHolder,
"UTF-8")
+ val holderEnc = URLEncoder.encode(bankAccount.accountHolder,
Charsets.UTF_8)
val lastSeenBalance = NexusBankBalanceEntity.find {
NexusBankBalancesTable.bankAccount eq bankAccount.id
}.lastOrNull()
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
index 10d4b042..408a42c9 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -19,6 +19,9 @@
package tech.libeufin.sandbox
+import com.fasterxml.jackson.core.JsonParseException
+import com.fasterxml.jackson.databind.exc.MismatchedInputException
+import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException
import io.ktor.application.*
import io.ktor.http.HttpStatusCode
import io.ktor.request.*
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
index 67eac25b..d1e82045 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -19,6 +19,7 @@
package tech.libeufin.sandbox
+import com.fasterxml.jackson.annotation.JsonProperty
import tech.libeufin.util.PaymentInfo
data class WithdrawalRequest(
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 0520ac10..70cbd817 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -997,7 +997,7 @@ val sandboxApp: Application.() -> Unit = {
)
}
logger.debug("TWG add-incoming passed authentication")
- val body = call.receive<TWGAdminAddIncoming>()
+ val body = call.receiveJson<TWGAdminAddIncoming>()
transaction {
val demobank = ensureDemobank(call)
val bankAccountCredit =
getBankAccountFromLabel(username, demobank)
@@ -1095,7 +1095,7 @@ val sandboxApp: Application.() -> Unit = {
route("/access-api") {
post("/accounts/{account_name}/transactions") {
val bankAccount = getBankAccountWithAuth(call)
- val req = call.receive<NewTransactionReq>()
+ val req = call.receiveJson<NewTransactionReq>()
val payto = parsePayto(req.paytoUri)
val amount: String? = payto.amount ?: req.amount
if (amount == null) throw badRequest("Amount is missing")
@@ -1158,7 +1158,7 @@ val sandboxApp: Application.() -> Unit = {
if (maybeOwnedAccount.owner != username) throw
unauthorized(
"Customer '$username' has no rights over bank account
'${maybeOwnedAccount.label}'"
)
- val req = call.receive<WithdrawalRequest>()
+ val req = call.receiveJson<WithdrawalRequest>()
// Check for currency consistency
val amount = parseAmount(req.amount)
if (amount.currency != demobank.currency) throw badRequest(
@@ -1385,7 +1385,7 @@ val sandboxApp: Application.() -> Unit = {
post("/testing/register") {
// Check demobank was created.
val demobank = ensureDemobank(call)
- val req = call.receive<CustomerRegistration>()
+ val req = call.receiveJson<CustomerRegistration>()
val checkExist = transaction {
DemobankCustomerEntity.find {
DemobankCustomersTable.username eq req.username
diff --git a/sandbox/src/main/resources/static/spa.html
b/sandbox/src/main/resources/static/spa.html
index 7ccf07c8..9403c409 100644
--- a/sandbox/src/main/resources/static/spa.html
+++ b/sandbox/src/main/resources/static/spa.html
@@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="en" class="has-aside-left
has-aside-mobile-transition has-navbar-fixed-top
has-aside-expanded"><head><meta charset="utf-8"><title>taler-bank</title><meta
name="viewport" content="width=device-width,initial-scale=1"><meta
name="mobile-web-app-capable" content="yes"><meta
name="apple-mobile-web-app-capable" content="yes"><link rel="icon"
href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD/////////////////////////
[...]
-/*! @creativebulma/bulma-tooltip v1.2.0 | (c) 2020 Gaetan | MIT License |
https://github.com/CreativeBulma/bulma-tooltip
*/[data-tooltip]:not(.is-disabled),[data-tooltip]:not(.is-loading),[data-tooltip]:not([disabled]){cursor:pointer;overflow:visible;position:relative}[data-tooltip]:not(.is-disabled):before,[data-tooltip]:not(.is-loading):before,[data-tooltip]:not([disabled]):before{background:rgba(74,74,74,.9);border-radius:2px;content:attr(data-tooltip);padding:.5rem
1rem;text-overflow [...]
\ No newline at end of file
+/*! @creativebulma/bulma-tooltip v1.2.0 | (c) 2020 Gaetan | MIT License |
https://github.com/CreativeBulma/bulma-tooltip
*/[data-tooltip]:not(.is-disabled),[data-tooltip]:not(.is-loading),[data-tooltip]:not([disabled]){cursor:pointer;overflow:visible;position:relative}[data-tooltip]:not(.is-disabled):before,[data-tooltip]:not(.is-loading):before,[data-tooltip]:not([disabled]):before{background:rgba(74,74,74,.9);border-radius:2px;content:attr(data-tooltip);padding:.5rem
1rem;text-overflow [...]
\ No newline at end of file
diff --git a/util/src/main/kotlin/Errors.kt b/util/src/main/kotlin/Errors.kt
index 55ad8711..e083d327 100644
--- a/util/src/main/kotlin/Errors.kt
+++ b/util/src/main/kotlin/Errors.kt
@@ -26,10 +26,10 @@ import org.slf4j.LoggerFactory
val logger: Logger = LoggerFactory.getLogger("tech.libeufin.util")
-data class UtilError(
+open class UtilError(
val statusCode: HttpStatusCode,
val reason: String,
- val ec: LibeufinErrorCode?
+ val ec: LibeufinErrorCode? = null
) :
Exception("$reason (HTTP status $statusCode)")
diff --git a/util/src/main/kotlin/Payto.kt b/util/src/main/kotlin/Payto.kt
index 4c3efb41..6953a4fe 100644
--- a/util/src/main/kotlin/Payto.kt
+++ b/util/src/main/kotlin/Payto.kt
@@ -1,5 +1,7 @@
package tech.libeufin.util
+import UtilError
+import io.ktor.http.*
import java.net.URI
import java.net.URLDecoder
import java.net.URLEncoder
@@ -16,7 +18,7 @@ data class Payto(
val message: String?,
val amount: String?
)
-class InvalidPaytoError(msg: String) : Exception(msg)
+class InvalidPaytoError(msg: String) : UtilError(HttpStatusCode.BadRequest,
msg)
// Return the value of query string parameter 'name', or null if not found.
// 'params' is the a list of key-value elements of all the query parameters
found in the URI.
@@ -27,22 +29,23 @@ private fun getQueryParamOrNull(name: String, params:
List<Pair<String, String>>
}
}
-fun parsePayto(paytoLine: String): Payto {
+fun parsePayto(paytoInput: String): Payto {
+ val payto = URLDecoder.decode(paytoInput, Charsets.UTF_8)
/**
* This check is due because URIs having a "payto:" prefix without
* slashes are correctly parsed by the Java 'URI' class. 'mailto'
* for example lacks the double-slash part.
*/
- if (!paytoLine.startsWith("payto://"))
- throw InvalidPaytoError("Invalid payto URI: $paytoLine")
+ if (!payto.startsWith("payto://"))
+ throw InvalidPaytoError("Invalid payto URI: $payto")
val javaParsedUri = try {
- URI(paytoLine)
+ URI(payto)
} catch (e: java.lang.Exception) {
- throw InvalidPaytoError("'${paytoLine}' is not a valid URI")
+ throw InvalidPaytoError("'${payto}' is not a valid URI")
}
if (javaParsedUri.scheme != "payto") {
- throw InvalidPaytoError("'${paytoLine}' is not payto")
+ throw InvalidPaytoError("'${payto}' is not payto")
}
val wireMethod = javaParsedUri.host
if (wireMethod != "iban") {
@@ -50,7 +53,7 @@ fun parsePayto(paytoLine: String): Payto {
}
val splitPath = javaParsedUri.path.split("/").filter { it.isNotEmpty() }
if (splitPath.size > 2) {
- throw InvalidPaytoError("too many path segments in iban payto URI:
$paytoLine")
+ throw InvalidPaytoError("too many path segments in iban payto URI:
$payto")
}
val (iban, bic) = if (splitPath.size == 1) {
Pair(splitPath[0], null)
--
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: Debug transactions creation (via Web UI).,
gnunet <=