gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 02/02: Custom DB for tests.


From: gnunet
Subject: [libeufin] 02/02: Custom DB for tests.
Date: Tue, 26 May 2020 13:56:13 +0200

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

ms pushed a commit to branch master
in repository libeufin.

commit c05a2ff6bf6d9d8067aaec6a23f411972295eabf
Author: MS <address@hidden>
AuthorDate: Tue May 26 13:55:28 2020 +0200

    Custom DB for tests.
    
    Plus fixing the conversion from dashed date
    to Long timestamp.
---
 integration-tests/test-ebics-highlevel.py            | 8 +++++---
 nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 5 +++--
 util/src/main/kotlin/time.kt                         | 5 +++--
 util/src/test/kotlin/TimeTest.kt                     | 1 +
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/integration-tests/test-ebics-highlevel.py 
b/integration-tests/test-ebics-highlevel.py
index 2732f77..cf6396b 100755
--- a/integration-tests/test-ebics-highlevel.py
+++ b/integration-tests/test-ebics-highlevel.py
@@ -58,6 +58,8 @@ SUBSCRIBER_BIC = "BUKBGB22"
 SUBSCRIBER_NAME = "Oliver Smith"
 BANK_ACCOUNT_LABEL = "savings"
 
+# Databases
+NEXUS_DB="test-nexus.sqlite3"
 
 def fail(msg):
     print(msg)
@@ -93,17 +95,17 @@ def assertResponse(response):
 # -1 Clean databases and start services.
 os.chdir("..")
 assert 0 == call(["rm", "-f", "sandbox/libeufin-sandbox.sqlite3"])
-assert 0 == call(["rm", "-f", "nexus/libeufin-nexus.sqlite3"])
+assert 0 == call(["rm", "-f", "nexus/{}".format(NEXUS_DB)])
 DEVNULL = open(os.devnull, "w")
 
 assert 0 == call(
-    ["./gradlew", "nexus:run", "--console=plain", "--args=superuser admin 
--password x"]
+    ["./gradlew", "nexus:run", "--console=plain", "--args=superuser admin 
--password x --db-name={}".format(NEXUS_DB)]
 )
 
 # Start nexus
 checkPorts([5001])
 nexus = Popen(
-    ["./gradlew", "nexus:run", "--console=plain", "--args=serve"],
+    ["./gradlew", "nexus:run", "--console=plain", "--args=serve 
--db-name={}".format(NEXUS_DB)],
     stdout=PIPE,
     stderr=PIPE,
 )
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index f648319..0db30ba 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -11,6 +11,7 @@ import tech.libeufin.util.*
 import tech.libeufin.util.ebics_h004.EbicsTypes
 import java.security.interfaces.RSAPublicKey
 import java.time.Instant
+import java.time.LocalDateTime
 import java.time.ZoneId
 import java.time.ZonedDateTime
 import java.time.format.DateTimeFormatter
@@ -123,7 +124,7 @@ fun processCamtMessage(
             currency = 
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Amt']/@Ccy")
             amount = 
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Amt']")
             status = 
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Sts']")
-            this.bookingDate = bookingDate.millis()
+            this.bookingDate = LocalDateTime.from(bookingDate).millis()
             counterpartIban =
                 camt53doc.pickString("//*[local-name()='${if 
(this.transactionType == "DBIT") "CdtrAcct" else 
"DbtrAcct"}']//*[local-name()='IBAN']")
             counterpartName =
@@ -441,7 +442,7 @@ fun authenticateRequest(request: ApplicationRequest): 
NexusUserEntity {
         NexusUsersTable.id eq username
     }.firstOrNull()
     if (user == null) {
-        throw NexusError(HttpStatusCode.Unauthorized, "Unknown user")
+        throw NexusError(HttpStatusCode.Unauthorized, "Unknown user 
'$username'")
     }
     if (!CryptoUtil.checkpw(password, user.passwordHash)) {
         throw NexusError(HttpStatusCode.Forbidden, "Wrong password")
diff --git a/util/src/main/kotlin/time.kt b/util/src/main/kotlin/time.kt
index 653799c..1799c87 100644
--- a/util/src/main/kotlin/time.kt
+++ b/util/src/main/kotlin/time.kt
@@ -15,7 +15,8 @@ fun LocalDateTime.toDashedDate(): String {
 
 fun parseDashedDate(date: String): LocalDateTime {
     val dtf = DateTimeFormatter.ISO_LOCAL_DATE
-    return LocalDateTime.from(LocalDate.parse(date, dtf))
+    val asDate = LocalDate.from(LocalDate.parse(date, dtf))
+    return asDate.atStartOfDay()
 }
 
 fun importDateFromMillis(millis: Long): LocalDateTime {
@@ -26,6 +27,6 @@ fun importDateFromMillis(millis: Long): LocalDateTime {
 }
 
 fun LocalDateTime.millis(): Long {
-    val instant = Instant.from(this)
+    val instant = Instant.from(this.atZone(ZoneId.systemDefault()))
     return instant.toEpochMilli()
 }
\ No newline at end of file
diff --git a/util/src/test/kotlin/TimeTest.kt b/util/src/test/kotlin/TimeTest.kt
index 1bd96fe..d22127b 100644
--- a/util/src/test/kotlin/TimeTest.kt
+++ b/util/src/test/kotlin/TimeTest.kt
@@ -1,4 +1,5 @@
 import org.junit.Test
+import tech.libeufin.util.parseDashedDate
 import java.time.*
 import java.time.format.DateTimeFormatter
 import java.time.temporal.TemporalAccessor

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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