libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 67e593cafdcaabdaa78ac80d6241f7065c637d47
parent 886c92fcaf42fa7a471509702a01a2d3837ad0e5
Author: MS <ms@taler.net>
Date:   Mon, 30 Aug 2021 23:19:28 -1100

Use EBICS_PROCESSING_ERROR as "Internal server error".

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt | 26++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -103,6 +103,16 @@ private class EbicsUnsupportedOrderType : EbicsRequestError( "091005" ) +/** + * Used here also for "Internal server error". For example, when the + * sandbox itself generates a invalid XML response. Strictly, this error + * should only be used for _business_ related problems. + */ +private class EbicsProcessingError(detail: String) : EbicsRequestError( + "[EBICS_PROCESSING_ERROR] $detail", + "091116" +) + private suspend fun ApplicationCall.respondEbicsKeyManagement( errorText: String, errorCode: String, @@ -637,14 +647,22 @@ private fun handleCct(paymentRequest: String) { private fun handleEbicsC53(requestContext: RequestContext): ByteArray { logger.debug("Handling C53 request") + + /** + * By multiple statements, this function is responsible to return + * a list of Strings: one for each statement. + */ val camt = constructCamtResponse( 53, requestContext.subscriber ) - if (!XMLUtil.validateFromString(camt)) throw SandboxError( - HttpStatusCode.InternalServerError, - "CAMT document was generated invalid" + if (!XMLUtil.validateFromString(camt)) throw EbicsProcessingError( + "Sandbox generated a invalid XML response." ) + /** + * Here, the list of strings will be converted to list of + * ByteArray and passed to the zip() method. + */ return listOf(camt.toByteArray(Charsets.UTF_8)).zip() } @@ -977,7 +995,7 @@ private fun handleEbicsDownloadTransactionInitialization(requestContext: Request "HTD" -> handleEbicsHtd(requestContext) "HKD" -> handleEbicsHkd(requestContext) "C53" -> handleEbicsC53(requestContext) - "C52" -> throw EbicsUnsupportedOrderType() + "C52" -> throw EbicsUnsupportedOrderType() // TBD "TSD" -> handleEbicsTSD() "PTK" -> handleEbicsPTK() else -> throw EbicsInvalidXmlError()