libeufin

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

commit b06aafe1b185cd40aa9a83d18a71f0de54412201
parent d89236440cb074091d6376f3064dcdb44f112baf
Author: Antoine A <>
Date:   Fri, 20 Mar 2026 20:59:09 +0100

nexus: ebics log payload earlier on upload

Diffstat:
Mlibeufin-ebics/src/main/kotlin/tech/libeufin/ebics/EBicsLogger.kt | 9+++------
Mlibeufin-ebics/src/main/kotlin/tech/libeufin/ebics/EbicsCommon.kt | 6+++---
Mtestbench/src/main/kotlin/Main.kt | 23+++++++----------------
3 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/libeufin-ebics/src/main/kotlin/tech/libeufin/ebics/EBicsLogger.kt b/libeufin-ebics/src/main/kotlin/tech/libeufin/ebics/EBicsLogger.kt @@ -1,6 +1,6 @@ /* * This file is part of LibEuFin. - * Copyright (C) 2024-2025 Taler Systems S.A. + * Copyright (C) 2024, 2025, 2026 Taler Systems S.A. * LibEuFin is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -103,16 +103,13 @@ class TxLogger internal constructor( /** Log EBICS transaction protocol step */ class StepLogger internal constructor( private val dir: Path?, - private val name: String? + name: String? ) { private val prefix = if (name != null) "$name-" else "" /** Log a protocol step [request] */ fun logRequest(request: ByteArray) { - if (dir != null) { - dir.resolve("${prefix}request.xml") - .writeBytes(request, StandardOpenOption.CREATE_NEW) - } + dir?.resolve("${prefix}request.xml")?.writeBytes(request, StandardOpenOption.CREATE_NEW) } /** Log a protocol step failure */ diff --git a/libeufin-ebics/src/main/kotlin/tech/libeufin/ebics/EbicsCommon.kt b/libeufin-ebics/src/main/kotlin/tech/libeufin/ebics/EbicsCommon.kt @@ -1,6 +1,6 @@ /* * This file is part of LibEuFin. - * Copyright (C) 2024-2025 Taler Systems S.A. + * Copyright (C) 2024, 2025, 2026 Taler Systems S.A. * LibEuFin is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -277,6 +277,8 @@ class EbicsClient( val impl = EbicsBTS(cfg, bankKeys, clientKeys, order) val preparedPayload = prepareUploadPayload(cfg, clientKeys, bankKeys, payload) + txLog.payload(payload, "xml") + // Init phase val initXml = impl.uploadInitialization(preparedPayload) val initResp = impl.postBTS(client, initXml, "Upload init $description", txLog.step("init")) @@ -286,8 +288,6 @@ class EbicsClient( val orderId = requireNotNull(initResp.orderID) { "Upload init $description: missing order ID" } - - txLog.payload(payload, "xml") // Transfer phase for (i in 1..preparedPayload.segments.size) { diff --git a/testbench/src/main/kotlin/Main.kt b/testbench/src/main/kotlin/Main.kt @@ -1,6 +1,6 @@ /* * This file is part of LibEuFin. - * Copyright (C) 2023-2025 Taler Systems S.A. + * Copyright (C) 2023, 2024, 2025, 2026 Taler Systems S.A. * * LibEuFin is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -219,7 +219,6 @@ class Cli : CliktCommand() { clientKeysPath.deleteIfExists() } bankKeysPath.deleteIfExists() - Unit } } Pair(suspend { ebisyncCmd.run("setup $debugFlags") }, cmds) @@ -265,12 +264,10 @@ class Cli : CliktCommand() { clientKeysPath.deleteIfExists() } bankKeysPath.deleteIfExists() - Unit } put("tx", "Initiate a new transaction") { val now = Instant.now() nexusCmd.run("initiate-payment $flags --amount=$currency:0.1 --subject \"single $now\" \"$payto\"") - Unit } put("txs", "Initiate four new transactions") { val now = Instant.now() @@ -283,19 +280,16 @@ class Cli : CliktCommand() { badPayto.parameters["receiver-name"] = "John Smith" val now = Instant.now() nexusCmd.run("initiate-payment $flags --amount=$currency:0.21 --subject \"bad name $now\" \"$badPayto\"") - Unit } put("tx-bad-iban", "Initiate a new transaction to a bad IBAN") { val badPayto = URLBuilder().takeFrom("payto://iban/XX18500105173385245165") badPayto.parameters["receiver-name"] = "John Smith" val now = Instant.now() nexusCmd.run("initiate-payment $flags --amount=$currency:0.22 --subject \"bad iban $now\" \"$badPayto\"") - Unit } put("tx-dummy-iban", "Initiate a new transaction to a dummy IBAN") { val now = Instant.now() nexusCmd.run("initiate-payment $flags --amount=$currency:0.23 --subject \"dummy iban $now\" \"$dummyPayto\"") - Unit } put("tx-check", "Check transaction semantic", "testing tx-check $flags") } @@ -376,25 +370,22 @@ data class CmdsBuilder( val map: MutableMap<String, Pair<String, suspend (List<String> ) -> Unit>>) { fun putCmd(name: String, step: String, lambda: suspend (List<String>) -> Unit) { - map.put(name, Pair(step, lambda)) + map[name] = Pair(step, lambda) } fun put(name: String, step: String, lambda: suspend () -> Unit) { - putCmd(name, step, { + putCmd(name = name, step = step, lambda = { lambda() - Unit }) } fun put(name: String, step: String, args: String) { - put(name, step, { + put(name, step) { cmd.run(args) - Unit - }) + } } fun putArgs(name: String, step: String, parser: (List<String>) -> String) { - putCmd(name, step, { args: List<String> -> + putCmd(name, step) { args: List<String> -> cmd.run(parser(args)) - Unit - }) + } } }