libeufin

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

RevenueApiTest.kt (2435B)


      1 /*
      2  * This file is part of LibEuFin.
      3  * Copyright (C) 2024, 2025, 2026 Taler Systems S.A.
      4 
      5  * LibEuFin is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU Affero General Public License as
      7  * published by the Free Software Foundation; either version 3, or
      8  * (at your option) any later version.
      9 
     10  * LibEuFin is distributed in the hope that it will be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General
     13  * Public License for more details.
     14 
     15  * You should have received a copy of the GNU Affero General Public
     16  * License along with LibEuFin; see the file COPYING.  If not, see
     17  * <http://www.gnu.org/licenses/>
     18  */
     19 
     20 import io.ktor.http.*
     21 import io.ktor.client.request.*
     22 import org.junit.Test
     23 import tech.libeufin.common.RevenueIncomingHistory
     24 import tech.libeufin.common.assertNotImplemented
     25 import tech.libeufin.common.assertOk
     26 
     27 class RevenueApiTest {
     28     // GET /taler-revenue/config
     29     @Test
     30     fun config() = serverSetup {
     31         client.get("/taler-revenue/config").assertOk()
     32     }
     33 
     34     // GET /taler-revenue/history
     35     @Test
     36     fun history() = serverSetup { db ->
     37         authRoutine(HttpMethod.Get, "/taler-revenue/history")
     38 
     39         historyRoutine<RevenueIncomingHistory>(
     40             url = "/taler-revenue/history",
     41             ids = { it.incoming_transactions.map { it.row_id } },
     42             registered = listOf(
     43                 // Transactions using clean transfer logic
     44                 { talerableIn(db) },
     45                 { talerableCompletedIn(db) },
     46                 { talerablePreparedIn(db) },
     47                 { talerablePreparedCompletedIn(db) },
     48 
     49                 // Common credit transactions
     50                 { registerIn(db) },
     51                 { registerCompletedIn(db) }
     52             ),
     53             ignored = listOf(
     54                 // Ignore debit transactions
     55                 { talerableOut(db) },
     56 
     57                 // Ignore incomplete
     58                 { registerIncompleteIn(db) },
     59                 { talerableIncompleteIn(db) },
     60                 { talerablePreparedIncompleteIn(db) },
     61             )
     62         )
     63     }
     64 
     65     @Test
     66     fun noApi() = serverSetup("mini.conf") {
     67         client.getA("/taler-revenue/config").assertNotImplemented()
     68     }
     69 
     70     @Test
     71     fun auth() = serverSetup("auth.conf") {
     72         authRoutine(HttpMethod.Get, "/taler-revenue/history")
     73     }
     74 }