[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Catching CAMT parsing errors.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Catching CAMT parsing errors. |
Date: |
Thu, 09 Jul 2020 18:15:17 +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 478947a Catching CAMT parsing errors.
478947a is described below
commit 478947a7e131a1659a29bc48031f813360b5eab1
Author: MS <ms@taler.net>
AuthorDate: Thu Jul 9 18:14:51 2020 +0200
Catching CAMT parsing errors.
---
integration-tests/test-bankConnection.py | 7 +++++--
nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt | 6 +-----
.../kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt | 12 +++++++++---
.../src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 6 ++++--
.../main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 5 +++--
5 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/integration-tests/test-bankConnection.py
b/integration-tests/test-bankConnection.py
index 920306e..be15195 100755
--- a/integration-tests/test-bankConnection.py
+++ b/integration-tests/test-bankConnection.py
@@ -135,11 +135,14 @@ assertResponse(
)
)
-connectionsList = assertResponse(
+resp = assertResponse(
get("http://localhost:5001/bank-connections")
)
-for el in connectionsList.json():
+connectionsList = resp.json().get("bankConnections")
+assert(connectionsList != None)
+
+for el in connectionsList:
print(el)
if el.get("name") == "my-ebics":
print("fail: account not deleted!")
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index 52ef436..449bcc2 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -285,7 +285,6 @@ private suspend fun talerTransfer(call: ApplicationCall) {
row.id.value
}
return call.respond(
- HttpStatusCode.OK,
TextContent(
customConverter(
TalerTransferResponse(
@@ -496,10 +495,7 @@ private suspend fun historyOutgoing(call: ApplicationCall)
{
}
}
}
- call.respond(
- HttpStatusCode.OK,
- TextContent(customConverter(history), ContentType.Application.Json)
- )
+ call.respond(TextContent(customConverter(history),
ContentType.Application.Json))
}
/**
diff --git
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 59e4189..151a65a 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -29,6 +29,7 @@ import org.w3c.dom.Document
import tech.libeufin.nexus.*
import tech.libeufin.nexus.ebics.fetchEbicsBySpec
import tech.libeufin.nexus.ebics.submitEbicsPaymentInitiation
+import tech.libeufin.nexus.iso20022.CamtParsingError
import tech.libeufin.nexus.iso20022.CreditDebitIndicator
import tech.libeufin.nexus.iso20022.parseCamtMessage
import tech.libeufin.nexus.server.FetchSpecJson
@@ -130,10 +131,15 @@ fun processCamtMessage(
if (acct == null) {
throw NexusError(HttpStatusCode.NotFound, "user not found")
}
- val res = parseCamtMessage(camtDoc)
-
+ val res = try {
+ parseCamtMessage(camtDoc)
+ } catch (e: CamtParsingError) {
+ throw NexusError(
+ HttpStatusCode.BadGateway,
+ "Invalid CAMT received from bank"
+ )
+ }
val stamp = ZonedDateTime.parse(res.creationDateTime,
DateTimeFormatter.ISO_DATE_TIME).toInstant().toEpochMilli()
-
when (code) {
"C52" -> {
val s = acct.lastReportCreationTimestamp
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
index 21d9733..3a9bbb8 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -319,7 +319,9 @@ private fun getEbicsSubscriberDetails(bankConnectionId:
String): EbicsClientSubs
if (transport == null) {
throw NexusError(HttpStatusCode.NotFound, "transport not found")
}
- val subscriber = EbicsSubscriberEntity.find {
EbicsSubscribersTable.nexusBankConnection eq transport.id }.first()
+ val subscriber = EbicsSubscriberEntity.find {
+ EbicsSubscribersTable.nexusBankConnection eq transport.id
+ }.first()
// transport exists and belongs to caller.
return getEbicsSubscriberDetailsInternal(subscriber)
}
@@ -368,7 +370,7 @@ fun Route.ebicsBankProtocolRoutes(client: HttpClient) {
post("test-host") {
val r = call.receiveJson<EbicsHostTestRequest>()
val qr = doEbicsHostVersionQuery(client, r.ebicsBaseUrl, r.ebicsHostId)
- call.respond(HttpStatusCode.OK, qr)
+ call.respond(qr)
return@post
}
}
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 acd5297..c9d97c9 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -236,6 +236,7 @@ fun serverMain(dbName: String, host: String) {
exception<EbicsProtocolError> { cause ->
logger.error("Exception while handling '${call.request.uri}'",
cause)
call.respond(
+ cause.httpStatusCode,
NexusErrorJson(
error = NexusErrorDetailJson(
type = "ebics-protocol-error",
@@ -287,7 +288,7 @@ fun serverMain(dbName: String, host: String) {
superuser = currentUser.superuser
)
}
- call.respond(HttpStatusCode.OK, ret)
+ call.respond(ret)
return@get
}
@@ -300,7 +301,7 @@ fun serverMain(dbName: String, host: String) {
}
}
val usersResp = UsersResponse(users)
- call.respond(HttpStatusCode.OK, usersResp)
+ call.respond(usersResp)
return@get
}
--
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: Catching CAMT parsing errors.,
gnunet <=