gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Test Access API's wire transfer.


From: gnunet
Subject: [libeufin] branch master updated: Test Access API's wire transfer.
Date: Sat, 07 Jan 2023 09:42:04 +0100

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

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 5ba09a22 Test Access API's wire transfer.
5ba09a22 is described below

commit 5ba09a22bc3d943d421e448639cbf41f58b9577b
Author: MS <ms@taler.net>
AuthorDate: Sat Jan 7 09:40:58 2023 +0100

    Test Access API's wire transfer.
---
 nexus/src/test/kotlin/MakeEnv.kt              |  5 +++
 nexus/src/test/kotlin/SandboxAccessApiTest.kt | 50 +++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/nexus/src/test/kotlin/MakeEnv.kt b/nexus/src/test/kotlin/MakeEnv.kt
index dff2c54d..a6e2ce2d 100644
--- a/nexus/src/test/kotlin/MakeEnv.kt
+++ b/nexus/src/test/kotlin/MakeEnv.kt
@@ -180,6 +180,11 @@ fun prepSandboxDb() {
             passwordHash = CryptoUtil.hashpw("foo")
             name = "Foo"
         }
+        DemobankCustomerEntity.new {
+            username = "bar"
+            passwordHash = CryptoUtil.hashpw("bar")
+            name = "Bar"
+        }
     }
 }
 
diff --git a/nexus/src/test/kotlin/SandboxAccessApiTest.kt 
b/nexus/src/test/kotlin/SandboxAccessApiTest.kt
index 028c41d1..bd86734d 100644
--- a/nexus/src/test/kotlin/SandboxAccessApiTest.kt
+++ b/nexus/src/test/kotlin/SandboxAccessApiTest.kt
@@ -10,6 +10,56 @@ import tech.libeufin.sandbox.*
 
 class SandboxAccessApiTest {
     val mapper = ObjectMapper()
+
+    // Move funds between accounts.
+    @Test
+    fun wireTransfer() {
+        withTestDatabase {
+            prepSandboxDb()
+            testApplication {
+                application(sandboxApp)
+                runBlocking {
+                    // Foo gives 20 to Bar
+                    
client.post("/demobanks/default/access-api/accounts/foo/transactions") {
+                        expectSuccess = true
+                        contentType(ContentType.Application.Json)
+                        basicAuth("foo", "foo")
+                        setBody("""{
+                            "paytoUri": 
"payto://iban/${BAR_USER_IBAN}?message=test",
+                            "amount": "TESTKUDOS:20"
+                        }""".trimIndent()
+                        )
+                    }
+                    // Foo checks its balance: -20
+                    var R = 
client.get("/demobanks/default/access-api/accounts/foo") {
+                        basicAuth("foo", "foo")
+                    }
+                    val mapper = ObjectMapper()
+                    var j = mapper.readTree(R.readBytes())
+                    assert(j.get("balance").get("amount").asText() == 
"TESTKUDOS:20")
+                    
assert(j.get("balance").get("credit_debit_indicator").asText().lowercase() == 
"debit")
+                    // Bar checks its balance: 20
+                    R = 
client.get("/demobanks/default/access-api/accounts/bar") {
+                        basicAuth("bar", "bar")
+                    }
+                    j = mapper.readTree(R.readBytes())
+                    assert(j.get("balance").get("amount").asText() == 
"TESTKUDOS:20")
+                    
assert(j.get("balance").get("credit_debit_indicator").asText().lowercase() == 
"credit")
+                    // Foo tries with an invalid amount
+                    R = 
client.post("/demobanks/default/access-api/accounts/foo/transactions") {
+                        contentType(ContentType.Application.Json)
+                        basicAuth("foo", "foo")
+                        setBody("""{
+                            "paytoUri": 
"payto://iban/${BAR_USER_IBAN}?message=test",
+                            "amount": "TESTKUDOS:20.001"
+                        }""".trimIndent()
+                        )
+                    }
+                    assert(R.status.value == HttpStatusCode.BadRequest.value)
+                }
+            }
+        }
+    }
     // Check successful and failing case due to insufficient funds.
     @Test
     fun debitWithdraw() {

-- 
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]