gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: fixing tests


From: gnunet
Subject: [libeufin] branch master updated: fixing tests
Date: Thu, 03 Sep 2020 17:02:50 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new dd83dec  fixing tests
dd83dec is described below

commit dd83dec27aec3bd5ce57bc667af40a2d24e8a552
Author: MS <ms@taler.net>
AuthorDate: Thu Sep 3 17:02:40 2020 +0200

    fixing tests
---
 integration-tests/test-sandbox.py                  |  2 +-
 .../tech/libeufin/sandbox/EbicsProtocolBackend.kt  |  8 +++---
 .../main/kotlin/tech/libeufin/sandbox/Helpers.kt   |  7 +++--
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 31 +++++++++++++---------
 4 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/integration-tests/test-sandbox.py 
b/integration-tests/test-sandbox.py
index f049de2..fd6a1f3 100755
--- 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
index 2996c85..e93c79d 100644
--- 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
index 9e7040a..67d17a9 100644
--- 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
index 5e3686d..38469a9 100644
--- 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

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]