gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: integration test


From: gnunet
Subject: [libeufin] branch master updated: integration test
Date: Tue, 12 May 2020 19:49:32 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 0661cf1  integration test
0661cf1 is described below

commit 0661cf1597f110b782154de202ce06d24f7e8946
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue May 12 19:48:49 2020 +0200

    integration test
    
    Up to the point where a new Ebics transport
    is being created, but parsing the request body fails.
---
 integration-tests/test-ebics-new.py               | 39 ++++++++++++++---------
 nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt |  9 +++---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 30 +++++++++--------
 3 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/integration-tests/test-ebics-new.py 
b/integration-tests/test-ebics-new.py
index 3f89f77..9f4047c 100755
--- a/integration-tests/test-ebics-new.py
+++ b/integration-tests/test-ebics-new.py
@@ -92,9 +92,10 @@ for i in range(10):
         if i == 9:
             nexus.terminate()
             stdout, stderr = nexus.communicate()
+            print("Nexus timed out")
             print("{}\n{}".format(stdout.decode(), stderr.decode()))
             exit(77)
-        sleep(1)
+        sleep(2)
         continue
     break
 # Start sandbox
@@ -108,9 +109,10 @@ for i in range(10):
             nexus.terminate()
             sandbox.terminate()
             stdout, stderr = nexus.communicate()
+            print("Sandbox timed out")
             print("{}\n{}".format(stdout.decode(), stderr.decode()))
             exit(77)
-        sleep(1)
+        sleep(2)
         continue
     break
 
@@ -169,7 +171,7 @@ dbconn.close()
 assertResponse(
     post(
         "http://localhost:5001/users";,
-        headers=dict(authorization=ADMIN_AUTHORIZATION_HEADER),
+        headers=dict(Authorization=ADMIN_AUTHORIZATION_HEADER),
         json=dict(
         username=USERNAME,
         password=PASSWORD
@@ -177,23 +179,30 @@ assertResponse(
     )
 )
 
-nexus.terminate()
-sandbox.terminate()
-print("All done!")
-exit(44)
-
-#1.b
+#1.b, make a ebics transport for the new user.
 assertResponse(
     post(
-        "http://localhost:5001/ebics/subscribers/{}".format(USERNAME),
+        "http://localhost:5001/bank-transports";,
         json=dict(
-        ebicsURL=EBICS_URL,
-        hostID=HOST_ID,
-        partnerID=PARTNER_ID,
-        userID=USER_ID
-        )
+            transport=dict(
+                name="my-ebics",
+                type="ebics"
+            ),
+            data=dict(
+                ebicsURL=EBICS_URL,
+                hostID=HOST_ID,
+                partnerID=PARTNER_ID,
+                userID=USER_ID
+            )
+        ),
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER)
     )
 )
+
+nexus.terminate()
+sandbox.terminate()
+exit(44)
+
 #2.a
 assertResponse(
     post(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index ef70927..0b80677 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -80,10 +80,9 @@ data class RawPayments(
  *  API types (used as requests/responses types) *
  *************************************************/
 data class BankTransport(
-    val name: String,
-    val backup: Any, // only EbicsKeysBackupJson exists now.
-    val new: Any,
-    val type: String
+    val transport: tech.libeufin.nexus.Transport,
+    val backup: Any?,
+    val data: Any?
 )
 
 /**
@@ -107,7 +106,7 @@ data class EbicsNewTransport(
     val partnerID: String,
     val hostID: String,
     val ebicsURL: String,
-    val systemID: String
+    val systemID: String?
 )
 
 /** Response type of "GET /prepared-payments/{uuid}" */
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index dd94526..488dce7 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -405,8 +405,10 @@ fun main() {
                 val userId = 
authenticateRequest(call.request.headers["Authorization"])
                 // user exists and is authenticated.
                 val body = call.receive<BankTransport>()
+                logger.debug("Request body parsed")
                 when (body.backup) {
                     is EbicsKeysBackupJson -> {
+                        logger.debug("Restoring a transport: 
${body.transport.name}")
                         val (authKey, encKey, sigKey) = try {
                             Triple(
                                 CryptoUtil.decryptKey(
@@ -433,7 +435,7 @@ fun main() {
                         logger.info("Restoring keys, creating new user: 
$userId")
                         try {
                             transaction {
-                                EbicsSubscriberEntity.new(userId) {
+                                EbicsSubscriberEntity.new(body.transport.name) 
{
                                     this.nexusUser = extractNexusUser(userId)
                                     ebicsURL = body.backup.ebicsURL
                                     hostID = body.backup.hostID
@@ -451,34 +453,34 @@ fun main() {
                             )
                             return@post
                         }
+                        call.respondText("Backup restored")
+                        return@post
                     }
                 }
-                when (body.new) {
+                when (body.data) {
                     is EbicsNewTransport -> {
+                        logger.debug("Creating new transport: 
${body.transport.name}")
                         val pairA = CryptoUtil.generateRsaKeyPair(2048)
                         val pairB = CryptoUtil.generateRsaKeyPair(2048)
                         val pairC = CryptoUtil.generateRsaKeyPair(2048)
                         transaction {
-                            EbicsSubscriberEntity.new {
+                            EbicsSubscriberEntity.new(body.transport.name) {
                                 nexusUser = extractNexusUser(userId)
-                                ebicsURL = body.new.ebicsURL
-                                hostID = body.new.hostID
-                                partnerID = body.new.partnerID
-                                userID = body.new.userID
-                                systemID = body.new.systemID
+                                ebicsURL = body.data.ebicsURL
+                                hostID = body.data.hostID
+                                partnerID = body.data.partnerID
+                                userID = body.data.userID
+                                systemID = body.data.systemID
                                 signaturePrivateKey = 
SerialBlob(pairA.private.encoded)
                                 encryptionPrivateKey = 
SerialBlob(pairB.private.encoded)
                                 authenticationPrivateKey = 
SerialBlob(pairC.private.encoded)
                             }
                         }
-                        call.respondText(
-                            "EBICS user successfully created",
-                            ContentType.Text.Plain,
-                            HttpStatusCode.OK
-                        )
+                        call.respondText("EBICS user successfully created")
                         return@post
                     }
-                }
+                } // end of second 'when'.
+
                 call.respond(
                     HttpStatusCode.BadRequest,
                     "Neither backup nor new transport given in request"

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]