gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/05: /history/incoming: no negative start param.


From: gnunet
Subject: [libeufin] 01/05: /history/incoming: no negative start param.
Date: Mon, 13 Mar 2023 10:25:12 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit c094c812a75d373791ceb228d073b90ea2415f90
Author: MS <ms@taler.net>
AuthorDate: Sat Mar 11 21:36:29 2023 +0100

    /history/incoming: no negative start param.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt              | 7 +++++--
 nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 2 +-
 nexus/src/test/kotlin/TalerTest.kt                              | 3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index c9e73662..dc545201 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -131,11 +131,14 @@ fun getComparisonOperator(delta: Int, start: Long, table: 
IdTable<Long>): Op<Boo
     }
 }
 
-fun expectLong(param: String?): Long {
+fun expectLong(param: String?, allowNegative: Boolean = false): Long {
     if (param == null) throw badRequest("'$param' is not Long")
-    return try { param.toLong() } catch (e: Exception) {
+    val maybeLong = try { param.toLong() } catch (e: Exception) {
         throw badRequest("'$param' is not Long")
     }
+    if (!allowNegative && maybeLong < 0)
+        throw badRequest("Not expecting a negative: $param")
+    return maybeLong
 }
 
 // Helper handling 'start' being optional and its dependence on 'delta'.
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 2632100f..12b0dd26 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -190,7 +190,7 @@ val nexusApp: Application.() -> Unit = {
             )
         }
         exception<UtilError> { call, cause ->
-            logger.error("Exception while handling '${call.request.uri}'", 
cause.message)
+            logger.error("Exception while handling '${call.request.uri}': 
${cause.message}")
             call.respond(
                 cause.statusCode,
                 message = ErrorResponse(
diff --git a/nexus/src/test/kotlin/TalerTest.kt 
b/nexus/src/test/kotlin/TalerTest.kt
index 7eadeb25..7dce7a25 100644
--- a/nexus/src/test/kotlin/TalerTest.kt
+++ b/nexus/src/test/kotlin/TalerTest.kt
@@ -32,11 +32,12 @@ class TalerTest {
                 application(nexusApp)
                 runBlocking {
                     launch {
-                        val r = 
client.get("/facades/taler/taler-wire-gateway/history/incoming?delta=5") {
+                        val r = 
client.get("/facades/taler/taler-wire-gateway/history/incoming?delta=5&start=3")
 {
                             expectSuccess = false
                             contentType(ContentType.Application.Json)
                             basicAuth("foo", "foo")
                         }
+                        assert(r.status.value == HttpStatusCode.OK.value)
                         val j = mapper.readTree(r.readBytes())
                         val reservePubFromTwg = 
j.get("incoming_transactions").get(0).get("reserve_pub").asText()
                         assert(reservePubFromTwg == reservePub)

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