libeufin

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

commit 9210b01fb46380537afccb50b07fdba0108fbe33
parent 51300a1a75c137c215189dff8ca38e53d9ec5dea
Author: Antoine A <>
Date:   Tue, 23 Jan 2024 20:11:37 +0100

Add missing /config endpoints

Diffstat:
MAPI_CHANGES.md | 2++
Mbank/src/main/kotlin/tech/libeufin/bank/Constants.kt | 5+++--
Mbank/src/main/kotlin/tech/libeufin/bank/Main.kt | 2+-
Mbank/src/main/kotlin/tech/libeufin/bank/RevenueApi.kt | 7++++++-
Mbank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt | 27++++++++++++++++++---------
Mbank/src/main/kotlin/tech/libeufin/bank/WireGatewayApi.kt | 12+++++-------
Mbank/src/test/kotlin/RevenueApiTest.kt | 8++++++++
Mbank/src/test/kotlin/WireGatewayApiTest.kt | 8++++++++
8 files changed, 51 insertions(+), 20 deletions(-)

diff --git a/API_CHANGES.md b/API_CHANGES.md @@ -30,6 +30,8 @@ This files contains all the API changes for the current release: - POST /cashouts: remove status field - PATCH /accounts/USERNAME: add tan_channel - GET /accounts/USERNAME: add tan_channel +- Add GET /accounts/USERNAME/taler-revenue/config +- Add GET /accounts/USERNAME/taler-wire-gateway/config ## bank cli diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Constants.kt b/bank/src/main/kotlin/tech/libeufin/bank/Constants.kt @@ -43,4 +43,5 @@ const val MAX_BODY_LENGTH: Long = 4 * 1024 // 4kB const val COREBANK_API_VERSION: String = "4:0:0" const val CONVERSION_API_VERSION: String = "0:0:0" const val INTEGRATION_API_VERSION: String = "2:0:2" -const val WIRE_GATEWAY_API_VERSION: String = "0:1:0" -\ No newline at end of file +const val WIRE_GATEWAY_API_VERSION: String = "0:2:0" +const val REVENUE_API_VERSION: String = "0:0:0" +\ No newline at end of file diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt @@ -209,7 +209,7 @@ fun Application.corebankWebApp(db: Database, ctx: BankConfig) { conversionApi(db, ctx) bankIntegrationApi(db, ctx) wireGatewayApi(db, ctx) - revenueApi(db) + revenueApi(db, ctx) ctx.spaPath?.let { get("/") { call.respondRedirect("/webui/") diff --git a/bank/src/main/kotlin/tech/libeufin/bank/RevenueApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/RevenueApi.kt @@ -28,8 +28,13 @@ import tech.libeufin.common.* import tech.libeufin.bank.auth.* import tech.libeufin.bank.db.* -fun Routing.revenueApi(db: Database) { +fun Routing.revenueApi(db: Database, ctx: BankConfig) { auth(db, TokenScope.readonly) { + get("/accounts/{USERNAME}/taler-revenue/config") { + call.respond(RevenueConfig( + currency = ctx.regionalCurrency + )) + } get("/accounts/{USERNAME}/taler-revenue/history") { val params = HistoryParams.extract(context.request.queryParameters) val bankAccount = call.bankInfo(db) diff --git a/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt b/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt @@ -304,8 +304,24 @@ data class TalerIntegrationConfigResponse( val currency: String, val currency_specification: CurrencySpecification ) { - val name: String = "taler-bank-integration"; - val version: String = INTEGRATION_API_VERSION; + val name: String = "taler-bank-integration" + val version: String = INTEGRATION_API_VERSION +} + +@Serializable +data class WireGatewayConfig( + val currency: String +) { + val name: String = "taler-wire-gateway" + val version: String = WIRE_GATEWAY_API_VERSION +} + +@Serializable +data class RevenueConfig( + val currency: String +) { + val name: String = "taler-revenue" + val version: String = REVENUE_API_VERSION } enum class CreditDebitInfo { @@ -535,13 +551,6 @@ data class AddIncomingResponse( val row_id: Long ) -@Serializable -data class TWGConfigResponse( - val name: String = "taler-wire-gateway", - val version: String = WIRE_GATEWAY_API_VERSION, - val currency: String -) - /** * Response of a TWG /history/incoming call. */ diff --git a/bank/src/main/kotlin/tech/libeufin/bank/WireGatewayApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/WireGatewayApi.kt @@ -35,14 +35,12 @@ import tech.libeufin.bank.auth.* fun Routing.wireGatewayApi(db: Database, ctx: BankConfig) { - get("/taler-wire-gateway/config") { - call.respond(TWGConfigResponse( - currency = ctx.regionalCurrency - )) - - return@get - } auth(db, TokenScope.readwrite) { + get("/accounts/{USERNAME}/taler-wire-gateway/config") { + call.respond(WireGatewayConfig( + currency = ctx.regionalCurrency + )) + } post("/accounts/{USERNAME}/taler-wire-gateway/transfer") { val req = call.receive<TransferRequest>() ctx.checkRegionalCurrency(req.amount) diff --git a/bank/src/test/kotlin/RevenueApiTest.kt b/bank/src/test/kotlin/RevenueApiTest.kt @@ -29,6 +29,14 @@ import org.junit.Test import tech.libeufin.bank.* class RevenueApiTest { + // GET /accounts/{USERNAME}/taler-revenue/config + @Test + fun config() = bankSetup { _ -> + authRoutine(HttpMethod.Get, "/accounts/merchant/taler-revenue/config") + + client.getA("/accounts/merchant/taler-revenue/config").assertOk() + } + // GET /accounts/{USERNAME}/taler-revenue/history @Test fun history() = bankSetup { diff --git a/bank/src/test/kotlin/WireGatewayApiTest.kt b/bank/src/test/kotlin/WireGatewayApiTest.kt @@ -30,6 +30,14 @@ import tech.libeufin.bank.* import tech.libeufin.common.* class WireGatewayApiTest { + // GET /accounts/{USERNAME}/taler-wire-gateway/config + @Test + fun config() = bankSetup { _ -> + authRoutine(HttpMethod.Get, "/accounts/merchant/taler-wire-gateway/config") + + client.getA("/accounts/merchant/taler-wire-gateway/config").assertOk() + } + // Testing the POST /transfer call from the TWG API. @Test fun transfer() = bankSetup { _ ->