[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Implement and test /config (nexus).
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Implement and test /config (nexus). |
Date: |
Fri, 11 Dec 2020 18:01:52 +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 d9d3db1 Implement and test /config (nexus).
d9d3db1 is described below
commit d9d3db1b094f412c85ddbe52480df6289a144f33
Author: MS <ms@taler.net>
AuthorDate: Fri Dec 11 18:01:31 2020 +0100
Implement and test /config (nexus).
---
integration-tests/tests.py | 30 ++++++++++++++++++----
integration-tests/util.py | 7 +++++
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 2 ++
nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt | 26 ++++++++++++++++---
.../main/kotlin/tech/libeufin/nexus/server/JSON.kt | 3 ++-
.../tech/libeufin/nexus/server/NexusServer.kt | 1 +
nexus/src/test/kotlin/DBTest.kt | 1 +
parsing-tests/checks.py | 5 ----
8 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
index bb4f06b..3a14f7d 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -12,7 +12,8 @@ from util import (
assertResponse,
makeNexusSuperuser,
dropSandboxTables,
- dropNexusTables
+ dropNexusTables,
+ assertJsonEqual
)
# Base URLs
@@ -246,10 +247,9 @@ def test_payment():
)
assert len(resp.json().get("transactions")) == 1
-# This test makes one payment via the Taler facade,
-# and expects too see it in the outgoing history.
-@pytest.mark.skip("Needs more attention")
-def test_taler_facade():
+
+@pytest.fixture
+def make_taler_facade():
assertResponse(
post(
f"{N}/facades",
@@ -258,6 +258,7 @@ def test_taler_facade():
type="taler-wire-gateway",
creator=NEXUS_USERNAME,
config=dict(
+ currency="EUR",
bankAccount=NEXUS_BANK_LABEL,
bankConnection=NEXUS_BANK_CONNECTION,
reserveTransferLevel="UNUSED",
@@ -267,6 +268,25 @@ def test_taler_facade():
auth=NEXUS_AUTH
)
)
+
+def test_taler_facade_config(make_taler_facade):
+ resp = assertResponse(
+ get(
+ f"{N}/facades/{TALER_FACADE}/taler/config",
+ auth=NEXUS_AUTH
+ )
+ )
+ assertJsonEqual(
+ resp.json(),
+ dict(currency="EUR", version="0.0.0", name=TALER_FACADE)
+ )
+
+
+# This test makes one payment via the Taler facade,
+# and expects too see it in the outgoing history.
+@pytest.mark.skip("Needs more attention")
+def test_taler_facade(make_taler_facade):
+
assertResponse(
post(
f"{N}/facades/{TALER_FACADE}/taler/transfer",
diff --git a/integration-tests/util.py b/integration-tests/util.py
index 1492b1f..acbb9b8 100644
--- a/integration-tests/util.py
+++ b/integration-tests/util.py
@@ -4,6 +4,7 @@ from subprocess import check_call, Popen, PIPE, DEVNULL
import socket
from requests import post, get
from time import sleep
+from deepdiff import DeepDiff
import atexit
from pathlib import Path
import sys
@@ -31,6 +32,12 @@ class CheckJsonTop:
check.check(json)
return json
+
+def assertJsonEqual(json1, json2):
+ diff = DeepDiff(json1, json2, ignore_order=True, report_repetition=True)
+ assert len(diff.keys()) == 0
+
+
def checkPort(port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 2ca386e..465b59e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -336,6 +336,7 @@ class FacadeEntity(id: EntityID<String>) :
Entity<String>(id) {
object TalerFacadeStateTable : IntIdTable() {
val bankAccount = text("bankAccount")
val bankConnection = text("bankConnection")
+ val currency = text("currency")
/* "statement", "report", "notification" */
val reserveTransferLevel = text("reserveTransferLevel")
@@ -351,6 +352,7 @@ class TalerFacadeStateEntity(id: EntityID<Int>) :
IntEntity(id) {
var bankAccount by TalerFacadeStateTable.bankAccount
var bankConnection by TalerFacadeStateTable.bankConnection
+ var currency by TalerFacadeStateTable.currency
/* "statement", "report", "notification" */
var reserveTransferLevel by TalerFacadeStateTable.reserveTransferLevel
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index 3099967..e63d8e3 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -43,10 +43,7 @@ import tech.libeufin.nexus.iso20022.CamtBankAccountEntry
import tech.libeufin.nexus.iso20022.CreditDebitIndicator
import tech.libeufin.nexus.iso20022.EntryStatus
import tech.libeufin.nexus.iso20022.TransactionDetails
-import tech.libeufin.nexus.server.Pain001Data
-import tech.libeufin.nexus.server.authenticateRequest
-import tech.libeufin.nexus.server.expectNonNull
-import tech.libeufin.nexus.server.expectUrlParameter
+import tech.libeufin.nexus.server.*
import tech.libeufin.util.CryptoUtil
import tech.libeufin.util.EbicsProtocolError
import tech.libeufin.util.parseAmount
@@ -538,7 +535,28 @@ private suspend fun historyIncoming(call:
ApplicationCall): Unit {
return call.respond(TextContent(customConverter(history),
ContentType.Application.Json))
}
+private fun getCurrency(facadeName: String): String {
+ val res = transaction {
+ TalerFacadeStateEntity.find {
+ TalerFacadeStateTable.facade eq facadeName
+ }.firstOrNull()
+ } ?: throw NexusError(
+ HttpStatusCode.InternalServerError,
+ "Facade '$facadeName' not found"
+ )
+ return res.currency
+}
+
fun talerFacadeRoutes(route: Route, httpClient: HttpClient) {
+ route.get("/config") {
+ val facadeName = ensureNonNull(call.parameters["fcid"])
+ call.respond(object {
+ val version = "0.0.0"
+ val name = facadeName
+ val currency = getCurrency(facadeName)
+ })
+ return@get
+ }
route.post("/transfer") {
talerTransfer(call)
return@post
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index b2d8e72..ec353ab 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -329,7 +329,8 @@ data class TalerWireGatewayFacadeConfig(
val bankAccount: String,
val bankConnection: String,
val reserveTransferLevel: String,
- val intervalIncremental: String
+ val intervalIncremental: String,
+ val currency: String
)
data class Pain001Data(
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 60edeb0..76e7760 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -901,6 +901,7 @@ fun serverMain(dbName: String, host: String) {
intervalIncrement = body.config.intervalIncremental
reserveTransferLevel = body.config.reserveTransferLevel
facade = newFacade
+ currency = body.config.currency
}
}
call.respondText("Facade created")
diff --git a/nexus/src/test/kotlin/DBTest.kt b/nexus/src/test/kotlin/DBTest.kt
index 26899bf..e42ef89 100644
--- a/nexus/src/test/kotlin/DBTest.kt
+++ b/nexus/src/test/kotlin/DBTest.kt
@@ -82,6 +82,7 @@ class DBTest {
reserveTransferLevel = "any"
intervalIncrement = "any"
this.facade = facade
+ currency = "UNUSED"
}
}
}
diff --git a/parsing-tests/checks.py b/parsing-tests/checks.py
index 6830813..1bf2333 100755
--- a/parsing-tests/checks.py
+++ b/parsing-tests/checks.py
@@ -3,7 +3,6 @@
import os
import sys
import json
-from deepdiff import DeepDiff
from subprocess import Popen, PIPE
# return dict with parse-result.
@@ -29,10 +28,6 @@ def get_json_from_disk(json_file):
with open(json_file_abs) as j:
return json.load(j)
-def assert_json_equal(json1, json2):
- diff = DeepDiff(json1, json2, ignore_order=True, report_repetition=True)
- assert len(diff.keys()) == 0
-
def test_camt53_example3():
parsed = call_parser("./samples/camt53_example3.xml")
entries = parsed["reports"][0]["entries"]
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Implement and test /config (nexus).,
gnunet <=