summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-05-26 13:55:28 +0200
committerMS <ms@taler.net>2020-05-26 13:55:28 +0200
commitc05a2ff6bf6d9d8067aaec6a23f411972295eabf (patch)
tree96d944494a1fe1e1edf771a6016584ac4b3b5833
parent4ebe7337a586779b7ae8414523188cdf7e768ed8 (diff)
downloadlibeufin-c05a2ff6bf6d9d8067aaec6a23f411972295eabf.tar.gz
libeufin-c05a2ff6bf6d9d8067aaec6a23f411972295eabf.tar.bz2
libeufin-c05a2ff6bf6d9d8067aaec6a23f411972295eabf.zip
Custom DB for tests.
Plus fixing the conversion from dashed date to Long timestamp.
-rwxr-xr-xintegration-tests/test-ebics-highlevel.py8
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt5
-rw-r--r--util/src/main/kotlin/time.kt5
-rw-r--r--util/src/test/kotlin/TimeTest.kt1
4 files changed, 12 insertions, 7 deletions
diff --git a/integration-tests/test-ebics-highlevel.py b/integration-tests/test-ebics-highlevel.py
index 2732f772..cf6396ba 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 f648319d..0db30ba6 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 653799cd..1799c877 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 1bd96fec..d22127b7 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