libeufin

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

CheckTest.kt (2223B)


      1 /*
      2  * This file is part of LibEuFin.
      3  * Copyright (C) 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 com.github.ajalt.clikt.testing.test
     21 import tech.libeufin.ebisync.cli.LibeufinEbisync
     22 import kotlin.io.path.*
     23 import kotlin.test.Test
     24 import kotlin.test.assertEquals
     25 
     26 class CheckTest {
     27     @Test
     28     fun fetchConditionNeedsNeitherDatabaseNorKeys() {
     29         val config = createTempFile("ebisync-check", ".conf")
     30         try {
     31             for ((destination, expected) in listOf("none" to 1, "azure-blob-storage" to 0)) {
     32                 config.writeText("""
     33                     [ebisync]
     34                     HOST_BASE_URL = http://localhost:1/ebics
     35                     HOST_ID = test
     36                     USER_ID = test
     37                     PARTNER_ID = test
     38                     BANK_PUBLIC_KEYS_FILE = /nonexistent/dd102-bank-keys.json
     39                     CLIENT_PRIVATE_KEYS_FILE = /nonexistent/dd102-client-keys.json
     40                     [ebisyncdb-postgres]
     41                     CONFIG = postgresql://localhost:1/unavailable
     42                     [ebisync-fetch]
     43                     DESTINATION = $destination
     44                     AZURE_API_URL = http://localhost:1/
     45                     AZURE_ACCOUNT_NAME = test
     46                     AZURE_ACCOUNT_KEY = unused
     47                     AZURE_CONTAINER = test
     48                 """.trimIndent())
     49                 val result = LibeufinEbisync().test("fetch -c $config --check")
     50                 assertEquals(expected, result.statusCode, result.output)
     51             }
     52         } finally {
     53             config.deleteIfExists()
     54         }
     55     }
     56 }