libeufin

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

commit a47fe8380d8048a3629b385d9e336e80eecd9885
parent 84f63adc02b66873a228e8432ace448a23509760
Author: MS <ms@taler.net>
Date:   Thu, 14 May 2020 19:10:54 +0200

HTD message to new API.

Organize the HTD message type into the ../send{MSG} style.

Diffstat:
Mintegration-tests/test-ebics-new.py | 20++++++++++++--------
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 42+++++++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/integration-tests/test-ebics-new.py b/integration-tests/test-ebics-new.py @@ -222,19 +222,19 @@ assertResponse( ) ) -nexus.terminate() -sandbox.terminate() -exit(44) - -#2.b +#2.b, download keys from the bank (HPB) assertResponse( post( - "http://localhost:5001/ebics/subscribers/{}/sync".format(USERNAME), - json=dict() + "http://localhost:5001/bank-transports/syncHPB", + json=dict( + type="ebics", + name="my-ebics" + ), + headers=dict(Authorization=USER_AUTHORIZATION_HEADER) ) ) -#2.c +#2.c, fetch bank account information assertResponse( post( "http://localhost:5001/ebics/subscribers/{}/fetch-accounts".format(USERNAME), @@ -242,6 +242,10 @@ assertResponse( ) ) +nexus.terminate() +sandbox.terminate() +exit(44) + #3 assertResponse( post( diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -52,6 +52,7 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import org.slf4j.event.Level import tech.libeufin.util.* +import tech.libeufin.util.ebics_h004.HTDResponseOrderData import java.text.DateFormat import java.util.zip.InflaterInputStream import javax.crypto.EncryptedPrivateKeyInfo @@ -105,6 +106,45 @@ suspend fun handleEbicsSendMSG( } return response } + "HTD" -> { + val response = doEbicsDownloadTransaction( + httpClient, subscriber, "HTD", EbicsStandardOrderParams() + ) + when (response) { + is EbicsDownloadBankErrorResult -> { + throw NexusError( + HttpStatusCode.BadGateway, + response.returnCode.errorCode + ) + } + is EbicsDownloadSuccessResult -> { + val payload = XMLUtil.convertStringToJaxb<HTDResponseOrderData>( + response.orderData.toString(Charsets.UTF_8) + ) + if (sync) { + transaction { + payload.value.partnerInfo.accountInfoList?.forEach { + val bankAccount = BankAccountEntity.new(id = it.id) { + accountHolder = it.accountHolder ?: "NOT-GIVEN" + iban = extractFirstIban(it.accountNumberList) + ?: throw NexusError(HttpStatusCode.NotFound, reason = "bank gave no IBAN") + bankCode = extractFirstBic(it.bankCodeList) ?: throw NexusError( + HttpStatusCode.NotFound, + reason = "bank gave no BIC" + ) + } + BankAccountMapEntity.new { + ebicsSubscriber = getEbicsTransport(userId, transportId) + this.nexusUser = nexusUser + this.bankAccount = bankAccount + } + } + } + } + response.orderData.toString(Charsets.UTF_8) + } + } + } "HEV" -> { val request = makeEbicsHEVRequest(subscriber) httpClient.postToBank(subscriber.ebicsUrl, request) @@ -529,7 +569,7 @@ fun main() { * Sends the bank a message "MSG" according to the transport * "transportName". DOES alterate DB tables. */ - post("/bank-transports/{transportName}/sync{MSG}") { + post("/bank-transports/sync{MSG}") { val userId = authenticateRequest(call.request.headers["Authorization"]) val body = call.receive<Transport>() when (body.type) {