commit 7dfef458b8e5feb726117b8b3105bb524c84b5e2
parent 105bed2923db9542c5c924a8861412c01ddf75ac
Author: MS <ms@taler.net>
Date: Sat, 7 Jan 2023 13:43:38 +0100
Test debit detection when serving EBICS.
Diffstat:
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/nexus/src/test/kotlin/DownloadAndSubmit.kt b/nexus/src/test/kotlin/DownloadAndSubmit.kt
@@ -301,4 +301,29 @@ class DownloadAndSubmit {
}
}
}
+
+ // Test the EBICS error message in case of debt threshold being surpassed
+ @Test
+ fun testDebit() {
+ withNexusAndSandboxUser {
+ testApplication {
+ application(sandboxApp)
+ runBlocking {
+ // Create Pain.001 with excessive amount.
+ addPaymentInitiation(
+ Pain001Data(
+ creditorIban = getIban(),
+ creditorBic = "SANDBOXX",
+ creditorName = "Tester",
+ subject = "test payment",
+ sum = "1000000",
+ currency = "TESTKUDOS"
+ ),
+ "foo"
+ )
+ assertException<EbicsProtocolError> { submitAllPaymentInitiations(client, "foo") }
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/nexus/src/test/kotlin/MakeEnv.kt b/nexus/src/test/kotlin/MakeEnv.kt
@@ -31,6 +31,18 @@ val userKeys = EbicsKeys(
enc = CryptoUtil.generateRsaKeyPair(2048),
sig = CryptoUtil.generateRsaKeyPair(2048)
)
+
+// New versions of JUnit provide this!
+inline fun <reified ExceptionType> assertException(block: () -> Unit) {
+ try {
+ block()
+ } catch (e: Throwable) {
+ assert(e.javaClass == ExceptionType::class.java)
+ return
+ }
+ return assert(false)
+}
+
/**
* Run a block after connecting to the test database.
* Cleans up the DB file afterwards.