libeufin

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

commit 84f63adc02b66873a228e8432ace448a23509760
parent 6b93c40f5b0f5ac711cde99016a842325ec7c808
Author: MS <ms@taler.net>
Date:   Thu, 14 May 2020 18:24:32 +0200

Integration test.

Fixing a out-of-transaction block statement,
plus adapting the test itself to the new API.

Diffstat:
Mintegration-tests/test-ebics-new.py | 26+++++++++++++++++---------
Mnexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 14++++++--------
2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/integration-tests/test-ebics-new.py b/integration-tests/test-ebics-new.py @@ -199,25 +199,33 @@ assertResponse( ) ) -nexus.terminate() -sandbox.terminate() -exit(44) - -#2.a +#2.a, upload keys to the bank (INI & HIA) assertResponse( post( - "http://localhost:5001/ebics/subscribers/{}/sendINI".format(USERNAME), - json=dict() + "http://localhost:5001/bank-transports/sendINI", + json=dict( + type="ebics", + name="my-ebics" + ), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER) ) ) assertResponse( post( - "http://localhost:5001/ebics/subscribers/{}/sendHIA".format(USERNAME), - json=dict() + "http://localhost:5001/bank-transports/sendHIA", + json=dict( + type="ebics", + name="my-ebics" + ), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER) ) ) +nexus.terminate() +sandbox.terminate() +exit(44) + #2.b assertResponse( post( diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt @@ -139,20 +139,18 @@ fun getEbicsSubscriberDetailsInternal(subscriber: EbicsSubscriberEntity): EbicsC fun getEbicsTransport(userId: String, transportId: String? = null): EbicsSubscriberEntity { val transport = transaction { if (transportId == null) { - return@transaction EbicsSubscriberEntity.all().first() + return@transaction EbicsSubscriberEntity.find { + EbicsSubscribersTable.nexusUser eq userId + }.firstOrNull() } - return@transaction EbicsSubscriberEntity.findById(transportId) + return@transaction EbicsSubscriberEntity.find{ + EbicsSubscribersTable.id eq transportId and (EbicsSubscribersTable.nexusUser eq userId) + }.firstOrNull() } ?: throw NexusError( HttpStatusCode.NotFound, "Could not find ANY Ebics transport for user $userId" ) - if (transport.nexusUser.id.value != userId) { - throw NexusError( - HttpStatusCode.Forbidden, - "No rights over transport $transportId" - ) - } return transport }