commit 907eb293905ff709afc9229c13249b8b199f653a
parent b28f1511dab120ef2bfeef39801a0058c543138b
Author: MS <ms@taler.net>
Date: Fri, 20 Jan 2023 14:52:53 +0100
testing the previous change
Diffstat:
4 files changed, 77 insertions(+), 8 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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 {