libeufin

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

commit 9d0ea4ac586ef68ccf63269bcf11c2aa04bf866c
parent f18170cff1040dfd2f046df4a985a115d64743ff
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Wed,  6 Nov 2019 12:31:51 +0100

responding to /sendIni (nexus)

Diffstat:
Mnexus/src/main/kotlin/Main.kt | 28++++++++++++++++------------
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 1-
2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt @@ -45,6 +45,7 @@ import io.ktor.server.netty.Netty import org.jetbrains.exposed.sql.transactions.transaction import org.slf4j.LoggerFactory import tech.libeufin.sandbox.* +import tech.libeufin.schema.ebics_h004.EbicsKeyManagementResponse import tech.libeufin.schema.ebics_h004.EbicsUnsecuredRequest import tech.libeufin.schema.ebics_s001.PubKeyValueType import tech.libeufin.schema.ebics_s001.SignaturePubKeyInfoType @@ -147,7 +148,6 @@ fun main() { } post("/ebics/subscribers/{id}/sendIni") { - // empty body for now..? val id = try { call.parameters["id"]!!.toInt() @@ -238,18 +238,22 @@ fun main() { return@post } - /** - * TODO: check response status code, - * and act accordingly when it differs from 200. - */ - - // works: val responseJaxb = XMLUtil.convertStringToJaxb<EbicsKeyManagementResponse>(response) + val responseJaxb = XMLUtil.convertStringToJaxb<EbicsKeyManagementResponse>(response) + val returnCode = responseJaxb.value.body.returnCode.value + if (returnCode == "000000") { + call.respond( + HttpStatusCode.OK, + NexusError("Sandbox accepted the key.") + ) + return@post + } else { - call.respond( - HttpStatusCode.OK, - NexusError("Sandbox responded.") - ) - return@post + call.respond( + HttpStatusCode.OK, + NexusError("Sandbox did not accepted the key. Error code: ${returnCode}") + ) + return@post + } } post("/nexus") { diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -353,7 +353,6 @@ private suspend fun ApplicationCall.ebicsweb() { } } - fun main() { dbCreateTables()