summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine A <>2024-02-07 16:50:08 +0100
committerAntoine A <>2024-02-07 16:50:08 +0100
commite3a62fa46e75cff879b59725165490943d0d0c1f (patch)
tree3cf8854c7c5962d8d3561feccef15fb9de30fd2f
parentf0926cab3914aaeededce9bfb455067d04489784 (diff)
downloadlibeufin-e3a62fa46e75cff879b59725165490943d0d0c1f.tar.gz
libeufin-e3a62fa46e75cff879b59725165490943d0d0c1f.tar.bz2
libeufin-e3a62fa46e75cff879b59725165490943d0d0c1f.zip
Warning instead of failure when new configuration values are missing
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/Config.kt25
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt2
-rw-r--r--common/src/main/kotlin/TalerCommon.kt7
m---------contrib/wallet-core0
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt2
-rw-r--r--testbench/README.md7
-rw-r--r--testbench/conf/integration.conf4
-rw-r--r--testbench/conf/mini.conf2
8 files changed, 34 insertions, 15 deletions
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Config.kt b/bank/src/main/kotlin/tech/libeufin/bank/Config.kt
index 9926672e..8ec6bc8d 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Config.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Config.kt
@@ -24,6 +24,10 @@ import kotlinx.serialization.json.Json
import tech.libeufin.common.DatabaseConfig
import java.nio.file.*
import kotlin.io.path.*
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+private val logger: Logger = LoggerFactory.getLogger("libeufin-bank")
/**
* Application the parsed configuration.
@@ -90,7 +94,7 @@ fun TalerConfig.loadServerConfig(): ServerConfig {
}
}
-fun TalerConfig.loadBankConfig(): BankConfig {
+fun TalerConfig.loadBankConfig(): BankConfig {
val regionalCurrency = requireString("libeufin-bank", "currency")
var fiatCurrency: String? = null;
var fiatCurrencySpec: CurrencySpecification? = null
@@ -109,11 +113,24 @@ fun TalerConfig.loadBankConfig(): BankConfig {
val method = when (val type = lookupString("libeufin-bank", "wire_type")) {
"iban" -> WireMethod.IBAN
"x-taler-bank" -> WireMethod.X_TALER_BANK
+ null -> {
+ val err = TalerConfigError.missing("payment target type", "libeufin-bank", "wire_type").message
+ logger.warn("$err, defaulting to 'iban' but will fail in a future update")
+ WireMethod.IBAN
+ }
else -> throw TalerConfigError.invalid("payment target type", "libeufin-bank", "wire_type", "expected 'iban' or 'x-taler-bank' got '$type'")
}
- val payto = when (method) {
- WireMethod.IBAN -> BankPaytoCtx(bic = lookupString("libeufin-bank", "iban_payto_bic"))
- WireMethod.X_TALER_BANK -> BankPaytoCtx(hostname = lookupString("libeufin-bank", "x_taler_bank_payto_hostname"))
+ val payto = BankPaytoCtx(
+ bic = lookupString("libeufin-bank", "iban_payto_bic"),
+ hostname = lookupString("libeufin-bank", "x_taler_bank_payto_hostname")
+ )
+ when (method) {
+ WireMethod.IBAN -> if (payto.bic == null) {
+ logger.warn(TalerConfigError.missing("BIC", "libeufin-bank", "iban_payto_bic").message + " will fail in a future update")
+ }
+ WireMethod.X_TALER_BANK -> if (payto.hostname == null) {
+ logger.warn(TalerConfigError.missing("hostname", "libeufin-bank", "x_taler_bank_payto_hostname").message + " will fail in a future update")
+ }
}
return BankConfig(
regionalCurrency = regionalCurrency,
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
index 0914222e..f1c5cc94 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
@@ -223,7 +223,7 @@ suspend fun createAccount(
if (!(req.payto_uri is XTalerBankPayto))
throw badRequest("Expected an IBAN payto uri")
else if (req.payto_uri.username != req.username)
- throw badRequest("Expected a payto uri for '${req.username}' got one for 'req.payto_uri.username'")
+ throw badRequest("Expected a payto uri for '${req.username}' got one for '${req.payto_uri.username}'")
}
val internalPayto = XTalerBankPayto.forUsername(req.username)
diff --git a/common/src/main/kotlin/TalerCommon.kt b/common/src/main/kotlin/TalerCommon.kt
index b96e87a3..836631a5 100644
--- a/common/src/main/kotlin/TalerCommon.kt
+++ b/common/src/main/kotlin/TalerCommon.kt
@@ -149,8 +149,11 @@ sealed class Payto {
/** Transform a payto URI to its bank form, using [name] as the receiver-name and the bank [ctx] */
fun bank(name: String, ctx: BankPaytoCtx): String = when (this) {
- is IbanPayto -> "payto://iban/${ctx.bic!!}/$iban?receiver-name=${name.encodeURLParameter()}"
- is XTalerBankPayto -> "payto://x-taler-bank/${ctx.hostname!!}/$username?receiver-name=${name.encodeURLParameter()}"
+ is IbanPayto -> {
+ val bic = if (ctx.bic != null) "${ctx.bic}/" else ""
+ "payto://iban/$bic$iban?receiver-name=${name.encodeURLParameter()}"
+ }
+ is XTalerBankPayto -> "payto://x-taler-bank/${ctx.hostname ?: "localhost"}/$username?receiver-name=${name.encodeURLParameter()}"
}
fun expectIban(): IbanPayto {
diff --git a/contrib/wallet-core b/contrib/wallet-core
-Subproject c15393d61199c665dc056dc41ed19c7dbb28f92
+Subproject d6ea0db963a73fa67eac98122ba2600ec7314fb
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 55d44734..7b3edb7f 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -41,7 +41,7 @@ import java.nio.file.Path
import java.time.Instant
val NEXUS_CONFIG_SOURCE = ConfigSource("libeufin", "libeufin-nexus", "libeufin-nexus")
-val logger: Logger = LoggerFactory.getLogger("libeufin-nexus")
+internal val logger: Logger = LoggerFactory.getLogger("libeufin-nexus")
/**
* Triple identifying one IBAN bank account.
diff --git a/testbench/README.md b/testbench/README.md
index 63cc81be..6c377ff8 100644
--- a/testbench/README.md
+++ b/testbench/README.md
@@ -4,7 +4,6 @@
To add a platform write a minimal configuration file at `testbench/test/PLATFORM/ebics.conf` such as :
-
``` ini
[nexus-ebics]
currency = CHF
@@ -19,6 +18,8 @@ USER_ID = PFC00563
PARTNER_ID = PFC00563
IBAN = CH7789144474425692816
+BIC = POFICHBEXXX
+NAME = LibEuFin Tests
```
To start the interactive EBICS test run :
@@ -27,6 +28,6 @@ To start the interactive EBICS test run :
make testbench platform=PLATFORM
```
-If HOST_BASE_URL is one a known test platform we will generate and then offer to reset client private keys to test keys registration, otherwise, we will expect existing keys to be found at `testbench/test/PLATFORM/ebics.edited.conf`.
+If HOST_BASE_URL is one a known test platform we will generate and then offer to reset client private keys to test keys registration, otherwise, we will expect existing keys to be found at `testbench/test/PLATFORM/client-ebics-keys.json`.
-This minimal configuration will be augmented on start, you can find the full documentation at `testbench/test/PLATFORM/client-ebics-keys.json`. \ No newline at end of file
+This minimal configuration will be augmented on start, you can find the full documentation at `testbench/test/PLATFORM/ebics.edited.conf`. \ No newline at end of file
diff --git a/testbench/conf/integration.conf b/testbench/conf/integration.conf
index a198dcce..490ecd8e 100644
--- a/testbench/conf/integration.conf
+++ b/testbench/conf/integration.conf
@@ -1,7 +1,7 @@
[libeufin-bank]
CURRENCY = KUDOS
-WIRE_TYPE = iban
-IBAN_PAYTO_BIC = SANDBOXX
+WIRE_TYPE = x-taler-bank
+X_TALER_BANK_PAYTO_HOSTNAME = https://bank.example.com
SUGGESTED_WITHDRAWAL_EXCHANGE = https://exchange.example.com
ALLOW_REGISTRATION = yes
ALLOW_ACCOUNT_DELETION = yes
diff --git a/testbench/conf/mini.conf b/testbench/conf/mini.conf
index 12cfc393..3e43a05d 100644
--- a/testbench/conf/mini.conf
+++ b/testbench/conf/mini.conf
@@ -1,7 +1,5 @@
[libeufin-bank]
CURRENCY = KUDOS
-WIRE_TYPE = iban
-IBAN_PAYTO_BIC = SANDBOXX
[nexus-ebics]
CURRENCY = CHF