libeufin

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

commit f6c766f6d365552af672c164ec5fff4a936e744c
parent 6c4245b6761caf746b58809b6f2c89601af0e85c
Author: Antoine A <>
Date:   Fri, 19 Jan 2024 14:25:33 +0000

Remove development features from libeufin-nexus and hide options that will be removed in the next version

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt | 41+++++++++++++++--------------------------
Mnexus/src/main/kotlin/tech/libeufin/nexus/EbicsSetup.kt | 24------------------------
Mnexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt | 34+++-------------------------------
3 files changed, 18 insertions(+), 81 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt @@ -358,7 +358,7 @@ fun firstLessThanSecond( } private fun ingestDocument( - db: Database?, + db: Database, currency: String, content: ByteArray, whichDocument: SupportedDocument @@ -373,7 +373,7 @@ private fun ingestDocument( content.unzipForEach { fileName, xmlContent -> if (!fileName.contains("camt.054", ignoreCase = true)) throw Exception("Asked for notification but did NOT get a camt.054") - logger.debug("parse $fileName") + logger.trace("parse $fileName") parseTxNotif(xmlContent, currency, incomingPayments, outgoingPayments) } } catch (e: IOException) { @@ -382,10 +382,10 @@ private fun ingestDocument( runBlocking { incomingPayments.forEach { - if (db != null) ingestIncomingPayment(db, it) else logger.debug("$it") + ingestIncomingPayment(db, it) } outgoingPayments.forEach { - if (db != null) ingestOutgoingPayment(db, it) else logger.debug("$it") + ingestOutgoingPayment(db, it) } } } catch (e: Exception) { @@ -401,7 +401,7 @@ private fun ingestDocument( SupportedDocument.PAIN_002 -> { try { content.unzipForEach { fileName, xmlContent -> - logger.debug("parse $fileName") + logger.trace("parse $fileName") val status = parseCustomerPaymentStatusReport(xmlContent.toString()) logger.debug("$status") // TODO ingest in db } @@ -473,21 +473,25 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti ).flag(default = false) private val onlyStatements by option( - help = "Downloads only camt.053 statements" + help = "Downloads only camt.053 statements", + hidden = true ).flag(default = false) private val onlyAck by option( - help = "Downloads only pain.002 acknowledgements" + help = "Downloads only pain.002 acknowledgements", + hidden = true ).flag(default = false) private val onlyReports by option( - help = "Downloads only camt.052 intraday reports" + help = "Downloads only camt.052 intraday reports", + hidden = true ).flag(default = false) private val onlyLogs by option( help = "Downloads only EBICS activity logs via pain.002," + " only available to --transient mode. Config needs" + - " log directory" + " log directory", + hidden = true ).flag(default = false) private val pinnedStart by option( @@ -496,17 +500,9 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti " latest document is always until the current time." ) - private val parse by option( - help = "Reads one ISO20022 document from STDIN and prints " + - "the parsing results. It does not affect the database." - ).flag(default = false) - - private val import by option( - help = "Read one ISO20022 document from STDIN and imports its content into the database" - ).flag(default = false) - private val ebicsExtraLog by option( - help = "Logs to STDERR the init phase of an EBICS download request" + help = "Logs to STDERR the init phase of an EBICS download request", + hidden = true ).flag(default = false) /** @@ -528,13 +524,6 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti if (onlyLogs) whichDoc = SupportedDocument.PAIN_002_LOGS Database(dbCfg.dbConnStr).use { db -> - if (parse || import) { - logger.debug("Reading from STDIN, running in debug mode. Not involving the database.") - val stdin = generateSequence(::readLine).joinToString("\n").toByteArray() - ingestDocument(if (import) db else null, cfg.currency, stdin, whichDoc) - return@cliCmd - } - val (clientKeys, bankKeys) = expectFullKeys(cfg) val ctx = FetchContext( cfg, diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSetup.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSetup.kt @@ -270,9 +270,6 @@ private fun makePdf(privs: ClientPrivateKeysFile, cfg: EbicsSetupConfig) { */ class EbicsSetup: CliktCommand("Set up the EBICS subscriber") { private val common by CommonOption() - private val checkFullConfig by option( - help = "Checks config values of ALL the subcommands" - ).flag(default = false) private val forceKeysResubmission by option( help = "Resubmits all the keys to the bank" ).flag(default = false) @@ -287,27 +284,6 @@ class EbicsSetup: CliktCommand("Set up the EBICS subscriber") { */ override fun run() = cliCmd(logger, common.log) { val cfg = extractEbicsConfig(common.config) - if (checkFullConfig) { - cfg.config.requireString("nexus-submit", "frequency").apply { - if (getFrequencyInSeconds(this) == null) - throw Exception("frequency value of nexus-submit section is not valid: $this") - } - cfg.config.requireString("nexus-fetch", "frequency").apply { - if (getFrequencyInSeconds(this) == null) - throw Exception("frequency value of nexus-fetch section is not valid: $this") - } - cfg.config.requirePath("nexus-fetch", "statement_log_directory") - cfg.config.requireNumber("nexus-httpd", "port") - cfg.config.requirePath("nexus-httpd", "unixpath") - cfg.config.requireString("nexus-httpd", "serve") - cfg.config.requireString("nexus-httpd-wire-gateway-facade", "enabled") - cfg.config.requireString("nexus-httpd-wire-gateway-facade", "auth_method") - cfg.config.requireString("nexus-httpd-wire-gateway-facade", "auth_token") - cfg.config.requireString("nexus-httpd-revenue-facade", "enabled") - cfg.config.requireString("nexus-httpd-revenue-facade", "auth_method") - cfg.config.requireString("nexus-httpd-revenue-facade", "auth_token") - return@cliCmd - } // Config is sane. Go (maybe) making the private keys. val clientKeys = preparePrivateKeys(cfg.clientPrivateKeysFilename) val httpClient = HttpClient() diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt @@ -72,12 +72,7 @@ data class SubmissionContext( /** * Bank EBICS public keys. */ - val bankPublicKeysFile: BankPublicKeysFile, - - /** - * Causes EBICS messages to be logged to STDERR. - */ - val ebicsExtraLog: Boolean = false + val bankPublicKeysFile: BankPublicKeysFile ) /** @@ -252,14 +247,7 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat help = "This flag submits what is found in the database and returns, " + "ignoring the 'frequency' configuration value" ).flag(default = false) - - private val debug by option( - help = "Reads the pain.001 document from STDIN and submits it to the bank" - ).flag(default = false) - - private val ebicsExtraLog by option( - help = "Logs init phase of uploaded messages to STDERR. Only available for EBICS 3" - ).flag(default = false) + /** * Submits any initiated payment that was not submitted * so far and -- according to the configuration -- returns @@ -274,24 +262,8 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat cfg = cfg, bankPublicKeysFile = bankKeys, clientPrivateKeysFile = clientKeys, - httpClient = HttpClient(), - ebicsExtraLog = ebicsExtraLog + httpClient = HttpClient() ) - if (debug) { - logger.info("Running in debug mode, submitting STDIN to the bank") - val maybeStdin = generateSequence(::readLine).joinToString("\n") - runBlocking { - submitPain001( - maybeStdin, - ctx.cfg, - ctx.clientPrivateKeysFile, - ctx.bankPublicKeysFile, - ctx.httpClient, - ctx.ebicsExtraLog - ) - } - return@cliCmd - } Database(dbCfg.dbConnStr).use { db -> val frequency = if (transient) { logger.info("Transient mode: submitting what found and returning.")