[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated (295ce2bc -> 6788842c)
From: |
gnunet |
Subject: |
[libeufin] branch master updated (295ce2bc -> 6788842c) |
Date: |
Thu, 02 Nov 2023 18:04:10 +0100 |
This is an automated email from the git hooks/post-receive script.
antoine pushed a change to branch master
in repository libeufin.
from 295ce2bc nexus db
new 506ff1a2 Remove ISO20022 logic for now
new b1943cb8 Clean tests
new 6788842c Update kotlin and clean some dependencies
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
bank/build.gradle | 2 +-
.../src/main/kotlin/tech/libeufin/bank/Database.kt | 51 +---
.../main/kotlin/tech/libeufin/bank/TalerMessage.kt | 6 +-
bank/src/test/kotlin/BankIntegrationApiTest.kt | 24 +-
bank/src/test/kotlin/CoreBankApiTest.kt | 284 ++++++++++-----------
bank/src/test/kotlin/StatsTest.kt | 6 +-
bank/src/test/kotlin/WireGatewayApiTest.kt | 124 ++++-----
bank/src/test/kotlin/helpers.kt | 15 +-
build.gradle | 8 +-
database-versioning/libeufin-bank-0001.sql | 2 +-
database-versioning/libeufin-bank-procedures.sql | 68 ++---
nexus/build.gradle | 4 +-
12 files changed, 251 insertions(+), 343 deletions(-)
diff --git a/bank/build.gradle b/bank/build.gradle
index 391433b3..f64a3abd 100644
--- a/bank/build.gradle
+++ b/bank/build.gradle
@@ -4,7 +4,7 @@ plugins {
id 'application'
id 'org.jetbrains.kotlin.jvm'
id "com.github.johnrengelman.shadow" version "8.1.1"
- id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.10'
+ id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
}
java {
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
index 8eeb6035..c460ba15 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
@@ -34,8 +34,6 @@ import kotlinx.coroutines.*
import com.zaxxer.hikari.*
import tech.libeufin.util.*
-private const val DB_CTR_LIMIT = 1000000
-
private val logger: Logger =
LoggerFactory.getLogger("tech.libeufin.bank.Database")
/**
@@ -337,15 +335,12 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
if (bonus != null) {
conn.prepareStatement("""
SELECT out_balance_insufficient
- FROM
bank_transaction(?,'admin','bonus',(?,?)::taler_amount,?,?,?,?)
+ FROM
bank_transaction(?,'admin','bonus',(?,?)::taler_amount,?)
""").run {
setString(1, internalPaytoUri.canonical)
setLong(2, bonus.value)
setInt(3, bonus.frac)
setLong(4, Instant.now().toDbMicros() ?: throw
faultyTimestampByBank())
- setString(5, "not used") // ISO20022
- setString(6, "not used") // ISO20022
- setString(7, "not used") // ISO20022
executeQuery().use {
when {
!it.next() -> throw internalServerError("Bank
transaction didn't properly return")
@@ -687,9 +682,6 @@ class Database(dbConfig: String, private val bankCurrency:
String, private val f
subject: String,
amount: TalerAmount,
timestamp: Instant,
- accountServicerReference: String = "not used", // ISO20022
- endToEndId: String = "not used", // ISO20022
- paymentInformationId: String = "not used" // ISO20022
): BankTransactionResult = conn { conn ->
conn.transaction {
val stmt = conn.prepareStatement("""
@@ -704,7 +696,7 @@ class Database(dbConfig: String, private val bankCurrency:
String, private val f
,out_debit_row_id
,out_creditor_is_exchange
,out_debtor_is_exchange
- FROM bank_transaction(?,?,?,(?,?)::taler_amount,?,?,?,?)
+ FROM bank_transaction(?,?,?,(?,?)::taler_amount,?)
"""
)
stmt.setString(1, creditAccountPayto.canonical)
@@ -713,9 +705,6 @@ class Database(dbConfig: String, private val bankCurrency:
String, private val f
stmt.setLong(4, amount.value)
stmt.setInt(5, amount.frac)
stmt.setLong(6, timestamp.toDbMicros() ?: throw
faultyTimestampByBank())
- stmt.setString(7, accountServicerReference)
- stmt.setString(8, paymentInformationId)
- stmt.setString(9, endToEndId)
stmt.executeQuery().use {
when {
!it.next() -> throw internalServerError("Bank transaction
didn't properly return")
@@ -744,9 +733,6 @@ class Database(dbConfig: String, private val bankCurrency:
String, private val f
,(amount).val AS amount_val
,(amount).frac AS amount_frac
,transaction_date
- ,account_servicer_reference
- ,payment_information_id
- ,end_to_end_id
,direction
,bank_account_id
,bank_transaction_id
@@ -765,11 +751,8 @@ class Database(dbConfig: String, private val bankCurrency:
String, private val f
it.getInt("amount_frac"),
bankCurrency
),
- accountServicerReference =
it.getString("account_servicer_reference"),
- endToEndId = it.getString("end_to_end_id"),
direction =
TransactionDirection.valueOf(it.getString("direction")),
bankAccountId = it.getLong("bank_account_id"),
- paymentInformationId = it.getString("payment_information_id"),
subject = it.getString("subject"),
transactionDate =
it.getLong("transaction_date").microsToJavaInstant() ?: throw
faultyTimestampByBank(),
dbRowId = it.getLong("bank_transaction_id")
@@ -1068,10 +1051,7 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
*/
suspend fun talerWithdrawalConfirm(
opUuid: UUID,
- timestamp: Instant,
- accountServicerReference: String = "NOT-USED",
- endToEndId: String = "NOT-USED",
- paymentInfId: String = "NOT-USED"
+ timestamp: Instant
): WithdrawalConfirmationResult = conn { conn ->
val stmt = conn.prepareStatement("""
SELECT
@@ -1080,14 +1060,11 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
out_balance_insufficient,
out_not_selected,
out_aborted
- FROM confirm_taler_withdrawal(?, ?, ?, ?, ?);
+ FROM confirm_taler_withdrawal(?, ?);
"""
)
stmt.setObject(1, opUuid)
stmt.setLong(2, timestamp.toDbMicros() ?: throw
faultyTimestampByBank())
- stmt.setString(3, accountServicerReference)
- stmt.setString(4, endToEndId)
- stmt.setString(5, paymentInfId)
stmt.executeQuery().use {
when {
!it.next() ->
@@ -1329,10 +1306,7 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
suspend fun talerTransferCreate(
req: TransferRequest,
username: String,
- timestamp: Instant,
- acctSvcrRef: String = "not used",
- pmtInfId: String = "not used",
- endToEndId: String = "not used",
+ timestamp: Instant
): TalerTransferCreationResult = conn { conn ->
val subject = OutgoingTxMetadata(req.wtid,
req.exchange_base_url).encode()
val stmt = conn.prepareStatement("""
@@ -1349,7 +1323,7 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
taler_transfer (
?, ?, ?,
(?,?)::taler_amount,
- ?, ?, ?, ?, ?, ?, ?
+ ?, ?, ?, ?
);
""")
@@ -1362,9 +1336,6 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
stmt.setString(7, req.credit_account.canonical)
stmt.setString(8, username)
stmt.setLong(9, timestamp.toDbMicros() ?: throw
faultyTimestampByBank())
- stmt.setString(10, acctSvcrRef)
- stmt.setString(11, pmtInfId)
- stmt.setString(12, endToEndId)
stmt.executeQuery().use {
when {
@@ -1414,10 +1385,7 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
suspend fun talerAddIncomingCreate(
req: AddIncomingRequest,
username: String,
- timestamp: Instant,
- acctSvcrRef: String = "not used",
- pmtInfId: String = "not used",
- endToEndId: String = "not used",
+ timestamp: Instant
): TalerAddIncomingCreationResult = conn { conn ->
val subject = IncomingTxMetadata(req.reserve_pub).encode()
val stmt = conn.prepareStatement("""
@@ -1433,7 +1401,7 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
taler_add_incoming (
?, ?,
(?,?)::taler_amount,
- ?, ?, ?, ?, ?, ?
+ ?, ?, ?
);
""")
@@ -1444,9 +1412,6 @@ class Database(dbConfig: String, private val
bankCurrency: String, private val f
stmt.setString(5, req.debit_account.canonical)
stmt.setString(6, username)
stmt.setLong(7, timestamp.toDbMicros() ?: throw
faultyTimestampByBank())
- stmt.setString(8, acctSvcrRef)
- stmt.setString(9, pmtInfId)
- stmt.setString(10, endToEndId)
stmt.executeQuery().use {
when {
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt
b/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt
index 276046dc..3d9d5241 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt
@@ -205,11 +205,7 @@ data class BankAccountTransaction(
*/
val bankAccountId: Long,
// Null if this type is used to _create_ one transaction.
- val dbRowId: Long,
- // Following are ISO20022 specific.
- val accountServicerReference: String,
- val paymentInformationId: String,
- val endToEndId: String,
+ val dbRowId: Long
)
/**
diff --git a/bank/src/test/kotlin/BankIntegrationApiTest.kt
b/bank/src/test/kotlin/BankIntegrationApiTest.kt
index e53dad21..da3d067f 100644
--- a/bank/src/test/kotlin/BankIntegrationApiTest.kt
+++ b/bank/src/test/kotlin/BankIntegrationApiTest.kt
@@ -30,9 +30,9 @@ class BankIntegrationApiTest {
// Check OK
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:9" })
+ jsonBody { "amount" to "KUDOS:9" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.get("/taler-integration/withdrawal-operation/$uuid")
.assertOk()
@@ -68,9 +68,9 @@ class BankIntegrationApiTest {
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
// Check OK
@@ -83,17 +83,17 @@ class BankIntegrationApiTest {
}.assertOk()
// Check already selected
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json(req) {
+ jsonBody(req) {
"reserve_pub" to randEddsaPublicKey()
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT)
}
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
// Check reserve_pub_reuse
@@ -102,17 +102,17 @@ class BankIntegrationApiTest {
}.assertConflict().assertErr(TalerErrorCode.BANK_DUPLICATE_RESERVE_PUB_SUBJECT)
// Check unknown account
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/UNKNOWN-IBAN-XYZ")
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNKNOWN_ACCOUNT)
// Check account not exchange
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/MERCHANT-IBAN-XYZ")
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_ACCOUNT_IS_NOT_EXCHANGE)
}
}
diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt
b/bank/src/test/kotlin/CoreBankApiTest.kt
index 98e5385b..f2c12342 100644
--- a/bank/src/test/kotlin/CoreBankApiTest.kt
+++ b/bank/src/test/kotlin/CoreBankApiTest.kt
@@ -59,10 +59,10 @@ class CoreBankTokenApiTest {
// New default token
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "scope" to "readonly"})
+ jsonBody { "scope" to "readonly" }
}.assertOk().run {
// Checking that the token lifetime defaulted to 24 hours.
- val resp =
Json.decodeFromString<TokenSuccessResponse>(bodyAsText())
+ val resp = json<TokenSuccessResponse>()
val token =
db.bearerTokenGet(Base32Crockford.decode(resp.access_token))
val lifeTime = Duration.between(token!!.creationTime,
token.expirationTime)
assertEquals(Duration.ofDays(1), lifeTime)
@@ -71,10 +71,10 @@ class CoreBankTokenApiTest {
// Check default duration
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "scope" to "readonly" })
+ jsonBody { "scope" to "readonly" }
}.assertOk().run {
// Checking that the token lifetime defaulted to 24 hours.
- val resp =
Json.decodeFromString<TokenSuccessResponse>(bodyAsText())
+ val resp = json<TokenSuccessResponse>()
val token =
db.bearerTokenGet(Base32Crockford.decode(resp.access_token))
val lifeTime = Duration.between(token!!.creationTime,
token.expirationTime)
assertEquals(Duration.ofDays(1), lifeTime)
@@ -83,27 +83,27 @@ class CoreBankTokenApiTest {
// Check refresh
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"scope" to "readonly"
"refreshable" to true
- })
+ }
}.assertOk().run {
- val token =
Json.decodeFromString<TokenSuccessResponse>(bodyAsText()).access_token
+ val token = json<TokenSuccessResponse>().access_token
client.post("/accounts/merchant/token") {
headers["Authorization"] = "Bearer secret-token:$token"
- jsonBody(json { "scope" to "readonly" })
+ jsonBody { "scope" to "readonly" }
}.assertOk()
}
// Check'forever' case.
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"scope" to "readonly"
"duration" to json {
"d_us" to "forever"
}
- })
+ }
}.run {
val never: TokenSuccessResponse =
Json.decodeFromString(bodyAsText())
assertEquals(Instant.MAX, never.expiration.t_s)
@@ -112,30 +112,30 @@ class CoreBankTokenApiTest {
// Check too big or invalid durations
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"scope" to "readonly"
"duration" to json {
"d_us" to "invalid"
}
- })
+ }
}.assertBadRequest()
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"scope" to "readonly"
"duration" to json {
"d_us" to Long.MAX_VALUE
}
- })
+ }
}.assertBadRequest()
client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"scope" to "readonly"
"duration" to json {
"d_us" to -1
}
- })
+ }
}.assertBadRequest()
}
@@ -145,9 +145,9 @@ class CoreBankTokenApiTest {
// TODO test restricted
val token = client.post("/accounts/merchant/token") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "scope" to "readonly" })
+ jsonBody { "scope" to "readonly" }
}.assertOk().run {
-
Json.decodeFromString<TokenSuccessResponse>(bodyAsText()).access_token
+ json<TokenSuccessResponse>().access_token
}
// Check OK
client.delete("/accounts/merchant/token") {
@@ -189,35 +189,35 @@ class CoreBankAccountsMgmtApiTest {
// Test generate payto_uri
client.post("/accounts") {
- jsonBody(json {
+ jsonBody {
"username" to "jor"
"password" to "password"
"name" to "Joe"
- })
+ }
}.assertCreated()
// Reserved account
reservedAccounts.forEach {
client.post("/accounts") {
- jsonBody(json {
+ jsonBody {
"username" to it
"password" to "password"
"name" to "John Smith"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_RESERVED_USERNAME_CONFLICT)
}
// Testing login conflict
client.post("/accounts") {
- jsonBody(json(req) {
+ jsonBody(req) {
"name" to "Foo"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_REGISTER_USERNAME_REUSE)
// Testing payto conflict
client.post("/accounts") {
- jsonBody(json(req) {
+ jsonBody(req) {
"username" to "bar"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_REGISTER_PAYTO_URI_REUSE)
client.get("/accounts/bar") {
basicAuth("admin", "admin-password")
@@ -237,9 +237,9 @@ class CoreBankAccountsMgmtApiTest {
repeat(100) {
client.post("/accounts") {
basicAuth("admin", "admin-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"username" to "foo$it"
- })
+ }
}.assertCreated()
client.get("/accounts/foo$it") {
basicAuth("admin", "admin-password")
@@ -260,9 +260,9 @@ class CoreBankAccountsMgmtApiTest {
// Check unsufficient fund
client.post("/accounts") {
basicAuth("admin", "admin-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"username" to "bar"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
client.get("/accounts/bar") {
basicAuth("admin", "admin-password")
@@ -305,11 +305,11 @@ class CoreBankAccountsMgmtApiTest {
// successful deletion
client.post("/accounts") {
- jsonBody(json {
+ jsonBody {
"username" to "john"
"password" to "password"
"name" to "John Smith"
- })
+ }
}.assertCreated()
client.delete("/accounts/john") {
basicAuth("admin", "admin-password")
@@ -323,18 +323,18 @@ class CoreBankAccountsMgmtApiTest {
// fail to delete, due to a non-zero balance.
client.post("/accounts/exchange/transactions") {
basicAuth("exchange", "exchange-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/MERCHANT-IBAN-XYZ?message=payout&amount=KUDOS:1"
- })
+ }
}.assertNoContent()
client.delete("/accounts/merchant") {
basicAuth("admin", "admin-password")
}.assertConflict().assertErr(TalerErrorCode.BANK_ACCOUNT_BALANCE_NOT_ZERO)
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout&amount=KUDOS:1"
- })
+ }
}.assertNoContent()
client.delete("/accounts/merchant") {
basicAuth("admin", "admin-password")
@@ -383,18 +383,18 @@ class CoreBankAccountsMgmtApiTest {
// Check admin account cannot be exchange
client.patch("/accounts/admin") {
basicAuth("admin", "admin-password")
- jsonBody(json { "is_taler_exchange" to true })
+ jsonBody { "is_taler_exchange" to true }
}.assertForbidden()
// But we can change its debt limit
client.patch("/accounts/admin") {
basicAuth("admin", "admin-password")
- jsonBody(json { "debit_threshold" to "KUDOS:100" })
+ jsonBody { "debit_threshold" to "KUDOS:100" }
}.assertNoContent()
// Check currency
client.patch("/accounts/merchant") {
basicAuth("admin", "admin-password")
- jsonBody(json(req) { "debit_threshold" to "EUR:100" })
+ jsonBody(req) { "debit_threshold" to "EUR:100" }
}.assertBadRequest()
// Check patch
@@ -416,9 +416,9 @@ class CoreBankAccountsMgmtApiTest {
// Changing the password.
client.patch("/accounts/merchant/auth") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"new_password" to "new-password"
- })
+ }
}.assertNoContent()
// Previous password should fail.
client.patch("/accounts/merchant/auth") {
@@ -427,9 +427,9 @@ class CoreBankAccountsMgmtApiTest {
// New password should succeed.
client.patch("/accounts/merchant/auth") {
basicAuth("merchant", "new-password")
- jsonBody(json {
+ jsonBody {
"new_password" to "merchant-password"
- })
+ }
}.assertNoContent()
}
@@ -451,18 +451,18 @@ class CoreBankAccountsMgmtApiTest {
// Gen some public and private accounts
repeat(5) {
client.post("/accounts") {
- jsonBody(json {
+ jsonBody {
"username" to "$it"
"password" to "password"
"name" to "Mr $it"
"is_public" to (it%2 == 0)
- })
+ }
}.assertCreated()
}
// All public
client.get("/public-accounts").run {
assertOk()
- val obj =
Json.decodeFromString<PublicAccountsResponse>(bodyAsText())
+ val obj = json<PublicAccountsResponse>()
assertEquals(3, obj.public_accounts.size)
obj.public_accounts.forEach {
assertEquals(0, it.account_name.toInt() % 2)
@@ -473,7 +473,7 @@ class CoreBankAccountsMgmtApiTest {
basicAuth("admin", "admin-password")
}.run {
assertOk()
- val obj =
Json.decodeFromString<ListBankAccountsResponse>(bodyAsText())
+ val obj = json<ListBankAccountsResponse>()
assertEquals(6, obj.accounts.size)
obj.accounts.forEachIndexed { idx, it ->
if (idx == 0) {
@@ -488,7 +488,7 @@ class CoreBankAccountsMgmtApiTest {
basicAuth("admin", "admin-password")
}.run {
assertOk()
- val obj =
Json.decodeFromString<ListBankAccountsResponse>(bodyAsText())
+ val obj = json<ListBankAccountsResponse>()
assertEquals(1, obj.accounts.size)
assertEquals("3", obj.accounts[0].username)
}
@@ -585,18 +585,18 @@ class CoreBankTransactionsApiTest {
repeat(3) {
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout$it&amount=KUDOS:0.$it"
- })
+ }
}.assertNoContent()
}
// Gen two transactions from exchange to merchant
repeat(2) {
client.post("/accounts/exchange/transactions") {
basicAuth("exchange", "exchange-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/MERCHANT-IBAN-XYZ?message=payout$it&amount=KUDOS:0.$it"
- })
+ }
}.assertNoContent()
}
@@ -632,9 +632,9 @@ class CoreBankTransactionsApiTest {
delay(200)
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout_poll&amount=KUDOS:4.2"
- })
+ }
}.assertNoContent()
}
@@ -642,9 +642,9 @@ class CoreBankTransactionsApiTest {
repeat(30) {
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout_range&amount=KUDOS:0.001"
- })
+ }
}.assertNoContent()
}
@@ -667,10 +667,10 @@ class CoreBankTransactionsApiTest {
// Create transaction
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to "payto://iban/EXCHANGE-IBAN-XYZ?message=payout"
"amount" to "KUDOS:0.3"
- })
+ }
}.assertNoContent()
// Check OK
client.get("/accounts/merchant/transactions/1") {
@@ -692,7 +692,7 @@ class CoreBankTransactionsApiTest {
// POST /transactions
@Test
- fun testCreate() = bankSetup { _ ->
+ fun create() = bankSetup { _ ->
val valid_req = json {
"payto_uri" to "payto://iban/EXCHANGE-IBAN-XYZ?message=payout"
"amount" to "KUDOS:0.3"
@@ -715,9 +715,9 @@ class CoreBankTransactionsApiTest {
// Check amount in payto_uri
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout2&amount=KUDOS:1.05"
- })
+ }
}.assertNoContent()
client.get("/accounts/merchant/transactions/3") {
basicAuth("merchant", "merchant-password")
@@ -729,10 +729,10 @@ class CoreBankTransactionsApiTest {
// Check amount in payto_uri precedence
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout3&amount=KUDOS:1.05"
"amount" to "KUDOS:10.003"
- })
+ }
}.assertNoContent()
client.get("/accounts/merchant/transactions/5") {
basicAuth("merchant", "merchant-password")
@@ -744,41 +744,41 @@ class CoreBankTransactionsApiTest {
// Testing the wrong currency
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"amount" to "EUR:3.3"
- })
+ }
}.assertBadRequest().assertErr(TalerErrorCode.GENERIC_CURRENCY_MISMATCH)
// Surpassing the debt limit
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
contentType(ContentType.Application.Json)
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"amount" to "KUDOS:555"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
// Missing message
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
contentType(ContentType.Application.Json)
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"payto_uri" to "payto://iban/EXCHANGE-IBAN-XYZ"
- })
+ }
}.assertBadRequest()
// Unknown creditor
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
contentType(ContentType.Application.Json)
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"payto_uri" to "payto://iban/UNKNOWN-IBAN-XYZ?message=payout"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNKNOWN_CREDITOR)
// Transaction to self
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
contentType(ContentType.Application.Json)
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"payto_uri" to "payto://iban/MERCHANT-IBAN-XYZ?message=payout"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_SAME_ACCOUNT)
suspend fun checkBalance(
@@ -813,24 +813,24 @@ class CoreBankTransactionsApiTest {
repeat(2) {
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/CUSTOMER-IBAN-XYZ?message=payout2&amount=KUDOS:3"
- })
+ }
}.assertNoContent()
}
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/CUSTOMER-IBAN-XYZ?message=payout2&amount=KUDOS:3"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
checkBalance(true, "KUDOS:8.4", false, "KUDOS:6")
// Send throught debt
client.post("/accounts/customer/transactions") {
basicAuth("customer", "customer-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/MERCHANT-IBAN-XYZ?message=payout2&amount=KUDOS:10"
- })
+ }
}.assertNoContent()
checkBalance(false, "KUDOS:1.6", true, "KUDOS:4")
}
@@ -843,19 +843,19 @@ class CoreBankWithdrawalApiTest {
// Check OK
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:9.0" })
+ jsonBody { "amount" to "KUDOS:9.0" }
}.assertOk()
// Check exchange account
client.post("/accounts/exchange/withdrawals") {
basicAuth("exchange", "exchange-password")
- jsonBody(json { "amount" to "KUDOS:9.0" })
+ jsonBody { "amount" to "KUDOS:9.0" }
}.assertConflict().assertErr(TalerErrorCode.BANK_ACCOUNT_IS_EXCHANGE)
// Check insufficient fund
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:90" })
+ jsonBody { "amount" to "KUDOS:90" }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
}
@@ -865,9 +865,9 @@ class CoreBankWithdrawalApiTest {
// Check OK
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:9.0" } )
+ jsonBody { "amount" to "KUDOS:9.0" }
}.assertOk().run {
- val opId =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val opId = json<BankAccountCreateWithdrawalResponse>()
client.get("/withdrawals/${opId.withdrawal_id}") {
basicAuth("merchant", "merchant-password")
}.assertOk()
@@ -886,9 +886,9 @@ class CoreBankWithdrawalApiTest {
// Check abort created
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
// Check OK
@@ -900,15 +900,15 @@ class CoreBankWithdrawalApiTest {
// Check abort selected
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
// Check OK
@@ -920,15 +920,15 @@ class CoreBankWithdrawalApiTest {
// Check abort confirmed
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
client.post("/withdrawals/$uuid/confirm").assertNoContent()
@@ -951,9 +951,9 @@ class CoreBankWithdrawalApiTest {
// Check confirm created
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
// Check err
@@ -964,15 +964,15 @@ class CoreBankWithdrawalApiTest {
// Check confirm selected
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
// Check OK
@@ -984,47 +984,47 @@ class CoreBankWithdrawalApiTest {
// Check confirm aborted
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:1" })
+ jsonBody { "amount" to "KUDOS:1" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
client.post("/withdrawals/$uuid/abort").assertNoContent()
// Check error
client.post("/withdrawals/$uuid/confirm").assertConflict()
- .assertErr(TalerErrorCode.BANK_CONFIRM_ABORT_CONFLICT)
+ .assertErr(TalerErrorCode.BANK_CONFIRM_ABORT_CONFLICT)
}
// Check balance insufficient
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:5" })
+ jsonBody { "amount" to "KUDOS:5" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/$uuid") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
// Send too much money
client.post("/accounts/merchant/transactions") {
basicAuth("merchant", "merchant-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/EXCHANGE-IBAN-XYZ?message=payout&amount=KUDOS:5"
- })
+ }
}.assertNoContent()
client.post("/withdrawals/$uuid/confirm").assertConflict()
- .assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
+ .assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
// Check can abort because not confirmed
client.post("/withdrawals/$uuid/abort").assertNoContent()
@@ -1046,7 +1046,7 @@ class CoreBankCashoutApiTest {
private suspend fun ApplicationTestBuilder.convert(amount: String):
TalerAmount {
// Check conversion
client.get("/cashout-rate?amount_debit=$amount").assertOk().run {
- val resp = Json.decodeFromString<ConversionResponse>(bodyAsText())
+ val resp = json<ConversionResponse>()
return resp.amount_credit
}
}
@@ -1076,40 +1076,40 @@ class CoreBankCashoutApiTest {
// Check insufficient fund
client.post("/accounts/customer/cashouts") {
basicAuth("customer", "customer-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"amount_debit" to "KUDOS:75"
"amount_credit" to convert("KUDOS:75")
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
// Check wrong conversion
client.post("/accounts/customer/cashouts") {
basicAuth("customer", "customer-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"amount_credit" to convert("KUDOS:2")
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_BAD_CONVERSION)
// Check wrong currency
client.post("/accounts/customer/cashouts") {
basicAuth("customer", "customer-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"amount_debit" to "EUR:1"
- })
+ }
}.assertBadRequest().assertErr(TalerErrorCode.GENERIC_CURRENCY_MISMATCH)
client.post("/accounts/customer/cashouts") {
basicAuth("customer", "customer-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"amount_credit" to "EUR:1"
- })
+ }
}.assertBadRequest().assertErr(TalerErrorCode.GENERIC_CURRENCY_MISMATCH)
// Check missing TAN info
client.post("/accounts/customer/cashouts") {
basicAuth("customer", "customer-password")
- jsonBody(json(req) {
+ jsonBody(req) {
"tan_channel" to "sms"
- })
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_MISSING_TAN_INFO)
}
@@ -1128,7 +1128,7 @@ class CoreBankCashoutApiTest {
basicAuth("customer", "customer-password")
jsonBody(req)
}.assertOk().run {
- val uuid =
Json.decodeFromString<CashoutPending>(bodyAsText()).cashout_id
+ val uuid = json<CashoutPending>().cashout_id
// Check OK
client.post("/accounts/customer/cashouts/$uuid/abort") {
@@ -1145,11 +1145,11 @@ class CoreBankCashoutApiTest {
basicAuth("customer", "customer-password")
jsonBody(req)
}.assertOk().run {
- val uuid =
Json.decodeFromString<CashoutPending>(bodyAsText()).cashout_id
+ val uuid = json<CashoutPending>().cashout_id
client.post("/accounts/customer/cashouts/$uuid/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertNoContent()
// Check error
@@ -1161,13 +1161,13 @@ class CoreBankCashoutApiTest {
// Check bad UUID
client.post("/accounts/customer/cashouts/chocolate/abort") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertBadRequest()
// Check unknown
client.post("/accounts/customer/cashouts/${UUID.randomUUID()}/abort") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertNotFound().assertErr(TalerErrorCode.BANK_TRANSACTION_NOT_FOUND)
}
@@ -1187,23 +1187,23 @@ class CoreBankCashoutApiTest {
basicAuth("customer", "customer-password")
jsonBody(req)
}.assertOk().run {
- val uuid =
Json.decodeFromString<CashoutPending>(bodyAsText()).cashout_id
+ val uuid = json<CashoutPending>().cashout_id
// Check bad TAN code
client.post("/accounts/customer/cashouts/$uuid/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to "nice-try" })
+ jsonBody { "tan" to "nice-try" }
}.assertForbidden()
// Check OK
client.post("/accounts/customer/cashouts/$uuid/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertNoContent()
// Check idempotence
client.post("/accounts/customer/cashouts/$uuid/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertNoContent()
}
@@ -1212,7 +1212,7 @@ class CoreBankCashoutApiTest {
basicAuth("customer", "customer-password")
jsonBody(req)
}.assertOk().run {
- val uuid =
Json.decodeFromString<CashoutPending>(bodyAsText()).cashout_id
+ val uuid = json<CashoutPending>().cashout_id
client.post("/accounts/customer/cashouts/$uuid/abort") {
basicAuth("customer", "customer-password")
}.assertNoContent()
@@ -1220,7 +1220,7 @@ class CoreBankCashoutApiTest {
// Check error
client.post("/accounts/customer/cashouts/$uuid/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertConflict().assertErr(TalerErrorCode.BANK_CONFIRM_ABORT_CONFLICT)
}
@@ -1229,18 +1229,18 @@ class CoreBankCashoutApiTest {
basicAuth("customer", "customer-password")
jsonBody(req)
}.assertOk().run {
- val uuid =
Json.decodeFromString<CashoutPending>(bodyAsText()).cashout_id
+ val uuid = json<CashoutPending>().cashout_id
// Send too much money
client.post("/accounts/customer/transactions") {
basicAuth("customer", "customer-password")
- jsonBody(json {
+ jsonBody {
"payto_uri" to
"payto://iban/merchant-IBAN-XYZ?message=payout&amount=KUDOS:8"
- })
+ }
}.assertNoContent()
client.post("/accounts/customer/cashouts/$uuid/confirm"){
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNALLOWED_DEBIT)
// Check can abort because not confirmed
@@ -1252,13 +1252,13 @@ class CoreBankCashoutApiTest {
// Check bad UUID
client.post("/accounts/customer/cashouts/chocolate/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertBadRequest()
// Check unknown
client.post("/accounts/customer/cashouts/${UUID.randomUUID()}/confirm") {
basicAuth("customer", "customer-password")
- jsonBody(json { "tan" to tanCode() })
+ jsonBody { "tan" to tanCode() }
}.assertNotFound().assertErr(TalerErrorCode.BANK_TRANSACTION_NOT_FOUND)
}
@@ -1267,7 +1267,7 @@ class CoreBankCashoutApiTest {
fun cashoutRate() = bankSetup { _ ->
// Check conversion
client.get("/cashout-rate?amount_debit=KUDOS:1").assertOk().run {
- val resp = Json.decodeFromString<ConversionResponse>(bodyAsText())
+ val resp = json<ConversionResponse>()
assertEquals(TalerAmount("FIAT:1.247"), resp.amount_credit)
}
@@ -1291,7 +1291,7 @@ class CoreBankCashoutApiTest {
Pair(0.75, 0.58), Pair(0.33, 0.24), Pair(0.66, 0.51)
)) {
client.get("/cashin-rate?amount_debit=FIAT:$amount").assertOk().run {
- val resp =
Json.decodeFromString<ConversionResponse>(bodyAsText())
+ val resp = json<ConversionResponse>()
assertEquals(TalerAmount("KUDOS:$converted"),
resp.amount_credit)
}
}
diff --git a/bank/src/test/kotlin/StatsTest.kt
b/bank/src/test/kotlin/StatsTest.kt
index 03209e63..dad4ea5a 100644
--- a/bank/src/test/kotlin/StatsTest.kt
+++ b/bank/src/test/kotlin/StatsTest.kt
@@ -38,20 +38,20 @@ class StatsTest {
suspend fun transfer(amount: TalerAmount) {
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(json {
+ jsonBody {
"request_uid" to randHashCode()
"amount" to amount
"exchange_base_url" to "http://exchange.example.com/"
"wtid" to randShortHashCode()
"credit_account" to "payto://iban/MERCHANT-IBAN-XYZ"
- })
+ }
}.assertOk()
}
suspend fun monitor(count: Long, amount: TalerAmount) {
Timeframe.entries.forEach { timestamp ->
client.get("/monitor?timestamp=${timestamp.name}") {
basicAuth("admin", "admin-password") }.assertOk().run {
- val resp =
Json.decodeFromString<MonitorResponse>(bodyAsText())
+ val resp = json<MonitorResponse>()
assertEquals(count, resp.talerPayoutCount)
assertEquals(amount, resp.talerPayoutInternalVolume)
}
diff --git a/bank/src/test/kotlin/WireGatewayApiTest.kt
b/bank/src/test/kotlin/WireGatewayApiTest.kt
index 87b2fc15..5867a54f 100644
--- a/bank/src/test/kotlin/WireGatewayApiTest.kt
+++ b/bank/src/test/kotlin/WireGatewayApiTest.kt
@@ -135,86 +135,70 @@ class WireGatewayApiTest {
// Trigger conflict due to reused request_uid
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "wtid" to randShortHashCode()
- "exchange_base_url" to
"http://different-exchange.example.com/"
- }
- )
+ jsonBody(valid_req) {
+ "wtid" to randShortHashCode()
+ "exchange_base_url" to "http://different-exchange.example.com/"
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_TRANSFER_REQUEST_UID_REUSED)
// Currency mismatch
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "amount" to "EUR:33"
- }
- )
+ jsonBody(valid_req) {
+ "amount" to "EUR:33"
+ }
}.assertBadRequest().assertErr(TalerErrorCode.GENERIC_CURRENCY_MISMATCH)
// Unknown account
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "request_uid" to randHashCode()
- "wtid" to randShortHashCode()
- "credit_account" to "payto://iban/UNKNOWN-IBAN-XYZ"
- }
- )
+ jsonBody(valid_req) {
+ "request_uid" to randHashCode()
+ "wtid" to randShortHashCode()
+ "credit_account" to "payto://iban/UNKNOWN-IBAN-XYZ"
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNKNOWN_CREDITOR)
// Same account
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "request_uid" to randHashCode()
- "wtid" to randShortHashCode()
- "credit_account" to "payto://iban/EXCHANGE-IBAN-XYZ"
- }
- )
+ jsonBody(valid_req) {
+ "request_uid" to randHashCode()
+ "wtid" to randShortHashCode()
+ "credit_account" to "payto://iban/EXCHANGE-IBAN-XYZ"
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_ACCOUNT_IS_EXCHANGE)
// Bad BASE32 wtid
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "wtid" to "I love chocolate"
- }
- )
+ jsonBody(valid_req) {
+ "wtid" to "I love chocolate"
+ }
}.assertBadRequest()
// Bad BASE32 len wtid
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "wtid" to randBase32Crockford(31)
- }
- )
+ jsonBody(valid_req) {
+ "wtid" to randBase32Crockford(31)
+ }
}.assertBadRequest()
// Bad BASE32 request_uid
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "request_uid" to "I love chocolate"
- }
- )
+ jsonBody(valid_req) {
+ "request_uid" to "I love chocolate"
+ }
}.assertBadRequest()
// Bad BASE32 len wtid
client.post("/accounts/exchange/taler-wire-gateway/transfer") {
basicAuth("exchange", "exchange-password")
- jsonBody(
- json(valid_req) {
- "request_uid" to randBase32Crockford(65)
- }
- )
+ jsonBody(valid_req) {
+ "request_uid" to randBase32Crockford(65)
+ }
}.assertBadRequest()
}
@@ -272,15 +256,15 @@ class WireGatewayApiTest {
// Gen one transaction using withdraw logic
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:9" })
+ jsonBody { "amount" to "KUDOS:9" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/${uuid}") {
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
client.post("/withdrawals/${uuid}/confirm") {
basicAuth("merchant", "merchant-password")
@@ -355,15 +339,15 @@ class WireGatewayApiTest {
delay(200)
client.post("/accounts/merchant/withdrawals") {
basicAuth("merchant", "merchant-password")
- jsonBody(json { "amount" to "KUDOS:9" })
+ jsonBody { "amount" to "KUDOS:9" }
}.assertOk().run {
- val resp =
Json.decodeFromString<BankAccountCreateWithdrawalResponse>(bodyAsText())
+ val resp = json<BankAccountCreateWithdrawalResponse>()
val uuid = resp.taler_withdraw_uri.split("/").last()
client.post("/taler-integration/withdrawal-operation/${uuid}")
{
- jsonBody(json {
+ jsonBody {
"reserve_pub" to randEddsaPublicKey()
"selected_exchange" to
IbanPayTo("payto://iban/EXCHANGE-IBAN-XYZ")
- })
+ }
}.assertOk()
client.post("/withdrawals/${uuid}/confirm") {
basicAuth("merchant", "merchant-password")
@@ -533,49 +517,41 @@ class WireGatewayApiTest {
// Currency mismatch
client.post("/accounts/exchange/taler-wire-gateway/admin/add-incoming") {
basicAuth("admin", "admin-password")
- jsonBody(
- json(valid_req) {
- "amount" to "EUR:33"
- }
- )
+ jsonBody(valid_req) { "amount" to "EUR:33" }
}.assertBadRequest().assertErr(TalerErrorCode.GENERIC_CURRENCY_MISMATCH)
// Unknown account
client.post("/accounts/exchange/taler-wire-gateway/admin/add-incoming") {
basicAuth("admin", "admin-password")
- jsonBody(
- json(valid_req) {
- "reserve_pub" to randEddsaPublicKey()
- "debit_account" to "payto://iban/UNKNOWN-IBAN-XYZ"
- }
- )
+ jsonBody(valid_req) {
+ "reserve_pub" to randEddsaPublicKey()
+ "debit_account" to "payto://iban/UNKNOWN-IBAN-XYZ"
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_UNKNOWN_DEBTOR)
// Same account
client.post("/accounts/exchange/taler-wire-gateway/admin/add-incoming") {
basicAuth("admin", "admin-password")
- jsonBody(
- json(valid_req) {
- "reserve_pub" to randEddsaPublicKey()
- "debit_account" to "payto://iban/EXCHANGE-IBAN-XYZ"
- }
- )
+ jsonBody(valid_req) {
+ "reserve_pub" to randEddsaPublicKey()
+ "debit_account" to "payto://iban/EXCHANGE-IBAN-XYZ"
+ }
}.assertConflict().assertErr(TalerErrorCode.BANK_ACCOUNT_IS_EXCHANGE)
// Bad BASE32 reserve_pub
client.post("/accounts/exchange/taler-wire-gateway/admin/add-incoming") {
basicAuth("admin", "admin-password")
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"reserve_pub" to "I love chocolate"
- })
+ }
}.assertBadRequest()
// Bad BASE32 len reserve_pub
client.post("/accounts/exchange/taler-wire-gateway/admin/add-incoming") {
basicAuth("admin", "admin-password")
- jsonBody(json(valid_req) {
+ jsonBody(valid_req) {
"reserve_pub" to randBase32Crockford(31)
- })
+ }
}.assertBadRequest()
}
}
\ No newline at end of file
diff --git a/bank/src/test/kotlin/helpers.kt b/bank/src/test/kotlin/helpers.kt
index d0bd69df..857c0f32 100644
--- a/bank/src/test/kotlin/helpers.kt
+++ b/bank/src/test/kotlin/helpers.kt
@@ -88,7 +88,7 @@ fun dbSetup(lambda: suspend (Database) -> Unit) {
suspend fun ApplicationTestBuilder.setMaxDebt(account: String, maxDebt:
TalerAmount) {
client.patch("/accounts/$account") {
basicAuth("admin", "admin-password")
- jsonBody(json { "debit_threshold" to maxDebt })
+ jsonBody { "debit_threshold" to maxDebt }
}.assertNoContent()
}
@@ -109,7 +109,7 @@ fun HttpResponse.assertForbidden(): HttpResponse =
assertStatus(HttpStatusCode.F
suspend fun HttpResponse.assertErr(code: TalerErrorCode): HttpResponse {
- val err = Json.decodeFromString<TalerError>(bodyAsText())
+ val err = json<TalerError>()
assertEquals(code.code, err.code)
return this
}
@@ -153,6 +153,17 @@ inline fun <reified B> HttpRequestBuilder.jsonBody(b: B,
deflate: Boolean = fals
}
}
+inline suspend fun HttpRequestBuilder.jsonBody(
+ from: JsonObject = JsonObject(emptyMap()),
+ deflate: Boolean = false,
+ builderAction: JsonBuilder.() -> Unit
+) {
+ jsonBody(json(from, builderAction), deflate)
+}
+
+inline suspend fun <reified B> HttpResponse.json(): B =
+ Json.decodeFromString(kotlinx.serialization.serializer<B>(), bodyAsText())
+
/* ----- Json DSL ----- */
inline fun json(from: JsonObject = JsonObject(emptyMap()), builderAction:
JsonBuilder.() -> Unit): JsonObject {
diff --git a/build.gradle b/build.gradle
index f3df7d69..233eaa98 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,12 +3,10 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
- // id 'org.jetbrains.kotlin.jvm' version '1.5.30'
- id 'org.jetbrains.kotlin.jvm' version '1.9.10'
+ id 'org.jetbrains.kotlin.jvm' version '1.9.20'
id 'idea'
id 'java-library'
id 'maven-publish'
- // id 'signing'
}
group = 'tech.libeufin'
@@ -21,10 +19,8 @@ if (!JavaVersion.current().isJava11Compatible()){
}
allprojects {
- ext.set("kotlin_version", "1.9.10")
+ ext.set("kotlin_version", "1.9.20")
ext.set("ktor_version", "2.3.3")
- ext.set("ktor_auth_version", "1.6.8")
- ext.set("exposed_version", "0.41.1")
repositories {
mavenCentral()
diff --git a/database-versioning/libeufin-bank-0001.sql
b/database-versioning/libeufin-bank-0001.sql
index d14d7a59..2df678fc 100644
--- a/database-versioning/libeufin-bank-0001.sql
+++ b/database-versioning/libeufin-bank-0001.sql
@@ -135,7 +135,7 @@ CREATE TABLE IF NOT EXISTS bank_account_transactions
,subject TEXT NOT NULL
,amount taler_amount NOT NULL
,transaction_date BIGINT NOT NULL -- is this ISO20022 terminology? document
format (microseconds since epoch)
- ,account_servicer_reference TEXT NOT NULL
+ ,account_servicer_reference TEXT
,payment_information_id TEXT
,end_to_end_id TEXT
,direction direction_enum NOT NULL
diff --git a/database-versioning/libeufin-bank-procedures.sql
b/database-versioning/libeufin-bank-procedures.sql
index c518a836..14d8d07c 100644
--- a/database-versioning/libeufin-bank-procedures.sql
+++ b/database-versioning/libeufin-bank-procedures.sql
@@ -318,9 +318,6 @@ CREATE OR REPLACE FUNCTION taler_transfer(
IN in_credit_account_payto TEXT,
IN in_username TEXT,
IN in_timestamp BIGINT,
- IN in_account_servicer_reference TEXT,
- IN in_payment_information_id TEXT,
- IN in_end_to_end_id TEXT,
-- Error status
OUT out_debtor_not_found BOOLEAN,
OUT out_debtor_not_exchange BOOLEAN,
@@ -390,9 +387,9 @@ SELECT
in_subject,
in_amount,
in_timestamp,
- in_account_servicer_reference,
- in_payment_information_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_exchange_balance_insufficient THEN
RETURN;
@@ -401,20 +398,8 @@ out_timestamp=in_timestamp;
-- Register outgoing transaction
CALL register_outgoing(in_request_uid, in_wtid, in_exchange_base_url,
out_tx_row_id);
END $$;
-COMMENT ON FUNCTION taler_transfer(
- bytea,
- bytea,
- text,
- taler_amount,
- text,
- text,
- text,
- bigint,
- text,
- text,
- text
- )-- TODO new comment
- IS 'function that (1) inserts the TWG requests'
+-- TODO new comment
+COMMENT ON FUNCTION taler_transfer IS 'function that (1) inserts the TWG
requests'
'details into the database and (2) performs '
'the actual bank transaction to pay the merchant';
@@ -426,9 +411,6 @@ CREATE OR REPLACE FUNCTION taler_add_incoming(
IN in_debit_account_payto TEXT,
IN in_username TEXT,
IN in_timestamp BIGINT,
- IN in_account_servicer_reference TEXT,
- IN in_payment_information_id TEXT,
- IN in_end_to_end_id TEXT,
-- Error status
OUT out_creditor_not_found BOOLEAN,
OUT out_creditor_not_exchange BOOLEAN,
@@ -491,9 +473,9 @@ SELECT
in_subject,
in_amount,
in_timestamp,
- in_account_servicer_reference,
- in_payment_information_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_debitor_balance_insufficient THEN
RETURN;
@@ -501,18 +483,8 @@ END IF;
-- Register incoming transaction
CALL register_incoming(in_reserve_pub, out_tx_row_id,
exchange_bank_account_id);
END $$;
-COMMENT ON FUNCTION taler_add_incoming(
- bytea,
- text,
- taler_amount,
- text,
- text,
- bigint,
- text,
- text,
- text
- ) -- TODO new comment
- IS 'function that (1) inserts the TWG requests'
+-- TODO new comment
+COMMENT ON FUNCTION taler_add_incoming IS 'function that (1) inserts the TWG
requests'
'details into the database and (2) performs '
'the actual bank transaction to pay the merchant';
@@ -522,9 +494,6 @@ CREATE OR REPLACE FUNCTION bank_transaction(
IN in_subject TEXT,
IN in_amount taler_amount,
IN in_timestamp BIGINT,
- IN in_account_servicer_reference TEXT,
- IN in_payment_information_id TEXT,
- IN in_end_to_end_id TEXT,
-- Error status
OUT out_creditor_not_found BOOLEAN,
OUT out_debtor_not_found BOOLEAN,
@@ -581,9 +550,9 @@ SELECT
in_subject,
in_amount,
in_timestamp,
- in_account_servicer_reference,
- in_payment_information_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_balance_insufficient THEN
RETURN;
@@ -693,9 +662,6 @@ END $$;
CREATE OR REPLACE FUNCTION confirm_taler_withdrawal(
IN in_withdrawal_uuid uuid,
IN in_confirmation_date BIGINT,
- IN in_acct_svcr_ref TEXT,
- IN in_pmt_inf_id TEXT,
- IN in_end_to_end_id TEXT,
OUT out_no_op BOOLEAN,
OUT out_balance_insufficient BOOLEAN,
OUT out_creditor_not_found BOOLEAN,
@@ -758,9 +724,9 @@ FROM bank_wire_transfer(
subject_local,
amount_local,
in_confirmation_date,
- in_acct_svcr_ref,
- in_pmt_inf_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_balance_insufficient THEN
RETURN;
@@ -774,7 +740,7 @@ UPDATE taler_withdrawal_operations
-- Register incoming transaction
CALL register_incoming(reserve_pub_local, tx_row_id, exchange_bank_account_id);
END $$;
-COMMENT ON FUNCTION confirm_taler_withdrawal(uuid, bigint, text, text, text)
+COMMENT ON FUNCTION confirm_taler_withdrawal
IS 'Set a withdrawal operation as confirmed and wire the funds to the
exchange.';
CREATE OR REPLACE FUNCTION bank_wire_transfer(
diff --git a/nexus/build.gradle b/nexus/build.gradle
index fdf16c52..2de7cec8 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -4,7 +4,7 @@ plugins {
id 'application'
id 'org.jetbrains.kotlin.jvm'
id "com.github.johnrengelman.shadow" version "8.1.1"
- id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.10'
+ id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
}
sourceSets {
@@ -66,11 +66,9 @@ dependencies {
implementation 'com.zaxxer:HikariCP:5.0.1'
// Ktor client library
implementation "io.ktor:ktor-client-apache:$ktor_version"
- implementation "io.ktor:ktor-client-auth:$ktor_version"
// Brings the call-logging library too.
implementation "io.ktor:ktor-server-test-host:$ktor_version"
- implementation "io.ktor:ktor-auth:$ktor_auth_version"
// PDF generation
implementation 'com.itextpdf:itext7-core:7.1.16'
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated (295ce2bc -> 6788842c),
gnunet <=