[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated (43e7d55 -> c05a2ff)
From: |
gnunet |
Subject: |
[libeufin] branch master updated (43e7d55 -> c05a2ff) |
Date: |
Tue, 26 May 2020 13:56:11 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a change to branch master
in repository libeufin.
from 43e7d55 migrating to java.time
new 4ebe733 admit --db option
new c05a2ff Custom DB for tests.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
integration-tests/test-ebics-highlevel.py | 8 +++++---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 4 ++--
nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 5 +++--
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 14 ++++++++------
util/src/main/kotlin/time.kt | 5 +++--
util/src/test/kotlin/TimeTest.kt | 1 +
6 files changed, 22 insertions(+), 15 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/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 72becea..4566792 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -269,8 +269,8 @@ class NexusBankConnectionEntity(id: EntityID<String>) :
Entity<String>(id) {
var owner by NexusUserEntity referencedOn NexusBankConnectionsTable.owner
}
-fun dbCreateTables() {
- Database.connect("jdbc:sqlite:libeufin-nexus.sqlite3", "org.sqlite.JDBC")
+fun dbCreateTables(dbName: String) {
+ Database.connect("jdbc:sqlite:${dbName}", "org.sqlite.JDBC")
TransactionManager.manager.defaultIsolationLevel =
Connection.TRANSACTION_SERIALIZABLE
transaction {
addLogger(StdOutSqlLogger)
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/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 5a30093..017a27e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -32,6 +32,8 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.ProgramResult
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.arguments.argument
+import com.github.ajalt.clikt.parameters.arguments.default
+import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.prompt
import io.ktor.application.ApplicationCall
@@ -80,17 +82,18 @@ class NexusCommand : CliktCommand() {
}
class Serve : CliktCommand("Run nexus HTTP server") {
+ private val dbName by option().default("libeufin-nexus.sqlite3")
override fun run() {
- serverMain()
+ serverMain(dbName)
}
}
-
class Superuser : CliktCommand("Add superuser or change pw") {
+ private val dbName by option().default("libeufin-nexus.sqlite3")
private val username by argument()
private val password by option().prompt(requireConfirmation = true,
hideInput = true)
override fun run() {
- dbCreateTables()
+ dbCreateTables(dbName)
transaction {
val hashedPw = hashpw(password)
val user = NexusUserEntity.findById(username)
@@ -221,9 +224,8 @@ fun requireBankConnection(call: ApplicationCall,
parameterKey: String): NexusBan
return conn
}
-
-fun serverMain() {
- dbCreateTables()
+fun serverMain(dbName: String) {
+ dbCreateTables(dbName)
val client = HttpClient {
expectSuccess = false // this way, it does not throw exceptions on !=
200 responses.
}
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.
- [libeufin] branch master updated (43e7d55 -> c05a2ff),
gnunet <=