commit 38599d632ec4e5b31af7ea98e0c8ac4423c470f9
parent 81ecdd6bf707bc41f028ff7da71dc30f4f576a49
Author: Florian Dold <florian.dold@gmail.com>
Date: Tue, 11 Feb 2020 16:15:01 +0100
API skeleton
Diffstat:
5 files changed, 96 insertions(+), 48 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Db.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Db.kt
@@ -11,38 +11,50 @@ import java.sql.Connection
const val ID_MAX_LENGTH = 50
-object EbicsRawBankTransactionsTable : IdTable<Long>() {
- override val id = EbicsSubscribersTable.long("id").entityId().primaryKey()
-
- val nexusSubscriber = reference("subscriber", EbicsSubscribersTable)
-
- /**
- * How did we learn about this transaction? C52 / C53 / C54
- */
- val sourceType = text("sourceType")
-
- val sourceFileName = text("sourceFileName")
-
-
-
- /**
- * "Subject" of the SEPA transaction
- */
- val unstructuredRemittanceInformation = text("unstructuredRemittanceInformation")
-
- /**
- * Is it a credit or debit transaction?
- */
- val transactionType = text("transactionType")
-
- val currency = text("currency")
-
- val amount = text("amount")
-
- val creditorIban = text("creditorIban")
-
- val debitorIban = text("creditorIban")
-}
+//object EbicsRawBankTransactionsTable : IdTable<Long>() {
+// override val id = EbicsSubscribersTable.long("id").entityId().primaryKey()
+//
+// val nexusSubscriber = reference("subscriber", EbicsSubscribersTable)
+//
+// /**
+// * How did we learn about this transaction? C52 / C53 / C54
+// */
+// val sourceType = text("sourceType")
+//
+// val sourceFileName = text("sourceFileName")
+//
+//
+//
+// /**
+// * "Subject" of the SEPA transaction
+// */
+// val unstructuredRemittanceInformation = text("unstructuredRemittanceInformation")
+//
+// /**
+// * Is it a credit or debit transaction?
+// */
+// val transactionType = text("transactionType")
+//
+// val currency = text("currency")
+//
+// val amount = text("amount")
+//
+// val creditorIban = text("creditorIban")
+//
+// val debitorIban = text("creditorIban")
+//}
+//
+//
+///**
+// * This table gets populated by the HTD request.
+// *
+// * It stores which subscriber has access to which bank accounts via EBICS.
+// *
+// * When making a payment, we need to refer to one of these accounts
+// */
+//object EbicsBankAccountsTable {
+//
+//}
object EbicsSubscribersTable : IdTable<String>() {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -288,8 +288,41 @@ fun main() {
}
}
+ post("/ebics/subscribers/fetch-accounts") {
+ // FIXME(marcello): fetch accounts via HTD and store it in the database
+ }
+
+ get("/ebics/subscribers/{id}/accounts") {
+ // FIXME(marcello): return bank accounts associated with the subscriber,
+ // this information is only avaiable *after* HTD or HKD has been called
+ }
+
+ post("/ebics/subscribers/{id}/accounts/{acctid}/prepare-payment") {
+ // FIXME(marcello): Put transaction in the database, generate PAIN.001 document
+ }
+
+ get("/ebics/subscribers/{id}/payments") {
+ // FIXME(marcello): List all outgoing transfers and their status
+ }
+
+ post("/ebics/subscribers/{id}/fetch-payment-status") {
+ // FIXME(marcello?): Fetch pain.002 and mark transfers in it as "failed"
+ }
+
post("/ebics/subscribers/{id}/collect-transactions-c52") {
- // Download C52 and store the result in the right database table
+ // FIXME(florian): Download C52 and store the result in the right database table
+ }
+
+ post("/ebics/subscribers/{id}/collect-transactions-c53") {
+ // FIXME(florian): Download C52 and store the result in the right database table
+ }
+
+ post("/ebics/subscribers/{id}/collect-transactions-c54") {
+ // FIXME(florian): Download C52 and store the result in the right database table
+ }
+
+ get("/ebics/subscribers/{id}/transactions") {
+ // FIXME(florian): Display local transaction history stored by the nexus.
}
post("/ebics/subscribers/{id}/sendC52") {
diff --git a/nexus/src/test/kotlin/LetterFormatTest.kt b/nexus/src/test/kotlin/LetterFormatTest.kt
@@ -4,6 +4,17 @@ import org.junit.Test
import tech.libeufin.nexus.chunkString
import tech.libeufin.nexus.getNonce
import tech.libeufin.util.toHexString
+import java.security.SecureRandom
+
+/**
+ * @param size in bits
+ */
+private fun getNonce(size: Int): ByteArray {
+ val sr = SecureRandom()
+ val ret = ByteArray(size / 8)
+ sr.nextBytes(ret)
+ return ret
+}
class LetterFormatTest {
diff --git a/util/src/test/kotlin/LogTest.kt b/util/src/test/kotlin/LogTest.kt
@@ -1,13 +1,8 @@
-import org.junit.Assert
import org.junit.Test
-import org.junit.Assert.*
import org.slf4j.LoggerFactory
-import java.net.URLClassLoader
-import tech.libeufin.util.LOGGER as utilLogger
class LogTest {
-
@Test
fun logLine() {
val loggerSandbox = LoggerFactory.getLogger("tech.libeufin.sandbox")
@@ -15,11 +10,4 @@ class LogTest {
loggerSandbox.info("line")
loggerNexus.trace("other line")
}
-
- @Test
- fun logFromUtil() {
- /* This log should show up with 'util' name but without this latter owning a logback.xml */
- utilLogger.trace("shown")
- }
}
-
diff --git a/util/src/test/kotlin/XmlUtilTest.kt b/util/src/test/kotlin/XmlUtilTest.kt
@@ -1,6 +1,8 @@
import org.apache.xml.security.binding.xmldsig.SignatureType
import org.junit.Test
import org.junit.Assert.*
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import tech.libeufin.util.ebics_h004.EbicsKeyManagementResponse
import tech.libeufin.util.ebics_h004.EbicsResponse
import tech.libeufin.util.ebics_h004.EbicsTypes
@@ -10,9 +12,11 @@ import tech.libeufin.util.XMLUtil
import java.security.KeyPairGenerator
import java.util.*
import javax.xml.transform.stream.StreamSource
-import tech.libeufin.util.LOGGER
import tech.libeufin.util.XMLUtil.Companion.signEbicsResponse
+val logger: Logger = LoggerFactory.getLogger("tech.libeufin.util")
+
+
class XmlUtilTest {
@Test
@@ -64,7 +68,7 @@ class XmlUtilTest {
</HTDResponseOrderData>""".trimIndent()
)
- LOGGER.debug(tmp.value.partnerInfo.orderInfoList[0].description)
+ logger.debug(tmp.value.partnerInfo.orderInfoList[0].description)
}
@Test
@@ -73,7 +77,7 @@ class XmlUtilTest {
XMLUtil.convertStringToJaxb<EbicsKeyManagementResponse>("<malformed xml>")
} catch (e: javax.xml.bind.UnmarshalException) {
// just ensuring this is the exception
- LOGGER.info("caught")
+ logger.info("caught")
return
}
assertTrue(false)