gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: testing account deletion


From: gnunet
Subject: [libeufin] branch master updated: testing account deletion
Date: Tue, 30 Jun 2020 17:50:01 +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 29ee48d  testing account deletion
29ee48d is described below

commit 29ee48d6961283946079e3a75ae60dd6abbe80a8
Author: MS <ms@taler.net>
AuthorDate: Tue Jun 30 17:49:51 2020 +0200

    testing account deletion
---
 integration-tests/test-bankConnection.py           | 148 +++++++++++++++++++++
 .../tech/libeufin/nexus/server/NexusServer.kt      |   6 +-
 2 files changed, 151 insertions(+), 3 deletions(-)

diff --git a/integration-tests/test-bankConnection.py 
b/integration-tests/test-bankConnection.py
new file mode 100755
index 0000000..920306e
--- /dev/null
+++ b/integration-tests/test-bankConnection.py
@@ -0,0 +1,148 @@
+#!/usr/bin/env python3
+
+from requests import post, get
+from time import sleep
+import os
+import hashlib
+import base64
+
+from util import startNexus, startSandbox
+
+# Nexus user details
+USERNAME = "person"
+PASSWORD = "y"
+USER_AUTHORIZATION_HEADER = "basic {}".format(
+    base64.b64encode(b"person:y").decode("utf-8")
+)
+
+# Admin authentication
+ADMIN_AUTHORIZATION_HEADER = "basic {}".format(
+    base64.b64encode(b"admin:x").decode("utf-8")
+)
+
+# EBICS details
+EBICS_URL = "http://localhost:5000/ebicsweb";
+HOST_ID = "HOST01"
+PARTNER_ID = "PARTNER1"
+USER_ID = "USER1"
+EBICS_VERSION = "H004"
+
+# Subscriber's bank account
+SUBSCRIBER_IBAN = "GB33BUKB20201555555555"
+SUBSCRIBER_BIC = "BUKBGB22"
+SUBSCRIBER_NAME = "Oliver Smith"
+BANK_ACCOUNT_LABEL = "savings"
+
+# Databases
+NEXUS_DB = "test-nexus.sqlite3"
+
+
+def fail(msg):
+    print(msg)
+    exit(1)
+
+
+def assertResponse(response):
+    if response.status_code != 200:
+        print("Test failed on URL: {}".format(response.url))
+        # stdout/stderr from both services is A LOT of text.
+        # Confusing to dump all that to console.
+        print("Check nexus.log and sandbox.log, probably under /tmp")
+        exit(1)
+    # Allows for finer grained checks.
+    return response
+
+
+startNexus(NEXUS_DB)
+startSandbox()
+
+# 0.a
+assertResponse(
+    post(
+        "http://localhost:5000/admin/ebics/host";,
+        json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION),
+    )
+)
+
+# 0.b
+assertResponse(
+    post(
+        "http://localhost:5000/admin/ebics/subscribers";,
+        json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID),
+    )
+)
+
+# 0.c
+assertResponse(
+    post(
+        "http://localhost:5000/admin/ebics/bank-accounts";,
+        json=dict(
+            subscriber=dict(hostID=HOST_ID, partnerID=PARTNER_ID, 
userID=USER_ID),
+            iban=SUBSCRIBER_IBAN,
+            bic=SUBSCRIBER_BIC,
+            name=SUBSCRIBER_NAME,
+            label=BANK_ACCOUNT_LABEL,
+        ),
+    )
+)
+
+# 1.a, make a new nexus user.
+assertResponse(
+    post(
+        "http://localhost:5001/users";,
+        headers=dict(Authorization=ADMIN_AUTHORIZATION_HEADER),
+        json=dict(username=USERNAME, password=PASSWORD),
+    )
+)
+
+print("creating bank connection")
+
+# make a ebics bank connection for the new user.
+assertResponse(
+    post(
+        "http://localhost:5001/bank-connections";,
+        json=dict(
+            name="my-ebics",
+            source="new",
+            type="ebics",
+            data=dict(
+                ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, 
userID=USER_ID
+            ),
+        ),
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
+    )
+)
+
+assertResponse(
+    post(
+        "http://localhost:5001/bank-connections";,
+        json=dict(
+            name="my-ebics-new",
+            source="new",
+            type="ebics",
+            data=dict(
+                ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, 
userID=USER_ID
+            ),
+        ),
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
+    )
+)
+
+assertResponse(
+    post(
+        "http://localhost:5001/bank-connections/delete-connection";,
+        json=dict(bankConnectionId="my-ebics")
+    )
+)
+
+connectionsList = assertResponse(
+    get("http://localhost:5001/bank-connections";)
+)
+
+for el in connectionsList.json():
+    print(el)
+    if el.get("name") == "my-ebics":
+        print("fail: account not deleted!")
+        exit(1)
+
+print("Test passed!")
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 50022af..fad0b91 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -642,13 +642,13 @@ fun serverMain(dbName: String, host: String) {
                     NexusBankConnectionEntity.all().forEach {
                         connList.add(
                             BankConnectionInfo(
-                                it.id.value,
-                                it.type
+                                name = it.id.value,
+                                type = it.type
                             )
                         )
                     }
                 }
-                call.respond(BankConnectionsList(connList))
+                call.respond(connList)
             }
 
             get("/bank-connections/{connid}") {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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