libeufin

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

commit 587d1ed27e43e95e0ae9ff0b91b6d21824035b04
parent c9cd57469e7c401c1cd27e6815e68628a42b3931
Author: Antoine A <>
Date:   Thu, 28 May 2026 14:17:06 +0200

ebics: clean code

Diffstat:
Mlibeufin-bank/src/api.rs | 19+++++--------------
Mlibeufin-ebics/src/ebics/key_management.rs | 4++--
Mlibeufin-ebics/src/iso20022/hac.rs | 3+--
Mlibeufin-ebics/src/iso20022/pain001.rs | 5+----
Mlibeufin-ebics/src/iso20022/pain002.rs | 5+----
Mlibeufin-ebics/src/setup.rs | 5++---
Mlibeufin-nexus/src/db/initiated.rs | 3+--
Mlibeufin-nexus/src/fetch.rs | 23+++--------------------
8 files changed, 16 insertions(+), 51 deletions(-)

diff --git a/libeufin-bank/src/api.rs b/libeufin-bank/src/api.rs @@ -249,7 +249,7 @@ pub mod test { http::{HeaderValue, Method, StatusCode, header::AUTHORIZATION}, middleware::{self, Next}, }; - use compact_str::CompactString; + use compact_str::{CompactString, CompactStringExt}; use jiff::Timestamp; use rand::{random_range, seq::IndexedRandom}; use taler_api::db::BindHelper; @@ -310,11 +310,7 @@ pub mod test { impl BankTestCtx { pub async fn new(conf: &str) -> Self { - let cfg = Config::from_file( - CONFIG_SOURCE, - Some(format!("conf/{conf}")), - ) - .unwrap(); + let cfg = Config::from_file(CONFIG_SOURCE, Some(format!("conf/{conf}"))).unwrap(); let cfg = BankCfg::parse(cfg).unwrap(); let dir = cfg.db_cfg.sql_dir.as_ref(); let (mut conn, db) = db_test_setup_manual(dir, "libeufin-bank").await; @@ -444,11 +440,7 @@ pub mod test { } pub async fn swap_cfg(mut self, conf: &str) -> Self { - let cfg = Config::from_file( - CONFIG_SOURCE, - Some(format!("conf/{conf}")), - ) - .unwrap(); + let cfg = Config::from_file(CONFIG_SOURCE, Some(format!("conf/{conf}"))).unwrap(); let state = Arc::new( BankState::start(self.state.db.clone(), BankCfg::parse(cfg).unwrap()).await, @@ -893,10 +885,9 @@ pub mod test { .challenges .into_iter() .map(|it| it.challenge_id) - .collect::<Vec<_>>() - .join(", "); + .join_compact(", "); ctx.requesta(self.method.clone(), self.uri.path(), Some(username)) - .header(TALER_CHALLENGE_IDS, ids) + .header(TALER_CHALLENGE_IDS, ids.to_string()) .raw_json(self.req_body.clone()) .await } diff --git a/libeufin-ebics/src/ebics/key_management.rs b/libeufin-ebics/src/ebics/key_management.rs @@ -21,6 +21,7 @@ use std::{borrow::Cow, io::Write as _}; use anyhow::bail; use aws_lc_rs::encoding::{AsDer, Pkcs8V1Der}; +use compact_str::CompactStringExt; use flate2::{Compression, write::ZlibEncoder}; use taler_common::encoding::base64; use tracing::info; @@ -265,8 +266,7 @@ where .as_bytes() .chunks(64) .map(|c| std::str::from_utf8(c).unwrap()) - .collect::<Vec<_>>() - .join("\n"); + .join_compact("\n"); let pem = format!("-----BEGIN RSA PRIVATE KEY-----\n{lines}\n-----END RSA PRIVATE KEY-----\n"); let cert = x509_certificate_from_rsa_private(&pem, "LibEuFin EBICS").unwrap(); let der = cert.der(); diff --git a/libeufin-ebics/src/iso20022/hac.rs b/libeufin-ebics/src/iso20022/hac.rs @@ -133,8 +133,7 @@ mod test { } } pretty_assertions::assert_eq!( - parse_hac(&std::fs::read("sample/platform/hac.xml").unwrap()) - .unwrap(), + parse_hac(&std::fs::read("sample/platform/hac.xml").unwrap()).unwrap(), [ ack( HacAction::FILE_DOWNLOAD, diff --git a/libeufin-ebics/src/iso20022/pain001.rs b/libeufin-ebics/src/iso20022/pain001.rs @@ -235,10 +235,7 @@ mod test { }; for dialect in Dialect::entries { pretty_assertions::assert_eq!( - std::fs::read_to_string(format!( - "sample/platform/{dialect}_pain001.xml" - )) - .unwrap(), + std::fs::read_to_string(format!("sample/platform/{dialect}_pain001.xml")).unwrap(), create_pain001(&msg, dialect, false).unwrap() ); } diff --git a/libeufin-ebics/src/iso20022/pain002.rs b/libeufin-ebics/src/iso20022/pain002.rs @@ -252,10 +252,7 @@ mod test { } ); pretty_assertions::assert_eq!( - parse_pain002( - &std::fs::read("sample/platform/pain002_accp.xml").unwrap() - ) - .unwrap(), + parse_pain002(&std::fs::read("sample/platform/pain002_accp.xml").unwrap()).unwrap(), MsgStatus { id: "5HIS3433VVIBAANHW3GX9DR1AXRS43KZ4U".into(), status: Some(PaymentGroupStatus::AcceptedCustomerProfile), diff --git a/libeufin-ebics/src/setup.rs b/libeufin-ebics/src/setup.rs @@ -20,7 +20,7 @@ use std::path::Path; use anyhow::{anyhow, bail}; -use compact_str::CompactString; +use compact_str::{CompactString, CompactStringExt}; use tracing::{debug, info}; use crate::{ @@ -69,8 +69,7 @@ pub async fn ebics_setup( versions .iter() .map(|v| v.to_string()) - .collect::<Vec<_>>() - .join(", ") + .join_compact(", ") ); if !versions.contains(&VersionNumber { number: "03.00".into(), diff --git a/libeufin-nexus/src/db/initiated.rs b/libeufin-nexus/src/db/initiated.rs @@ -492,8 +492,7 @@ mod test { #[tokio::test] pub async fn initiated_skip() { let (_, db) = db_setup().await; - let cfg = - Config::from_file(CONFIG_SOURCE, Some("conf/skip.conf")).unwrap(); + let cfg = Config::from_file(CONFIG_SOURCE, Some("conf/skip.conf")).unwrap(); let cfg = NexusCfg::parse(cfg).unwrap(); let cfg = cfg.ingest().unwrap(); let millis = Span::new().milliseconds(10); diff --git a/libeufin-nexus/src/fetch.rs b/libeufin-nexus/src/fetch.rs @@ -24,6 +24,7 @@ use std::{ }; use anyhow::{anyhow, bail}; +use compact_str::CompactStringExt; use jiff::{Timestamp, Zoned, tz::TimeZone}; use libeufin_ebics::{ ebics::{ @@ -325,16 +326,7 @@ pub async fn ebics_fetch( .into_iter() .map(|it| it.order) .collect::<Vec<_>>(); - debug!( - "HKD: {}", - std::fmt::from_fn(|f| f.write_str( - &supported_orders - .iter() - .map(|it| it.to_string()) - .collect::<Vec<_>>() - .join(",") - )) - ); + debug!(target: "fetch", "HKD: {}", supported_orders.iter().map(|it| it.to_string()).join_compact(", ")); supported_orders .retain(|order| orders.iter().find(|it| order.eq(it)).is_some()); fetch(&supported_orders, since).await @@ -356,16 +348,7 @@ pub async fn ebics_fetch( let res = async { // We fetch HAA to only fetch pending & supported EBICS orders and get the document versions let mut haa = ebics.haa(db, client, bank, false).await?; - debug!(target: "fetch", - "HAA: {}", - std::fmt::from_fn(|f| f.write_str( - &haa.orders - .iter() - .map(|it| it.to_string()) - .collect::<Vec<_>>() - .join(",") - )) - ); + debug!(target: "fetch", "HAA: {}", haa.orders.iter().map(|it| it.to_string()).join_compact(", ")); haa.orders .retain(|order| orders.iter().find(|it| order.eq(it)).is_some()); fetch(&haa.orders, *pinned_start).await