[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 04/06: Integration test.
From: |
gnunet |
Subject: |
[libeufin] 04/06: Integration test. |
Date: |
Wed, 29 Apr 2020 21:44:43 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
commit f49ae7d5613adc3b6329d04d9c842a7801f97baf
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Apr 29 17:11:24 2020 +0200
Integration test.
Up to the point where the test asks for cardinality
of history set and fails. The failure is due to the
Sandbox that uses a hardcoded response.
---
integration-tests/test-ebics.py | 8 ++++
nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 25 ++---------
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 51 ++++++++++++++++-------
3 files changed, 46 insertions(+), 38 deletions(-)
diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py
index 6736893..5c5fbbb 100755
--- a/integration-tests/test-ebics.py
+++ b/integration-tests/test-ebics.py
@@ -110,6 +110,14 @@ resp = post(
assert(resp.status_code == 200)
# FIXME: assert that history is EMPTY at this point!
+resp = get(
+ "http://localhost:5001/users/{}/history".format(USERNAME)
+)
+
+assert(
+ resp.status_code == 200 and \
+ len(resp.json().get("payments")) == 0
+)
#6 Prepare a payment (via pure Nexus service)
#7 Execute such payment via EBICS
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index 188aa2d..dca0806 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -137,24 +137,6 @@ class TestSubscriber()
/** PAYMENT INSTRUCTIONS TYPES */
-/** Represents a prepared payment at the nexus. This structure is
- * used to SHOW a prepared payment to the caller. */
-data class PaymentInfoElement(
- /**
- * This field is the mnemonic value that bank accounts usually have.
- */
- val debtorAccount: String,
- val creditorIban: String,
- val creditorBic: String,
- val creditorName: String,
- val subject: String,
- val sum: Amount,
- val submitted: Boolean
-)
-data class PaymentsInfo(
- var payments: MutableList<PaymentInfoElement> = mutableListOf()
-)
-
/** This structure is used to INSTRUCT the nexus to prepare such payment. */
data class Pain001Data(
val creditorIban: String,
@@ -166,9 +148,9 @@ data class Pain001Data(
)
/**
- * This type is more of a debug one, and it shows details
- * about one payment that was accounted by the bank (typically
- * in a CAMT.05x entry)
+ * (Very) generic information about one payment. Can be
+ * derived from a CAMT response, or from a prepared PAIN
+ * document.
*/
data class RawPayment(
val creditorIban: String,
@@ -177,7 +159,6 @@ data class RawPayment(
val subject: String,
val date: String
)
-
data class RawPayments(
var payments: MutableList<RawPayment> = mutableListOf()
)
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 1b87c27..59abf55 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -135,14 +135,13 @@ fun main() {
routing {
- /** General / debug endpoints */
+ /** GENERAL / DEBUG ENDPOINTS */
get("/") {
call.respondText("Hello by Nexus!\n")
return@get
}
-
- get("/taler/test-auth") {
+ get("/test-auth") {
authenticateRequest(call.request.headers["Authorization"])
call.respondText("Authenticated!", ContentType.Text.Plain,
HttpStatusCode.OK)
return@get
@@ -150,6 +149,31 @@ fun main() {
/** USER endpoints (no EBICS) */
+ get("/users/{id}/history") {
+ /** NOTE: behaviour could be augmented by filtering on date
range. */
+ val nexusUser = extractNexusUser(call.parameters["id"])
+ val ret = RawPayments()
+ transaction {
+ RawBankTransactionEntity.find {
+ RawBankTransactionsTable.nexusUser eq
nexusUser.id.value
+ }.forEach {
+ ret.payments.add(
+ RawPayment(
+ debitorIban = it.debitorIban,
+ creditorIban = it.creditorIban,
+ subject = it.unstructuredRemittanceInformation,
+ date = DateTime(it.bookingDate).toDashedDate(),
+ amount = "${it.currency}:${it.amount}"
+ )
+ )
+ }
+ }
+ call.respond(
+ HttpStatusCode.OK,
+ ret
+ )
+ return@get
+ }
/** Lists the users known to this system */
get("/users") {
val ret = NexusUsers()
@@ -176,9 +200,8 @@ fun main() {
call.respond(ret)
return@get
}
-
/** Get all the details associated with a NEXUS user */
- get("/user/{id}") {
+ get("/users/{id}") {
val response = transaction {
val nexusUser = extractNexusUser(call.parameters["id"])
NexusUser(
@@ -188,7 +211,6 @@ fun main() {
call.respond(HttpStatusCode.OK, response)
return@get
}
-
/** Make a new NEXUS user in the system */
post("/users/{id}") {
val newUserId = expectId(call.parameters["id"])
@@ -210,8 +232,7 @@ fun main() {
)
return@post
}
-
- /** List all the bank accounts associated with a given NEXUS user.
*/
+ /** Show bank accounts associated with a given NEXUS user */
get("/users/{id}/accounts") {
// this information is only avaiable *after* HTD or HKD has
been called
val id = expectId(call.parameters["id"])
@@ -236,10 +257,10 @@ fun main() {
)
return@get
}
- /** Show list of payments prepared by calling user. */
+ /** Show PREPARED payments */
get("/users/{id}/payments") {
val nexusUserId = expectId(call.parameters["id"])
- val ret = PaymentsInfo()
+ val ret = RawPayments()
transaction {
val nexusUser = extractNexusUser(nexusUserId)
val bankAccountsMap = UserToBankAccountEntity.find {
@@ -250,14 +271,12 @@ fun main() {
Pain001Table.debtorAccount eq it.bankAccount.iban
}.forEach {
ret.payments.add(
- PaymentInfoElement(
- debtorAccount = it.debtorAccount,
+ RawPayment(
creditorIban = it.creditorIban,
- creditorBic = it.creditorBic,
- creditorName = it.creditorName,
+ debitorIban = "FIXME",
subject = it.subject,
- sum = it.sum,
- submitted = it.submitted // whether Nexus
processed and sent to the bank
+ amount = "${it.currency}:${it.sum}",
+ date = DateTime(it.date).toDashedDate()
)
)
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [libeufin] branch master updated (b6e9340 -> 13bfc9f), gnunet, 2020/04/29
- [libeufin] 02/06: remove empty lines, gnunet, 2020/04/29
- [libeufin] 03/06: Integration test., gnunet, 2020/04/29
- [libeufin] 06/06: Abstracting on "bank account"., gnunet, 2020/04/29
- [libeufin] 04/06: Integration test.,
gnunet <=
- [libeufin] 01/06: Remove notion of "bank customer" from Sandbox., gnunet, 2020/04/29
- [libeufin] 05/06: More "history logic" to the Sandbox., gnunet, 2020/04/29