libeufin

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

commit b082dd8bdc4e35ac5d836bc6aff2b0ef6313b9bd
parent 5ffae0e12b62c0eabfa997657eabf02b6dcf9502
Author: Antoine A <>
Date:   Fri, 12 Jan 2024 13:03:06 +0000

Remove deprecated endpoints and fields

Diffstat:
MMakefile | 4++++
Mbank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt | 54+++++++++---------------------------------------------
Mbank/src/main/kotlin/tech/libeufin/bank/Main.kt | 1-
Mbank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt | 11-----------
Mbank/src/main/kotlin/tech/libeufin/bank/db/AccountDAO.kt | 1-
Mbank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt | 5+----
Mbank/src/test/kotlin/BankIntegrationApiTest.kt | 2+-
Mbank/src/test/kotlin/CoreBankApiTest.kt | 18+++++++-----------
Mbank/src/test/kotlin/helpers.kt | 2+-
Mbank/src/test/kotlin/routines.kt | 4++--
10 files changed, 25 insertions(+), 77 deletions(-)

diff --git a/Makefile b/Makefile @@ -101,3 +101,7 @@ check: install-nobuild-bank-files .PHONY: test test: install-nobuild-bank-files ./gradlew test --tests $(test) -i + +.PHONY: integration-test +integration-test: install-nobuild-bank-files + ./gradlew :integration:test --tests $(test) -i diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt @@ -143,9 +143,6 @@ private fun Routing.coreBankTokenApi(db: Database) { } suspend fun createAccount(db: Database, ctx: BankConfig, req: RegisterAccountRequest, isAdmin: Boolean): Pair<AccountCreationResult, IbanPayTo> { - val reqPayto = req.payto_uri ?: req.internal_payto_uri - val contactData = req.contact_data ?: req.challenge_contact_data - // Prohibit reserved usernames: if (RESERVED_ACCOUNTS.contains(req.username)) throw conflict( @@ -171,8 +168,8 @@ suspend fun createAccount(db: Database, ctx: BankConfig, req: RegisterAccountReq throw unsupportedTanChannel(req.tan_channel) } val missing = when (req.tan_channel) { - TanChannel.sms -> contactData?.phone?.get() == null - TanChannel.email -> contactData?.email?.get() == null + TanChannel.sms -> req.contact_data?.phone?.get() == null + TanChannel.email -> req.contact_data?.email?.get() == null } if (missing) throw conflict( @@ -187,15 +184,15 @@ suspend fun createAccount(db: Database, ctx: BankConfig, req: RegisterAccountReq TalerErrorCode.END ) - var retry = if (reqPayto == null) IBAN_ALLOCATION_RETRY_COUNTER else 0 + var retry = if (req.payto_uri == null) IBAN_ALLOCATION_RETRY_COUNTER else 0 while (true) { - val internalPayto = reqPayto ?: IbanPayTo(genIbanPaytoUri()) + val internalPayto = req.payto_uri ?: IbanPayTo(genIbanPaytoUri()) val res = db.account.create( login = req.username, name = req.name, - email = contactData?.email?.get(), - phone = contactData?.phone?.get(), + email = req.contact_data?.email?.get(), + phone = req.contact_data?.phone?.get(), cashoutPayto = req.cashout_payto_uri, password = req.password, internalPaytoUri = internalPayto, @@ -205,7 +202,7 @@ suspend fun createAccount(db: Database, ctx: BankConfig, req: RegisterAccountReq bonus = if (!req.is_taler_exchange) ctx.registrationBonus else TalerAmount(0, 0, ctx.regionalCurrency), tanChannel = req.tan_channel, - checkPaytoIdempotent = req.internal_payto_uri != null + checkPaytoIdempotent = req.payto_uri != null ) // Retry with new IBAN if (res == AccountCreationResult.PayToReuse && retry > 0) { @@ -227,7 +224,6 @@ suspend fun patchAccount( info: String? = null ): AccountPatchResult { req.debit_threshold?.run { ctx.checkRegionalCurrency(this) } - val contactData = req.contact_data ?: req.challenge_contact_data if (username == "admin" && req.is_public == true) throw conflict( @@ -243,8 +239,8 @@ suspend fun patchAccount( login = username, name = req.name, cashoutPayto = req.cashout_payto_uri, - email = contactData?.email ?: Option.None, - phone = contactData?.phone ?: Option.None, + email = req.contact_data?.email ?: Option.None, + phone = req.contact_data?.phone ?: Option.None, tan_channel = req.tan_channel, isPublic = req.is_public, debtLimit = req.debit_threshold, @@ -530,20 +526,6 @@ private fun Routing.coreBankWithdrawalApi(db: Database, ctx: BankConfig) { } } } - post("/accounts/{USERNAME}/withdrawals/{withdrawal_id}/abort") { - val opId = call.uuidUriComponent("withdrawal_id") - when (db.withdrawal.abort(opId)) { - AbortResult.UnknownOperation -> throw notFound( - "Withdrawal operation $opId not found", - TalerErrorCode.BANK_TRANSACTION_NOT_FOUND - ) - AbortResult.AlreadyConfirmed -> throw conflict( - "Cannot abort confirmed withdrawal", - TalerErrorCode.BANK_ABORT_CONFIRM_CONFLICT - ) - AbortResult.Success -> call.respond(HttpStatusCode.NoContent) - } - } post("/accounts/{USERNAME}/withdrawals/{withdrawal_id}/confirm") { val opId = call.uuidUriComponent("withdrawal_id") val challenge = call.challenge(db, Operation.withdrawal) @@ -559,24 +541,6 @@ private fun Routing.coreBankWithdrawalApi(db: Database, ctx: BankConfig) { ) call.respond(op) } - post("/withdrawals/{withdrawal_id}/abort") { - val opId = call.uuidUriComponent("withdrawal_id") - when (db.withdrawal.abort(opId)) { - AbortResult.UnknownOperation -> throw notFound( - "Withdrawal operation $opId not found", - TalerErrorCode.BANK_TRANSACTION_NOT_FOUND - ) - AbortResult.AlreadyConfirmed -> throw conflict( - "Cannot abort confirmed withdrawal", - TalerErrorCode.BANK_ABORT_CONFIRM_CONFLICT - ) - AbortResult.Success -> call.respond(HttpStatusCode.NoContent) - } - } - post("/withdrawals/{withdrawal_id}/confirm") { - val opId = call.uuidUriComponent("withdrawal_id") - call.confirmWithdrawalHttp(db, ctx, opId, false) - } } suspend fun ApplicationCall.cashoutHttp(db: Database, ctx: BankConfig, req: CashoutRequest, is2fa: Boolean) { diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt @@ -467,7 +467,6 @@ class CreateAccount : CliktCommand( phone = Option.Some(phone), ), cashout_payto_uri = cashout_payto_uri, - internal_payto_uri = internal_payto_uri, payto_uri = payto_uri, debit_threshold = debit_threshold ) diff --git a/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt b/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt @@ -177,9 +177,6 @@ data class RegisterAccountRequest( val payto_uri: IbanPayTo? = null, val debit_threshold: TalerAmount? = null, val tan_channel: TanChannel? = null, - // TODO remove - val internal_payto_uri: IbanPayTo? = null, - val challenge_contact_data: ChallengeContactData? = null, ) @Serializable @@ -198,8 +195,6 @@ data class AccountReconfiguration( val is_public: Boolean? = null, val debit_threshold: TalerAmount? = null, val tan_channel: Option<TanChannel?> = Option.None, - // TODO remove - val challenge_contact_data: ChallengeContactData? = null, val is_taler_exchange: Boolean? = null, ) @@ -424,10 +419,6 @@ data class WithdrawalPublicInfo ( val username: String, val selected_reserve_pub: EddsaPublicKey? = null, val selected_exchange_account: String? = null, - // TODO remove - val aborted: Boolean, - val confirmation_done: Boolean, - val selection_done: Boolean, ) @Serializable @@ -662,8 +653,6 @@ data class PublicAccount( val payto_uri: String, val balance: Balance, val is_taler_exchange: Boolean, - // TODO remove - val account_name: String ) /** diff --git a/bank/src/main/kotlin/tech/libeufin/bank/db/AccountDAO.kt b/bank/src/main/kotlin/tech/libeufin/bank/db/AccountDAO.kt @@ -517,7 +517,6 @@ class AccountDAO(private val db: Database) { ) { PublicAccount( username = it.getString("login"), - account_name = it.getString("login"), payto_uri = it.getString("internal_payto_uri"), balance = Balance( amount = it.getAmount("balance", db.bankCurrency), diff --git a/bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt b/bank/src/main/kotlin/tech/libeufin/bank/db/WithdrawalDAO.kt @@ -255,10 +255,7 @@ class WithdrawalDAO(private val db: Database) { amount = it.getAmount("amount", db.bankCurrency), username = it.getString("login"), selected_exchange_account = it.getString("selected_exchange_payto"), - selected_reserve_pub = it.getBytes("reserve_pub")?.run(::EddsaPublicKey), - selection_done = it.getBoolean("selection_done"), - confirmation_done = it.getBoolean("confirmation_done"), - aborted = it.getBoolean("aborted"), + selected_reserve_pub = it.getBytes("reserve_pub")?.run(::EddsaPublicKey) ) } } diff --git a/bank/src/test/kotlin/BankIntegrationApiTest.kt b/bank/src/test/kotlin/BankIntegrationApiTest.kt @@ -181,7 +181,7 @@ class BankIntegrationApiTest { } // Check bad UUID - client.postA("/taler-integration/withdrawal-operation//chocolate/abort").assertBadRequest() + client.postA("/taler-integration/withdrawal-operation/chocolate/abort").assertBadRequest() // Check unknown client.postA("/taler-integration/withdrawal-operation/${UUID.randomUUID()}/abort") diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt b/bank/src/test/kotlin/CoreBankApiTest.kt @@ -182,13 +182,13 @@ class CoreBankAccountsApiTest { // Check idempotency with payto client.post("/accounts") { json(req) { - "internal_payto_uri" to payto + "payto_uri" to payto } }.assertOk() // Check payto conflict client.post("/accounts") { json(req) { - "internal_payto_uri" to genIbanPaytoUri() + "payto_uri" to genIbanPaytoUri() } }.assertConflict(TalerErrorCode.BANK_REGISTER_USERNAME_REUSE) } @@ -200,7 +200,7 @@ class CoreBankAccountsApiTest { "password" to "password" "name" to "Jane" "is_public" to true - "internal_payto_uri" to ibanPayto + "payto_uri" to ibanPayto "is_taler_exchange" to true } // Check Ok @@ -381,7 +381,7 @@ class CoreBankAccountsApiTest { "username" to "john" "password" to "john-password" "name" to "John" - "internal_payto_uri" to genTmpPayTo() + "payto_uri" to genTmpPayTo() } }.assertOk() fillTanInfo("john") @@ -661,7 +661,7 @@ class CoreBankAccountsApiTest { val obj = json<PublicAccountsResponse>() assertEquals(3, obj.public_accounts.size) obj.public_accounts.forEach { - assertEquals(0, it.account_name.toInt() % 2) + assertEquals(0, it.username.toInt() % 2) } } // All accounts @@ -940,11 +940,7 @@ class CoreBankWithdrawalApiTest { client.get("/withdrawals/${it.withdrawal_id}") { pwAuth("merchant") }.assertOkJson<WithdrawalPublicInfo> { - assert(!it.selection_done) - assert(!it.aborted) - assert(!it.confirmation_done) assertEquals(amount, it.amount) - // TODO check all status } } @@ -993,7 +989,7 @@ class CoreBankWithdrawalApiTest { }.assertOkJson<BankAccountCreateWithdrawalResponse> { val uuid = it.taler_withdraw_uri.split("/").last() withdrawalSelect(uuid) - client.postA("/accounts/merchant/withdrawals/$uuid/abort").assertNoContent() + client.postA("/taler-integration/withdrawal-operation/$uuid/abort").assertNoContent() // Check error client.postA("/accounts/merchant/withdrawals/$uuid/confirm") @@ -1013,7 +1009,7 @@ class CoreBankWithdrawalApiTest { .assertConflict(TalerErrorCode.BANK_UNALLOWED_DEBIT) // Check can abort because not confirmed - client.postA("/accounts/merchant/withdrawals/$uuid/abort").assertNoContent() + client.postA("/taler-integration/withdrawal-operation/$uuid/abort").assertNoContent() } // Check bad UUID diff --git a/bank/src/test/kotlin/helpers.kt b/bank/src/test/kotlin/helpers.kt @@ -258,7 +258,7 @@ suspend fun ApplicationTestBuilder.withdrawal(amount: String) { }.assertOkJson<BankAccountCreateWithdrawalResponse> { val uuid = it.taler_withdraw_uri.split("/").last() withdrawalSelect(uuid) - client.postA("/withdrawals/${uuid}/confirm") + client.postA("/accounts/merchant/withdrawals/${uuid}/confirm") .assertNoContent() } } diff --git a/bank/src/test/kotlin/routines.kt b/bank/src/test/kotlin/routines.kt @@ -256,7 +256,7 @@ inline suspend fun <reified B> ApplicationTestBuilder.statusRoutine( } } delay(100) - client.post("/withdrawals/$confirmed_uuid/confirm").assertNoContent() + client.postA("/accounts/customer/withdrawals/$confirmed_uuid/confirm").assertNoContent() } // Polling abort @@ -274,7 +274,7 @@ inline suspend fun <reified B> ApplicationTestBuilder.statusRoutine( } } delay(100) - client.post("/withdrawals/$aborted_uuid/abort").assertNoContent() + client.post("/taler-integration/withdrawal-operation/$aborted_uuid/abort").assertNoContent() } } } \ No newline at end of file