carloea2 commented on code in PR #8146:
URL: https://github.com/apache/texera/pull/8146#discussion_r3906726682


##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala:
##########
@@ -91,6 +91,10 @@ object DashboardResource {
       @BeanParam params: SearchQueryParams,
       includePublic: Boolean = false
   ): DashboardSearchResult = {
+    if (params.offset < 0 || params.count < 0 || params.count == Int.MaxValue)

Review Comment:
   Defined the lookahead and maximum count once, then used them in the guard, 
message, documentation, and query limit.



##########
amber/src/test/scala/org/apache/texera/web/resource/dashboard/DashboardResourceSpec.scala:
##########
@@ -121,9 +132,30 @@ class DashboardResourceSpec extends AnyFlatSpec with 
Matchers {
   // every one of them maps to a non-null Field, so getColumnField never
   // returns None.
 
-  // -- searchAllResources: the dispatch guard --------------------------------
+  // -- searchAllResources: pagination and dispatch guards --------------------
+
+  "searchAllResources" should "reject a negative start" in {
+    assertInvalidPagination(SearchQueryParams(offset = -1))
+  }
+
+  it should "reject a negative count" in {
+    assertInvalidPagination(SearchQueryParams(count = -1))
+  }
+
+  it should "reject a count that overflows the query limit" in {

Review Comment:
   Added the largest valid count case using MaxSearchCount.



##########
amber/src/test/scala/org/apache/texera/web/resource/dashboard/DashboardResourceSpec.scala:
##########
@@ -121,9 +132,30 @@ class DashboardResourceSpec extends AnyFlatSpec with 
Matchers {
   // every one of them maps to a non-null Field, so getColumnField never
   // returns None.
 
-  // -- searchAllResources: the dispatch guard --------------------------------
+  // -- searchAllResources: pagination and dispatch guards --------------------
+
+  "searchAllResources" should "reject a negative start" in {
+    assertInvalidPagination(SearchQueryParams(offset = -1))
+  }
+
+  it should "reject a negative count" in {
+    assertInvalidPagination(SearchQueryParams(count = -1))
+  }
+
+  it should "reject a count that overflows the query limit" in {
+    assertInvalidPagination(SearchQueryParams(count = Int.MaxValue))
+  }
+
+  it should "allow zero pagination values" in {

Review Comment:
   Added the dispatch comment so the assertion path is explicit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to