libeufin

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

commit 047fe5a47217dc5c2dba100b8e22bb442a194975
parent ee5315a102ef729c90d04497bba6ee7bc05110ce
Author: Antoine A <>
Date:   Tue,  2 Jun 2026 14:38:00 +0200

nexus: improve fake incoming command

Diffstat:
Mlibeufin-nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt | 35+++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/libeufin-nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt b/libeufin-nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt @@ -72,7 +72,7 @@ class FakeIncoming : TalerCmd() { private val amount by option( "--amount", - help = "The payment amount, payto 'amount' parameter takes the precedence" + help = "The payment amount, credit-payto 'amount' parameter takes the precedence" ).convert { TalerAmount(it) } private val creditFee by option( "--credit-fee", @@ -80,21 +80,36 @@ class FakeIncoming : TalerCmd() { ).convert { TalerAmount(it) } private val subject by option( "--subject", - help = "The payment subject, payto 'message' parameter takes the precedence" + help = "The payment subject, credit-payto 'message' parameter takes the precedence" ) private val chQrr by option( "--ch-qrr", - help = "The payment reference, payto 'ch-qrr' parameter takes the precedence" + help = "The payment reference, credit-payto 'ch-qrr' parameter takes the precedence" ) - private val payto by argument( + private val creditPayto by option( + "--credit-payto", + help = "The credited account IBAN payto URI" + ).convert { Payto.parse(it).expectIban() } + private val debitPayto by option( + "--debit-payto", help = "The debited account IBAN payto URI" ).convert { Payto.parse(it).expectIban() } + private val payto by argument( + name = "deprecated", + help = "deprecated" + ).convert { Payto.parse(it).expectIban() }.optional() override fun run() = cliCmd(logger) { nexusConfig(config).withDb { db, cfg -> - val amount = requireNotNull(payto.amount ?: amount) { "Missing amount" } - val subject = payto.message ?: subject - val reference = payto.chQrr ?: chQrr + val amount = requireNotNull(creditPayto?.amount ?: payto?.amount ?: amount) { "Missing amount" } + val subject = creditPayto?.message ?: payto?.message ?: subject + val reference = creditPayto?.chQrr ?: payto?.chQrr ?: chQrr + + creditPayto?.let { + require(it.iban.toString() == cfg.ebics.account.iban) { + "Creditor must be exchange expected {cfg.ebics.account.iban} got {it.iban}" + } + } require(amount.currency == cfg.currency) { "Wrong currency: expected ${cfg.currency} got ${amount.currency}" @@ -104,7 +119,7 @@ class FakeIncoming : TalerCmd() { db, cfg.ingest, IncomingPayment( amount = amount, - debtor = payto, + debtor = debitPayto ?: payto ?: IbanPayto.rand("Testing Account"), subject = reference ?: subject ?: "", creditFee = creditFee, executionTime = Instant.now(), @@ -207,9 +222,9 @@ class EbicsDownload : TalerCmd("ebics-btd") { class IbanGen : CliktCommand("gen") { override fun help(context: Context) = "Generate fake IBANs for testing" - + private val country by option().enum<Country>().required() - + override fun run() { println(IBAN.rand(country)) }