gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/06: Integration tests.


From: gnunet
Subject: [libeufin] 01/06: Integration tests.
Date: Sun, 15 Nov 2020 22:06:52 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit ea502185c7e76f49724e970350bb40588f7037b3
Author: MS <ms@taler.net>
AuthorDate: Fri Nov 13 22:21:18 2020 +0100

    Integration tests.
    
    Preparing services and let pytest be launched via Makefile.
---
 Makefile                   |   5 ++
 integration-tests/test.py  |  64 ---------------------
 integration-tests/tests.py | 135 +++++++++++++++++++++++++++++++++++++++++++++
 integration-tests/util.py  |   6 +-
 4 files changed, 141 insertions(+), 69 deletions(-)

diff --git a/Makefile b/Makefile
index 4c22294..a454ceb 100644
--- a/Makefile
+++ b/Makefile
@@ -39,3 +39,8 @@ assemble:
 .PHONY: check
 check:
        @./gradlew check
+
+
+.PHONY: tests
+tests:
+       @cd integration-tests; py.test tests.py; cd ..
diff --git a/integration-tests/test.py b/integration-tests/test.py
deleted file mode 100755
index cd77b44..0000000
--- a/integration-tests/test.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python3
-
-from util import startNexus, startSandbox, assertResponse, flushTablesSandbox
-from requests import post, get
-
-# Databases
-NEXUS_DB="/tmp/test-nexus.sqlite3"
-SANDBOX_DB="/tmp/test-sandbox.sqlite3"
-
-# Nexus user details
-NEXUS_USERNAME = "person"
-NEXUS_PASSWORD = "y"
-
-# EBICS details
-EBICS_URL = "http://localhost:5000/ebicsweb";
-EBICS_HOST = "HOST01"
-EBICS_PARTNER = "PARTNER1"
-EBICS_USER = "USER1"
-EBICS_VERSION = "H004"
-
-# Subscriber's bank account at the Sandbox
-BANK_IBAN = "GB33BUKB20201555555555"
-BANK_BIC = "BUKBGB22"
-BANK_NAME = "Oliver Smith"
-BANK_LABEL = "savings"
-
-def prepareSandbox():
-    # make ebics host at sandbox
-    assertResponse(
-        post(
-            "http://localhost:5000/admin/ebics/host";,
-            json=dict(hostID=EBICS_HOST, ebicsVersion=EBICS_VERSION),
-        )
-    )
-    
-    # make new ebics subscriber at sandbox
-    assertResponse(
-        post(
-            "http://localhost:5000/admin/ebics/subscribers";,
-            json=dict(hostID=EBICS_HOST, partnerID=EBICS_PARTNER, 
userID=EBICS_USER),
-        )
-    )
-    
-    # give a bank account to such subscriber, at sandbox
-    assertResponse(
-        post(
-            "http://localhost:5000/admin/ebics/bank-accounts";,
-            json=dict(
-                subscriber=dict(hostID=EBICS_HOST, partnerID=EBICS_PARTNER, 
userID=EBICS_USER),
-                iban=BANK_IBAN,
-                bic=BANK_BIC,
-                name=BANK_NAME,
-                label=BANK_LABEL
-            )
-        )
-    )
-
-startNexus(NEXUS_DB)
-startSandbox(SANDBOX_DB)
-
-prepareSandbox()
-print("Services correctly started.")
-print("Emptying tables at Sandbox")
-flushTablesSandbox(SANDBOX_DB)
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
new file mode 100755
index 0000000..ff15ead
--- /dev/null
+++ b/integration-tests/tests.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python3
+
+from requests import post, get, auth
+from util import (
+    startNexus,
+    startSandbox,
+    assertResponse,
+    flushTablesSandbox,
+    flushTablesNexus
+)
+
+# Databases
+NEXUS_DB="/tmp/test-nexus.sqlite3"
+SANDBOX_DB="/tmp/test-sandbox.sqlite3"
+
+# Nexus user details
+NEXUS_USERNAME = "person"
+NEXUS_PASSWORD = "y"
+NEXUS_BANK_CONNECTION="my-ebics"
+NEXUS_BANK_LABEL="local-savings"
+NEXUS_AUTH = auth.HTTPBasicAuth(
+    NEXUS_USERNAME,
+    NEXUS_PASSWORD
+)
+
+# EBICS details
+EBICS_URL = "http://localhost:5000/ebicsweb";
+EBICS_HOST = "HOST01"
+EBICS_PARTNER = "PARTNER1"
+EBICS_USER = "USER1"
+EBICS_VERSION = "H004"
+
+# Subscriber's bank account at the Sandbox
+BANK_IBAN = "GB33BUKB20201555555555"
+BANK_BIC = "BUKBGB22"
+BANK_NAME = "Oliver Smith"
+BANK_LABEL = "savings"
+
+def prepareSandbox():
+    # make ebics host at sandbox
+    assertResponse(
+        post(
+            "http://localhost:5000/admin/ebics/host";,
+            json=dict(hostID=EBICS_HOST, ebicsVersion=EBICS_VERSION),
+        )
+    )
+    # make new ebics subscriber at sandbox
+    assertResponse(
+        post(
+            "http://localhost:5000/admin/ebics/subscribers";,
+            json=dict(hostID=EBICS_HOST, partnerID=EBICS_PARTNER, 
userID=EBICS_USER),
+        )
+    )
+    # give a bank account to such subscriber, at sandbox
+    assertResponse(
+        post(
+            "http://localhost:5000/admin/ebics/bank-accounts";,
+            json=dict(
+                subscriber=dict(hostID=EBICS_HOST, partnerID=EBICS_PARTNER, 
userID=EBICS_USER),
+                iban=BANK_IBAN,
+                bic=BANK_BIC,
+                name=BANK_NAME,
+                label=BANK_LABEL
+            )
+        )
+    )
+
+def prepareNexus():
+    # make a new nexus user.
+    assertResponse(
+        post(
+            "http://localhost:5001/users";,
+            auth=auth.HTTPBasicAuth("admin", "x"),
+            json=dict(username=NEXUS_USERNAME, password=NEXUS_PASSWORD),
+        )
+    )
+    # make a ebics bank connection for the new user.
+    assertResponse(
+        post(
+            "http://localhost:5001/bank-connections";,
+            json=dict(
+                name=NEXUS_BANK_CONNECTION,
+                source="new",
+                type="ebics",
+                data=dict(
+                    ebicsURL=EBICS_URL,
+                    hostID=EBICS_HOST,
+                    partnerID=EBICS_PARTNER,
+                    userID=EBICS_USER
+                ),
+            ),
+            auth=NEXUS_AUTH
+        )
+    )
+    # synchronizing the connection
+    assertResponse(
+        post(
+            "http://localhost:5001/bank-connections/my-ebics/connect";,
+            json=dict(),
+            auth=NEXUS_AUTH
+        )
+    )
+    # download offered bank accounts
+    assertResponse(
+        post(
+            "http://localhost:5001/bank-connections/my-ebics/fetch-accounts";,
+            json=dict(),
+            auth=NEXUS_AUTH
+        )
+    )
+    # import one bank account into the Nexus
+    assertResponse(
+        post(
+            "http://localhost:5001/bank-connections/my-ebics/import-account";,
+            json=dict(
+                offeredAccountId=BANK_LABEL,
+                nexusBankAccountId=NEXUS_BANK_LABEL
+            ),
+            auth=NEXUS_AUTH
+        )
+    )
+
+startNexus(NEXUS_DB)
+startSandbox(SANDBOX_DB)
+
+prepareSandbox()
+prepareNexus()
+
+#def test_0():
+#    assertResponse(
+#        REQUEST HERE!
+#    )
+
+flushTablesNexus(NEXUS_DB)
+flushTablesSandbox(SANDBOX_DB)
diff --git a/integration-tests/util.py b/integration-tests/util.py
index 27d8d17..6c9ebe8 100644
--- a/integration-tests/util.py
+++ b/integration-tests/util.py
@@ -155,8 +155,4 @@ def startNexus(dbname="nexus-test.sqlite3"):
     return nexus
 
 def assertResponse(response, acceptedResponses=[200]):
-    if response.status_code not in acceptedResponses:
-        print("Test failed on URL: {}, status: {}".format(
-            response.url, response.status_code))
-        exit(1)
-    return response
+    assert response.status_code in acceptedResponses

-- 
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]