libeufin

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

commit ad85d90d5cdf71e57401f4071316c84bb499a5bb
parent 1ce76c52f15995d869f62e212f067e53e9369785
Author: ms <ms@taler.net>
Date:   Fri, 15 Jan 2021 17:18:32 +0100

make sure only one Camt is responded

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

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -441,7 +441,7 @@ fun buildCamtString(type: Int, subscriberIban: String, history: List<RawPayment> * * @param type 52 or 53. */ -private fun constructCamtResponse(type: Int, header: EbicsRequest.Header, subscriber: EbicsSubscriberEntity): MutableList<String> { +private fun constructCamtResponse(type: Int, header: EbicsRequest.Header, subscriber: EbicsSubscriberEntity): String { val dateRange = (header.static.orderDetails?.orderParams as EbicsRequest.StandardOrderParams).dateRange val (start: LocalDateTime, end: LocalDateTime) = if (dateRange != null) { Pair( @@ -452,7 +452,7 @@ private fun constructCamtResponse(type: Int, header: EbicsRequest.Header, subscr val bankAccount = getBankAccountFromSubscriber(subscriber) logger.info("getting history for account with iban ${bankAccount.iban}") val history = historyForAccount(bankAccount.iban) - return mutableListOf(buildCamtString(type, bankAccount.iban, history)) + return buildCamtString(type, bankAccount.iban, history) } /** @@ -591,15 +591,11 @@ private fun handleEbicsC53(requestContext: RequestContext): ByteArray { requestContext.requestObject.header, requestContext.subscriber ) - // FIXME: this function should be replaced with one that fills only - // *one* CAMT document with multiple "Ntry" elements. - return camt.map { - if (!XMLUtil.validateFromString(it)) throw SandboxError( + if (!XMLUtil.validateFromString(camt)) throw SandboxError( HttpStatusCode.InternalServerError, "CAMT document was generated invalid" - ) - it.toByteArray(Charsets.UTF_8) - }.zip() + ) + return listOf(camt.toByteArray(Charsets.UTF_8)).zip() } private suspend fun ApplicationCall.handleEbicsHia(header: EbicsUnsecuredRequest.Header, orderData: ByteArray) {