gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Moving DB statements inside transactio


From: gnunet
Subject: [libeufin] branch master updated: Moving DB statements inside transaction block.
Date: Thu, 14 May 2020 20:58:20 +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 dee6d7b  Moving DB statements inside transaction block.
dee6d7b is described below

commit dee6d7b62215972e958a8a5e03242d11e22117b9
Author: MS <address@hidden>
AuthorDate: Thu May 14 20:57:45 2020 +0200

    Moving DB statements inside transaction block.
---
 integration-tests/test-ebics-new.py               | 18 ++++++++++------
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 25 ++++++++++++++---------
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/integration-tests/test-ebics-new.py 
b/integration-tests/test-ebics-new.py
index db9b530..77d9777 100755
--- a/integration-tests/test-ebics-new.py
+++ b/integration-tests/test-ebics-new.py
@@ -268,7 +268,7 @@ resp = assertResponse(
 assert(len(resp.json().get("transactions")) == 0)
 
 #5.a, prepare a payment
-assertResponse(
+resp = assertResponse(
     post(
         
"http://localhost:5001/bank-accounts/{}/prepared-payments".format(BANK_ACCOUNT_LABEL),
         json=dict(
@@ -281,16 +281,22 @@ assertResponse(
         headers=dict(Authorization=USER_AUTHORIZATION_HEADER)
     )
 )
+PREPARED_PAYMENT_UUID=resp.json().get("uuid")
+assert(PREPARED_PAYMENT_UUID != None)
+
+#5.b, submit prepared statement
+assertResponse(
+    post(
+        "http://localhost:5001/bank-accounts/prepared-payments/submit";,
+        json=dict(uuid=PREPARED_PAYMENT_UUID),
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER)
+    )
+)
 
 nexus.terminate()
 sandbox.terminate()
 exit(44)
 
-#5.b
-assertResponse(
-    post("http://localhost:5001/ebics/execute-payments";)
-)
-
 #6
 assertResponse(
     post(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index aa73709..15b4a8b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -280,19 +280,22 @@ fun main() {
             /**
              * Submit one particular payment at the bank.
              */
-            post("/bank-accounts/{accountid}/prepared-payments/submit") {
+            post("/bank-accounts/prepared-payments/submit") {
                 val userId = 
authenticateRequest(call.request.headers["Authorization"])
                 val body = call.receive<SubmitPayment>()
                 val preparedPayment = getPreparedPayment(body.uuid)
-                if (preparedPayment.nexusUser.id.value != userId) throw 
NexusError(
-                    HttpStatusCode.Forbidden,
-                    "No rights over such payment"
-                )
-                if (preparedPayment.submitted) {
-                    throw NexusError(
-                        HttpStatusCode.PreconditionFailed,
-                        "Payment ${body.uuid} was submitted already"
+                transaction {
+                    if (preparedPayment.nexusUser.id.value != userId) throw 
NexusError(
+                        HttpStatusCode.Forbidden,
+                        "No rights over such payment"
                     )
+                    if (preparedPayment.submitted) {
+                        throw NexusError(
+                            HttpStatusCode.PreconditionFailed,
+                            "Payment ${body.uuid} was submitted already"
+                        )
+                    }
+
                 }
                 val pain001document = createPain001document(preparedPayment)
                 if (body.transport != null) {
@@ -314,7 +317,9 @@ fun main() {
                         client, userId, null, pain001document
                     )
                 }
-                preparedPayment.submitted = true
+                transaction {
+                    preparedPayment.submitted = true
+                }
                 call.respondText("Payment ${body.uuid} submitted")
                 return@post
             }

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



reply via email to

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