commit 79b3ce63052d8e5c87dd9abf78af780aff7c0707
parent 973ec3de5e78fa670f76a0d57f32ca1a1bbe8122
Author: ms <ms@taler.net>
Date: Fri, 17 Mar 2023 22:26:22 +0100
Scheduled tasks test case.
Diffstat:
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -738,9 +738,9 @@ val nexusApp: Application.() -> Unit = {
*/
if (ingestionResult.errors != null)
/**
- * 500 is intentionally generic, because multiple errors
- * may suggest different statuses. The response body however
- * informs the client about what failed.
+ * Nexus could not handle the error (regardless of it being generated
+ * here or gotten from the bank). The response body should inform the
+ * client about what failed.
*/
statusCode = HttpStatusCode.InternalServerError
call.respond(
diff --git a/nexus/src/test/kotlin/NexusApiTest.kt b/nexus/src/test/kotlin/NexusApiTest.kt
@@ -0,0 +1,38 @@
+import io.ktor.client.plugins.*
+import io.ktor.client.request.*
+import io.ktor.http.*
+import io.ktor.server.testing.*
+import org.junit.Test
+import tech.libeufin.nexus.server.nexusApp
+
+/**
+ * This class tests the API offered by Nexus,
+ * documented here: https://docs.taler.net/libeufin/api-nexus.html
+ */
+class NexusApiTest {
+
+ // Testing the creation of scheduled tasks.
+ @Test
+ fun schedule() {
+ withTestDatabase {
+ prepNexusDb()
+ testApplication {
+ application(nexusApp)
+ // POSTing omitted 'params', to test whether Nexus
+ // expects it as 'null' for a 'submit' task.
+ client.post("/bank-accounts/foo/schedule") {
+ contentType(ContentType.Application.Json)
+ expectSuccess = true
+ basicAuth("foo", "foo")
+ // NOTE: current API doesn't allow to omit the 'params' field.
+ setBody("""{
+ "name": "send-payments",
+ "cronspec": "* * *",
+ "type": "submit",
+ "params": null
+ }""".trimIndent())
+ }
+ }
+ }
+ }
+}
+\ No newline at end of file