libeufin

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

commit 6d6ce026a37d8f88ceb3370efb40e86d4d26d8b9
parent 1102d8a9bde4fa452494f9eb6141176feb399e1d
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Tue, 28 Jan 2020 15:13:25 +0100

Admin command to create a new HostID.

Diffstat:
Mnexus/src/test/script/prepare_subscriber.sh | 2+-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt | 2+-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 20+++++++++++++++++++-
Msandbox/src/main/python/libeufin-cli | 30++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/nexus/src/test/script/prepare_subscriber.sh b/nexus/src/test/script/prepare_subscriber.sh @@ -37,7 +37,7 @@ read x printf "\n" exe_echo libeufin-cli ebics new-subscriber \ - --ebics-url http://localhost:5001/ebicsweb \ + --ebics-url http://localhost:5000/ebicsweb \ --user-id "user$1" \ --partner-id "partner$1" \ --host-id "host$1" && sleep 1 diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt @@ -141,7 +141,7 @@ data class EbicsHostResponse( ) data class EbicsHostCreateRequest( - val hostID: String, + val hostId: String, val ebicsVersion: String ) diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -330,12 +330,30 @@ fun main() { } post("/ebics/hosts") { val req = call.receive<EbicsHostCreateRequest>() + + val pairA = CryptoUtil.generateRsaKeyPair(2048) + val pairB = CryptoUtil.generateRsaKeyPair(2048) + val pairC = CryptoUtil.generateRsaKeyPair(2048) + transaction { + addLogger(StdOutSqlLogger) EbicsHostEntity.new { this.ebicsVersion = req.ebicsVersion - this.hostId = hostId + this.hostId = req.hostId + this.authenticationPrivateKey = SerialBlob(pairA.private.encoded) + this.encryptionPrivateKey = SerialBlob(pairB.private.encoded) + this.signaturePrivateKey = SerialBlob(pairC.private.encoded) + } } + + call.respondText( + "Host created.", + ContentType.Text.Plain, + HttpStatusCode.OK + ) + return@post + } get("/ebics/hosts/{id}") { val resp = transaction { diff --git a/sandbox/src/main/python/libeufin-cli b/sandbox/src/main/python/libeufin-cli @@ -23,6 +23,36 @@ def cli(ctx, nexus_base_url): def admin(): pass + +@admin.command(help="Instruct the Sandbox to create a new EBICS host ID.") +@click.option( + "--sandbox-url", + help="URL (with path) of the Sandbox that will activate the new Subscriber", + required=True +) +@click.option( + "--host-id", + help="EBICS host ID", + required=True +) +@click.option( + "--ebics-version", + help="EBICS version to support", + required=True +) +def add_host(sandbox_url, host_id, ebics_version): + body = dict( + hostId=host_id, + ebicsVersion=ebics_version + ) + try: + resp = post(sandbox_url, json=body) + except Exception: + print("Could not reach the Sandbox") + return + + print(resp.content.decode("utf-8")) + @admin.command(help="Instruct the Sandbox to create a new EBICS Subscriber") @click.option( "--sandbox-url",