libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 8f5d1e8d753b5c4120673d73919d61e9b6d54199
parent d0f6f92c8df867d59804220368760f0b9f759372
Author: MS <ms@taler.net>
Date:   Thu, 28 May 2020 18:10:10 +0200

Facade test.

Get the facade creation to pass.

Diffstat:
Mintegration-tests/test-taler-facade.py | 26+++++++++++++++++++++++---
Mnexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 7+++----
Mnexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 8++++----
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 2+-
4 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/integration-tests/test-taler-facade.py b/integration-tests/test-taler-facade.py @@ -57,6 +57,7 @@ SUBSCRIBER_IBAN = "GB33BUKB20201555555555" SUBSCRIBER_BIC = "BUKBGB22" SUBSCRIBER_NAME = "Oliver Smith" BANK_ACCOUNT_LABEL = "savings" +BANK_CONNECTION_LABEL = "my-ebics" # Databases NEXUS_DB="test-nexus.sqlite3" @@ -187,7 +188,7 @@ assertResponse( post( "http://localhost:5001/bank-connections", json=dict( - name="my-ebics", + name=BANK_CONNECTION_LABEL, source="new", type="ebics", data=dict( @@ -202,7 +203,7 @@ print("connecting") assertResponse( post( - "http://localhost:5001/bank-connections/my-ebics/connect", + "http://localhost:5001/bank-connections/{}/connect".format(BANK_CONNECTION_LABEL), json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) @@ -212,12 +213,31 @@ assertResponse( # 2.c, fetch bank account information assertResponse( post( - "http://localhost:5001/bank-connections/my-ebics/ebics/import-accounts", + "http://localhost:5001/bank-connections/{}/ebics/import-accounts".format(BANK_CONNECTION_LABEL), json=dict(), headers=dict(Authorization=USER_AUTHORIZATION_HEADER), ) ) +# 3, create new facade +assertResponse( + post( + "http://localhost:5001/facades", + json=dict( + name="my-facade", + type="taler-wire-gateway", + creator=USERNAME, + config=dict( + bankAccount=BANK_ACCOUNT_LABEL, + bankConnection=BANK_CONNECTION_LABEL, + reserveTransferLevel="UNUSED", + intervalIncremental="UNUSED" + ) + ), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER), + ) +) + nexus.terminate() sandbox.terminate() print("Test passed!") diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt @@ -272,8 +272,7 @@ class NexusBankConnectionEntity(id: EntityID<String>) : Entity<String>(id) { } object FacadesTable : IdTable<String>() { - override val id = NexusBankConnectionsTable.text("id").entityId().primaryKey() - val name = text("name") + override val id = FacadesTable.text("id").entityId().primaryKey() val type = text("type") val creator = reference("creator", NexusUsersTable) val config = reference("config", TalerFacadeConfigsTable) // see #6266 @@ -281,7 +280,6 @@ object FacadesTable : IdTable<String>() { class FacadeEntity(id: EntityID<String>) : Entity<String>(id) { companion object : EntityClass<String, FacadeEntity>(FacadesTable) - var name by FacadesTable.name var type by FacadesTable.type var creator by NexusUserEntity referencedOn FacadesTable.creator var config by TalerFacadeConfigEntity referencedOn FacadesTable.config @@ -318,7 +316,8 @@ fun dbCreateTables(dbName: String) { TalerIncomingPayments, TalerRequestedPayments, NexusBankConnectionsTable, - NexusBankMessagesTable + NexusBankMessagesTable, + FacadesTable ) } } \ No newline at end of file diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt @@ -257,10 +257,10 @@ data class FacadeInfo( val name: String, val type: String, val creator: String, - val bankAccountsRead: MutableList<String> = mutableListOf(), - val bankAccountsWrite: MutableList<String> = mutableListOf(), - val bankConnectionsRead: MutableList<String> = mutableListOf(), - val bankConnectionsWrite: MutableList<String> = mutableListOf(), + val bankAccountsRead: MutableList<String>? = mutableListOf(), + val bankAccountsWrite: MutableList<String>? = mutableListOf(), + val bankConnectionsRead: MutableList<String>? = mutableListOf(), + val bankConnectionsWrite: MutableList<String>? = mutableListOf(), val config: TalerWireGatewayFacadeConfig /* To be abstracted to Any! */ ) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -947,8 +947,8 @@ fun serverMain(dbName: String) { } post("/facades") { val body = call.receive<FacadeInfo>() - val user = authenticateRequest(call.request) transaction { + val user = authenticateRequest(call.request) FacadeEntity.new(body.name) { type = body.type creator = user