commit dd83dec27aec3bd5ce57bc667af40a2d24e8a552
parent ed19bbcaea3c5b5e8d86112e89e6d8de4e485741
Author: MS <ms@taler.net>
Date: Thu, 3 Sep 2020 17:02:40 +0200
fixing tests
Diffstat:
4 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/integration-tests/test-sandbox.py b/integration-tests/test-sandbox.py
@@ -33,7 +33,7 @@ def assertResponse(response):
print("Test failed on URL: {}".format(response.url))
# stdout/stderr from both services is A LOT of text.
# Confusing to dump all that to console.
- print("Check sandbox.log, probably under /tmp")
+ print("Status code was: " + str(response.status_code))
exit(1)
# Allows for finer grained checks.
return response
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -326,7 +326,6 @@ fun buildCamtString(type: Int, subscriberIban: String, history: MutableList<RawP
} // date of assets' actual (un)availability
element("AcctSvcrRef") {
val uid = if (it.uid != null) it.uid.toString() else {
- LOGGER.error("")
throw EbicsRequestError(
errorCode = "091116",
errorText = "EBICS_PROCESSING_ERROR"
@@ -485,7 +484,10 @@ private fun constructCamtResponse(
date = importDateFromMillis(it[date]).toDashedDate(),
amount = it[amount],
currency = it[currency],
- uid = "${it[pmtInfId]}-${it[msgId]}"
+ // The line below produces a value too long (>35 chars),
+ // and it makes the document invalid!
+ // uid = "${it[pmtInfId]}-${it[msgId]}"
+ uid = "${it[pmtInfId]}"
)
)
}
@@ -572,7 +574,7 @@ private fun handleCct(paymentRequest: String, initiatorName: String, ctx: Reques
transaction {
try {
BankAccountTransactionsTable.insert {
- it[account] = getBankAccountFromPain(parseResult).id
+ it[account] = getBankAccountFromIban(parseResult.debitorIban).id
it[creditorIban] = parseResult.creditorIban
it[creditorName] = parseResult.creditorName
it[debitorIban] = parseResult.debitorIban
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -38,15 +38,14 @@ fun getOrderTypeFromTransactionId(transactionID: String): String {
return uploadTransaction.orderType
}
-fun getBankAccountFromPain(painParseResult: PainParseResult): BankAccountEntity {
+fun getBankAccountFromIban(iban: String): BankAccountEntity {
return transaction {
BankAccountEntity.find(
- BankAccountsTable.iban eq
- painParseResult.debitorIban
+ BankAccountsTable.iban eq iban
)
}.firstOrNull() ?: throw SandboxError(
HttpStatusCode.NotFound,
- "Did not find a bank account for ${painParseResult.debitorIban}"
+ "Did not find a bank account for ${iban}"
)
}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -75,7 +75,7 @@ import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorName
import tech.libeufin.util.*
import tech.libeufin.util.ebics_h004.EbicsResponse
import tech.libeufin.util.ebics_h004.EbicsTypes
-import java.util.UUID
+import kotlin.random.Random
class CustomerNotFound(id: String?) : Exception("Customer ${id} not found")
class BadInputData(inputData: String?) : Exception("Customer provided invalid input data: ${inputData}")
@@ -263,19 +263,24 @@ fun serverMain(dbName: String) {
*/
post("/admin/payments") {
val body = call.receive<RawPayment>()
+ val random = Random.nextLong()
transaction {
- BankAccountTransactionsTable.insert {
- it[creditorIban] = body.creditorIban
- it[creditorBic] = body.creditorBic
- it[creditorName] = body.creditorName
- it[debitorIban] = body.debitorIban
- it[debitorBic] = body.debitorBic
- it[debitorName] = body.debitorName
- it[subject] = body.subject
- it[amount] = body.amount
- it[currency] = body.currency
- it[date] = Instant.now().toEpochMilli()
- }
+ val debitorBankAccount = getBankAccountFromIban(body.debitorIban).id
+ BankAccountTransactionsTable.insert {
+ it[creditorIban] = body.creditorIban
+ it[creditorBic] = body.creditorBic
+ it[creditorName] = body.creditorName
+ it[debitorIban] = body.debitorIban
+ it[debitorBic] = body.debitorBic
+ it[debitorName] = body.debitorName
+ it[subject] = body.subject
+ it[amount] = body.amount
+ it[currency] = body.currency
+ it[date] = Instant.now().toEpochMilli()
+ it[pmtInfId] = random.toString()
+ it[msgId] = random.toString()
+ it[account] = debitorBankAccount
+ }
}
call.respondText("Payment created")
return@post