commit 1de5b7203cbc8cd090223523259f11cdcf26e475
parent f6e8b3e065fb1cbfda652a6d7f0339667c736030
Author: Antoine A <>
Date: Fri, 12 Jan 2024 17:43:21 +0000
Uppercase bounce id
Diffstat:
6 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
@@ -111,7 +111,7 @@ nexus-test: install-nobuild-nexus-files
./gradlew :nexus:test --tests $(test) -i
.PHONY: integration
-integration:
+integration: install-nobuild-bank-files install-nobuild-nexus-files
./gradlew :integration:run --console=plain --args="$(test)"
.PHONY: doc
diff --git a/database-versioning/libeufin-nexus-procedures.sql b/database-versioning/libeufin-nexus-procedures.sql
@@ -138,8 +138,9 @@ SELECT bank_transfer_id, debit_payto_uri
-- Generate a bounce ID deterministically from the bank ID
-- We hash the bank ID with SHA-256 then we encode the hash using base64
-- As bank id can be at most 35 characters long we truncate the encoded hash
--- Most banks should be case sensitive but we might have to normalize the id to uppercase for some of them
-SELECT substr(encode(public.digest(bank_id, 'sha256'), 'base64'), 0, 35) INTO out_bounce_id;
+-- We are not sure whether this field is case-insensitive in all banks as the standard
+-- does not clearly specify this, so we have chosen to capitalise it
+SELECT upper(substr(encode(public.digest(bank_id, 'sha256'), 'base64'), 0, 35)) INTO out_bounce_id;
-- Initiate the bounce transaction
INSERT INTO initiated_outgoing_transactions (
diff --git a/integration/conf/netzbon.conf b/integration/conf/netzbon.conf
@@ -21,5 +21,8 @@ NAME = Genossenschaft Netz Soziale Oekonomie
[nexus-fetch]
STATEMENT_LOG_DIRECTORY = test/netzbon/fetch
+[nexus-submit]
+SUBMISSIONS_LOG_DIRECTORY = test/netzbon/submit
+
[nexus-postgres]
CONFIG = postgres:///libeufincheck
diff --git a/integration/conf/postfinance.conf b/integration/conf/postfinance.conf
@@ -20,5 +20,8 @@ IBAN = CH7789144474425692816
[nexus-fetch]
STATEMENT_LOG_DIRECTORY = test/postfinance/fetch
+[nexus-submit]
+SUBMISSIONS_LOG_DIRECTORY = test/postfinance/submit
+
[nexus-postgres]
CONFIG = postgres:///libeufincheck
diff --git a/integration/src/main/kotlin/Main.kt b/integration/src/main/kotlin/Main.kt
@@ -157,6 +157,20 @@ class Cli : CliktCommand("Run integration tests on banks provider") {
step("Test fetch transactions")
nexusCmd.test("ebics-fetch --transient -c $conf --pinned-start 2022-01-01").assertOk()
+
+ while (true) {
+ when (ask("Run 'fetch', 'submit' or 'exit'>")) {
+ "fetch" -> {
+ step("Fetch new transactions")
+ nexusCmd.test("ebics-fetch --transient -c $conf").assertOk()
+ }
+ "submit" -> {
+ step("Submit pending transactions")
+ nexusCmd.test("ebics-submit --transient -c $conf").assertOk()
+ }
+ "exit" -> break
+ }
+ }
}
}
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt
@@ -37,6 +37,7 @@ import java.time.ZoneId
import java.util.*
import kotlin.concurrent.fixedRateTimer
import kotlin.io.path.createDirectories
+import kotlin.io.path.*
/**
* Possible stages when an error may occur. These stages
@@ -104,8 +105,7 @@ class NexusSubmitException(
*/
private fun maybeLog(
maybeLogDir: String?,
- xml: String,
- requestUid: String
+ xml: String
) {
if (maybeLogDir == null) {
logger.info("Logging pain.001 to files is disabled")
@@ -115,11 +115,11 @@ private fun maybeLog(
val now = Instant.now()
val asUtcDate = LocalDate.ofInstant(now, ZoneId.of("UTC"))
val subDir = "${asUtcDate.year}-${asUtcDate.monthValue}-${asUtcDate.dayOfMonth}"
- val dirs = Path.of(maybeLogDir, subDir)
+ val dirs = Path(maybeLogDir, subDir)
dirs.createDirectories()
- val f = File(
+ val f = Path(
dirs.toString(),
- "${now.toDbMicros()}_requestUid_${requestUid}_pain.001.xml"
+ "${now.toDbMicros()}_pain.001.xml"
)
// Very rare: same pain.001 should not be submitted twice in the same microsecond.
if (f.exists()) {