gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 04/09: testing the previous change


From: gnunet
Subject: [libeufin] 04/09: testing the previous change
Date: Fri, 20 Jan 2023 16:49:38 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 907eb293905ff709afc9229c13249b8b199f653a
Author: MS <ms@taler.net>
AuthorDate: Fri Jan 20 14:52:53 2023 +0100

    testing the previous change
---
 nexus/src/test/kotlin/DownloadAndSubmit.kt     |  6 ---
 nexus/src/test/kotlin/JsonTest.kt              |  3 +-
 nexus/src/test/kotlin/MakeEnv.kt               |  7 +++
 nexus/src/test/kotlin/SandboxCircuitApiTest.kt | 69 +++++++++++++++++++++++++-
 4 files changed, 77 insertions(+), 8 deletions(-)

diff --git a/nexus/src/test/kotlin/DownloadAndSubmit.kt 
b/nexus/src/test/kotlin/DownloadAndSubmit.kt
index 928df051..0ac5b0c7 100644
--- a/nexus/src/test/kotlin/DownloadAndSubmit.kt
+++ b/nexus/src/test/kotlin/DownloadAndSubmit.kt
@@ -10,7 +10,6 @@ import io.ktor.server.routing.*
 import io.ktor.server.testing.*
 import kotlinx.coroutines.runBlocking
 import org.jetbrains.exposed.sql.transactions.transaction
-import org.junit.Ignore
 import org.junit.Test
 import org.w3c.dom.Document
 import tech.libeufin.nexus.*
@@ -87,11 +86,6 @@ fun getCustomEbicsServer(r: EbicsResponses, endpoint: String 
= "/ebicsweb"): App
     return ret
 }
 
-/**
- * Remove @Ignore, after having put asserts along tests,
- * and having had access to runTask and TaskSchedule, that
- * are now 'private'.
- */
 class DownloadAndSubmit {
     /**
      * Download a C52 report from the bank.
diff --git a/nexus/src/test/kotlin/JsonTest.kt 
b/nexus/src/test/kotlin/JsonTest.kt
index a1024f85..138790cb 100644
--- a/nexus/src/test/kotlin/JsonTest.kt
+++ b/nexus/src/test/kotlin/JsonTest.kt
@@ -42,7 +42,8 @@ class JsonTest {
 
     /**
      * Ignored because this test was only used to check
-     * the logs, as opposed to assert over values.
+     * the logs, as opposed to assert over values.  Consider
+     * to remove the Ignore
      */
     @Ignore
     @Test
diff --git a/nexus/src/test/kotlin/MakeEnv.kt b/nexus/src/test/kotlin/MakeEnv.kt
index 40da1d81..bb25a0b6 100644
--- a/nexus/src/test/kotlin/MakeEnv.kt
+++ b/nexus/src/test/kotlin/MakeEnv.kt
@@ -197,12 +197,19 @@ fun prepSandboxDb() {
             username = "foo"
             passwordHash = CryptoUtil.hashpw("foo")
             name = "Foo"
+            cashout_address = "payto://iban/OUTSIDE"
         }
         DemobankCustomerEntity.new {
             username = "bar"
             passwordHash = CryptoUtil.hashpw("bar")
             name = "Bar"
         }
+        DemobankCustomerEntity.new {
+            username = "baz"
+            passwordHash = CryptoUtil.hashpw("foo")
+            name = "Baz"
+            cashout_address = "payto://iban/OTHERBANK"
+        }
     }
 }
 
diff --git a/nexus/src/test/kotlin/SandboxCircuitApiTest.kt 
b/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
index 916400a1..ce688e2b 100644
--- a/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
+++ b/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
@@ -12,6 +12,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
 import org.junit.Test
 import tech.libeufin.sandbox.*
 import java.io.File
+import java.util.*
 
 class SandboxCircuitApiTest {
     // Get /config, fails if != 200.
@@ -27,6 +28,26 @@ class SandboxCircuitApiTest {
             }
         }
     }
+    // Tests that only account with a cash-out address are returned.
+    @Test
+    fun listAccountsTest() {
+        withTestDatabase {
+            prepSandboxDb()
+            testApplication {
+                application(sandboxApp)
+                var R = client.get("/demobanks/default/circuit-api/accounts") {
+                    expectSuccess = false
+                    basicAuth("admin", "foo")
+                }
+                println(R.bodyAsText())
+                R = client.get("/demobanks/default/circuit-api/accounts/baz") {
+                    expectSuccess = false
+                    basicAuth("admin", "foo")
+                }
+                println(R.bodyAsText())
+            }
+        }
+    }
     @Test
     fun badUuidTest() {
         withTestDatabase {
@@ -60,7 +81,53 @@ class SandboxCircuitApiTest {
         assert(!checkEmailAddress("foo+bar@example.com"))
     }
 
-    // Test the creation and confirmation of a cash-out operation.
+    @Test
+    fun listCashouts() {
+        withTestDatabase {
+            prepSandboxDb()
+            testApplication {
+                application(sandboxApp)
+                var R = client.get("/demobanks/default/circuit-api/cashouts") {
+                    expectSuccess = true
+                    basicAuth("admin", "foo")
+                }
+                assert(R.status.value == HttpStatusCode.NoContent.value)
+                transaction {
+                    CashoutOperationEntity.new {
+                        tan = "unused"
+                        uuid = UUID.randomUUID()
+                        amountDebit = "unused"
+                        amountCredit = "unused"
+                        subject = "unused"
+                        creationTime = 0L
+                        tanChannel = "UNUSED" // change type to enum?
+                        account = "unused"
+                        state = CashoutOperationState.PENDING
+                    }
+                }
+                R = client.get("/demobanks/default/circuit-api/cashouts") {
+                    expectSuccess = true
+                    basicAuth("admin", "foo")
+                }
+                assert(R.status.value == HttpStatusCode.OK.value)
+                // Extract the UUID and check it.
+                val mapper = ObjectMapper()
+                var respJson = mapper.readTree(R.bodyAsText())
+                val uuid = respJson.get("cashouts").get(0).asText()
+                R = 
client.get("/demobanks/default/circuit-api/cashouts/$uuid") {
+                    expectSuccess = true
+                    basicAuth("admin", "foo")
+                }
+                assert(R.status.value == HttpStatusCode.OK.value)
+                respJson = mapper.readTree(R.bodyAsText())
+                val status = respJson.get("status").asText()
+                assert(status.uppercase() == "PENDING")
+                println(R.bodyAsText())
+            }
+        }
+    }
+
+    // Tests the creation and confirmation of a cash-out operation.
     @Test
     fun cashout() {
         withTestDatabase {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]