commit 82870057112f43f36483542f8b2574e8723113c0
parent 52222ba815fd0b0f31521d7482826ed6536c5bb2
Author: Marcello Stanisci <ms@taler.net>
Date: Wed, 29 Apr 2020 16:49:57 +0200
Integration test.
Bring tests until the history is asked via C53.
This includes the preparation of the Sandbox beforehand.
Diffstat:
3 files changed, 120 insertions(+), 4 deletions(-)
diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python3
+
+from requests import post, get
+
+# Steps implemented in this test.
+#
+# 1 Prepare the Sandbox to run the test.
+# -> Make a EBICS host, and make a EBICS subscriber
+# for the test runner.
+#
+# 2 Prepare the Nexus to run the test.
+# -> Make a Nexus user, and make a EBICS transport
+# entity associated with that user.
+#
+# 3 Upload keys from Nexus to the Bank (INI & HIA)
+# 4 Download key from the Bank (HPB) to the Nexus
+#
+# 5 Request history from the Nexus to the Bank (C53).
+# 6 Verify that history is empty.
+# 7 Issue a payment from Nexus (Prepare & trigger CCT)
+# 8 Request history again, from Nexus to Bank.
+# 9 Verify that previous payment shows up.
+
+
+# Nexus user details
+USERNAME="person"
+
+# EBICS details
+EBICS_URL="http://localhost:5000/ebicsweb"
+HOST_ID="HOST01"
+PARTNER_ID="PARTNER1"
+USER_ID="USER1"
+EBICS_VERSION = "H004"
+
+#0 Prepare Sandbox (make Ebics host & one subscriber)
+resp = post(
+ "http://localhost:5000/admin/ebics-host",
+ json=dict(
+ hostID=HOST_ID,
+ ebicsVersion=EBICS_VERSION
+ )
+)
+
+assert(resp.status_code == 200)
+
+resp = post(
+ "http://localhost:5000/admin/ebics-subscriber",
+ json=dict(
+ hostID=HOST_ID,
+ partnerID=PARTNER_ID,
+ userID=USER_ID
+ )
+)
+
+assert(resp.status_code == 200)
+
+#1 Create a Nexus user
+
+resp = post(
+ "http://localhost:5001/users/{}".format(USERNAME),
+ json=dict(
+ password="secret"
+ )
+)
+
+assert(resp.status_code == 200)
+
+#2 Create a EBICS user
+resp = post(
+ "http://localhost:5001/ebics/subscribers/{}".format(USERNAME),
+ json=dict(
+ ebicsURL=EBICS_URL,
+ hostID=HOST_ID,
+ partnerID=PARTNER_ID,
+ userID=USER_ID
+ )
+)
+
+assert(resp.status_code == 200)
+
+#3 Upload keys to the bank INI & HIA
+resp = post(
+ "http://localhost:5001/ebics/subscribers/{}/sendINI".format(USERNAME),
+ json=dict()
+)
+
+assert(resp.status_code == 200)
+
+resp = post(
+ "http://localhost:5001/ebics/subscribers/{}/sendHIA".format(USERNAME),
+ json=dict()
+)
+
+assert(resp.status_code == 200)
+
+#4 Download keys from the bank HPB
+resp = post(
+ "http://localhost:5001/ebics/subscribers/{}/sync".format(USERNAME),
+ json=dict()
+)
+
+assert(resp.status_code == 200)
+
+#5 Request history via EBICS
+resp = post(
+ "http://localhost:5001/ebics/subscribers/{}/collect-transactions-c53".format(USERNAME),
+ json=dict()
+)
+
+assert(resp.status_code == 200)
+
+# FIXME: assert that history is EMPTY at this point!
+
+#6 Prepare a payment (via pure Nexus service)
+#7 Execute such payment via EBICS
+#8 Request history again via EBICS
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -42,7 +42,7 @@ data class EbicsHostResponse(
)
data class EbicsHostCreateRequest(
- val hostId: String,
+ val hostID: String,
val ebicsVersion: String
)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -194,7 +194,7 @@ fun main() {
else call.respond(resp)
}
/** Create a new EBICS host. */
- post("/ebics/hosts") {
+ post("/admin/ebics-host") {
val req = call.receive<EbicsHostCreateRequest>()
val pairA = CryptoUtil.generateRsaKeyPair(2048)
val pairB = CryptoUtil.generateRsaKeyPair(2048)
@@ -203,7 +203,7 @@ fun main() {
addLogger(StdOutSqlLogger)
EbicsHostEntity.new {
this.ebicsVersion = req.ebicsVersion
- this.hostId = req.hostId
+ this.hostId = req.hostID
this.authenticationPrivateKey = SerialBlob(pairA.private.encoded)
this.encryptionPrivateKey = SerialBlob(pairB.private.encoded)
this.signaturePrivateKey = SerialBlob(pairC.private.encoded)
@@ -211,7 +211,7 @@ fun main() {
}
}
call.respondText(
- "Host '${req.hostId}' created.",
+ "Host '${req.hostID}' created.",
ContentType.Text.Plain,
HttpStatusCode.OK
)