gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: checks (work in progress)


From: gnunet
Subject: [libeufin] branch master updated: checks (work in progress)
Date: Thu, 29 Oct 2020 22:27:59 +0100

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 2c20308  checks (work in progress)
2c20308 is described below

commit 2c20308c86309fccb3843d095c89320a6995e49e
Author: MS <ms@taler.net>
AuthorDate: Thu Oct 29 22:27:55 2020 +0100

    checks (work in progress)
---
 integration-tests/all.sh                           |  2 +-
 integration-tests/json_checks.py                   | 51 ++++++++++++++++++++++
 integration-tests/test-bankAccount.py              |  2 +
 integration-tests/test-bankConnection.py           | 11 ++++-
 integration-tests/test-ebics-highlevel.py          |  4 +-
 integration-tests/test-ebics.py                    | 13 ++++--
 integration-tests/util.py                          |  2 +-
 .../tech/libeufin/nexus/server/NexusServer.kt      |  2 +-
 8 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/integration-tests/all.sh b/integration-tests/all.sh
index c8dd215..4eb3241 100755
--- a/integration-tests/all.sh
+++ b/integration-tests/all.sh
@@ -6,7 +6,7 @@ set -e
 ./test-ebics-highlevel.py
 ./test-ebics.py
 ./test-sandbox.py
-./test-taler-facade.py
+./test-taler-facade.py 
 ./test-bankConnection.py
 ./test-ebics-double-payment-submission.py
 echo "All tests passed."
diff --git a/integration-tests/json_checks.py b/integration-tests/json_checks.py
index a0a54bc..916712a 100644
--- a/integration-tests/json_checks.py
+++ b/integration-tests/json_checks.py
@@ -10,6 +10,15 @@ def checkNewUserRequest(json):
     c = T(F("username"), F("password"))
     return c.check(json)
 
+def checkBankAccountElement(json):
+    c = T(
+        F("nexusBankAccountId"),
+        F("iban"),
+        F("bic"),
+        F("ownerName")
+    )
+    return c.check(json)
+
 def checkPreparePayment(json):
     c = T(
         F("iban"),
@@ -20,10 +29,51 @@ def checkPreparePayment(json):
     )
     return c.check(json)
 
+def checkBankConnection(json):
+    c = T(
+        F("bankConnectionId"),
+        F("bankConnectionType"),
+        F("ready"),
+        F("bankKeysReviewed")
+    )
+    return c.check(json)
+
+def checkDeleteConnection(json):
+    c = T(F("bankConnectionId"))
+    return c.check(json)
+
+def checkConnectionListElement(json):
+    c = T(
+        F("name"),
+        F("type")
+    )
+    return c.check(json)
+
 def checkPreparedPaymentResponse(json):
     c = T(F("uuid"))
     return c.check(json)
 
+def checkPreparedPaymentElement(json):
+    c = T(
+        F("paymentInitiationId"),
+        F("submitted"),
+        F("creditorIban"),
+        F("creditorBic"),
+        F("creditorName"),
+        F("amount"),
+        F("subject"),
+        F("submissionDate"),
+        F("preparationDate")
+    )
+    return c.check(json)
+
+def checkFetchTransactions(json):
+    c = T(
+            F("rangeType"),
+            F("level")
+    )
+    return c.check(json)
+
 def checkTransaction(json):
     c = T(
             F("account"),
@@ -34,6 +84,7 @@ def checkTransaction(json):
             F("date"),
             F("subject")
     )
+    return c.check(json)
 
 def checkNewEbicsConnection(json):
     c = T(
diff --git a/integration-tests/test-bankAccount.py 
b/integration-tests/test-bankAccount.py
index a640aa8..29baa94 100755
--- a/integration-tests/test-bankAccount.py
+++ b/integration-tests/test-bankAccount.py
@@ -7,6 +7,7 @@ import hashlib
 import base64
 
 from util import startNexus, startSandbox, assertResponse
+from json_checks import checkNewUserRequest, checkBankAccountElement
 
 # Nexus user details
 USERNAME = "person"
@@ -153,6 +154,7 @@ listOfferedAccountsAfter = assertResponse(
 )
 
 for el in listOfferedAccountsAfter.json().get("accounts"):
+    checkBankAccountElement(el)
     if el.get("nexusBankAccountId") == "savings-at-nexus":
         exit(0)
         print("Test passed!")
diff --git a/integration-tests/test-bankConnection.py 
b/integration-tests/test-bankConnection.py
index 02571a5..954af26 100755
--- a/integration-tests/test-bankConnection.py
+++ b/integration-tests/test-bankConnection.py
@@ -7,6 +7,7 @@ import hashlib
 import base64
 
 from util import startNexus, startSandbox, assertResponse
+from json_checks import checkDeleteConnection, checkConnectionListElement, 
checkBankConnection
 
 # Nexus user details
 USERNAME = "person"
@@ -119,7 +120,7 @@ assertResponse(
 assertResponse(
     post(
         "http://localhost:5001/bank-connections/delete-connection";,
-        json=dict(bankConnectionId="my-ebics")
+        json=checkDeleteConnection(dict(bankConnectionId="my-ebics"))
     )
 )
 
@@ -131,8 +132,16 @@ connectionsList = resp.json().get("bankConnections")
 assert(connectionsList != None)
 
 for el in connectionsList:
+    checkConnectionListElement(el)
     if el.get("name") == "my-ebics":
         print("fail: account not deleted!")
         exit(1)
 
+resp = assertResponse(
+    get("http://localhost:5001/bank-connections/my-ebics-new";,
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER)
+    )
+)
+checkBankConnection(resp.json())
+
 print("Test passed!")
diff --git a/integration-tests/test-ebics-highlevel.py 
b/integration-tests/test-ebics-highlevel.py
index bb49e31..29069f4 100755
--- a/integration-tests/test-ebics-highlevel.py
+++ b/integration-tests/test-ebics-highlevel.py
@@ -181,7 +181,7 @@ resp = assertResponse(
         headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
     )
 )
-checkPreparedPaymentResponse(resp)
+checkPreparedPaymentResponse(resp.json())
 PREPARED_PAYMENT_UUID = resp.json().get("uuid")
 
 # 5.b, submit payment initiation
@@ -213,6 +213,6 @@ if len(transactions) != 1:
     print(transactions)
     fail(f"Unexpected number of transactions ({len(transactions)}); should be 
1")
 
-checkTransactions(transactions[0])
+checkTransaction(transactions[0])
 
 print("Test passed!")
diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py
index aac20d7..c725715 100755
--- a/integration-tests/test-ebics.py
+++ b/integration-tests/test-ebics.py
@@ -3,13 +3,13 @@
 from requests import post, get
 from subprocess import call, Popen, PIPE
 from time import sleep
+from util import startNexus, startSandbox, assertResponse
+from json_checks import checkFetchTransactions, checkPreparedPaymentElement
 import os
 import socket
 import hashlib
 import base64
 
-from util import startNexus, startSandbox, assertResponse
-
 # Steps implemented in this test.
 #
 # 0 Prepare sandbox.
@@ -212,6 +212,13 @@ PREPARED_PAYMENT_UUID = resp.json().get("uuid")
 if PREPARED_PAYMENT_UUID == None:
     fail("Payment UUID not received")
 
+resp = assertResponse(
+    
get(f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/payment-initiations/{PREPARED_PAYMENT_UUID}";,
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER)
+    )
+)
+checkPreparedPaymentElement(resp.json())
+
 # 5.b, submit prepared statement
 assertResponse(
     post(
@@ -225,7 +232,7 @@ assertResponse(
 assertResponse(
     post(
         
f"http://localhost:5001/bank-accounts/{BANK_ACCOUNT_LABEL}/fetch-transactions";,
-        json=dict(level="all", rangeType="all"),
+        json=checkFetchTransactions(dict(level="all", rangeType="all")),
         headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
     )
 )
diff --git a/integration-tests/util.py b/integration-tests/util.py
index ab85cd6..76d68bc 100644
--- a/integration-tests/util.py
+++ b/integration-tests/util.py
@@ -16,7 +16,7 @@ class CheckJsonField:
 
     def check(self, json):
         if self.name not in json and not self.optional:
-            print(f"'{self.name}' not found in the JSON.")
+            print(f"'{self.name}' not found in the JSON: {json}.")
             sys.exit(1)
         if self.nested:
             self.nested.check(json.get(self.name))
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 26473ff..08e709c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -119,7 +119,7 @@ fun extractUserAndPassword(authorizationHeader: String): 
Pair<String, String> {
 fun authenticateRequest(request: ApplicationRequest): NexusUserEntity {
     val authorization = request.headers["Authorization"]
     val headerLine = if (authorization == null) throw NexusError(
-        HttpStatusCode.BadRequest, "Authentication:-header line not found"
+        HttpStatusCode.BadRequest, "Authorization header not found"
     ) else authorization
     val (username, password) = extractUserAndPassword(headerLine)
     val user = NexusUserEntity.find {

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