summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2022-03-17 16:21:41 +0000
committerLuca Milanesio <luca.milanesio@gmail.com>2022-03-17 16:21:49 +0000
commitd144dbd612d3133f42743f5826e635f42c23de2f (patch)
treece55b813821333140d32dd18665ab8aaa0725f56
parentaf9d0136709830fe4af735a4980d1e729660907d (diff)
parenta94fad0841b4dab7bf405711c6f9e813eff64220 (diff)
Merge branch 'stable-3.3' into stable-3.4
* stable-3.3: Set version to 3.3.11-SNAPSHOT Set version to 3.3.10 Ignore '--no-limit' query changes option for anonymous users Release-Notes: skip Change-Id: I323b6708075bbe54624d72f39a5a3e39fb0856f4
-rw-r--r--Documentation/rest-api-changes.txt4
-rw-r--r--java/com/google/gerrit/server/restapi/change/QueryChanges.java7
-rw-r--r--javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java22
3 files changed, 28 insertions, 5 deletions
diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt
index cd80d3dd4b..8da7a9da2c 100644
--- a/Documentation/rest-api-changes.txt
+++ b/Documentation/rest-api-changes.txt
@@ -77,8 +77,8 @@ Queries changes visible to the caller. The
link:user-search.html#_search_operators[query string] must be provided
by the `q` parameter. The `n` parameter can be used to limit the
returned results. The `no-limit` parameter can be used remove the default
-limit on queries and return all results. This might not be supported by
-all index backends.
+limit on queries and return all results (does not apply to anonymous requests).
+This might not be supported by all index backends.
As result a list of link:#change-info[ChangeInfo] entries is returned.
The change output is sorted by the last update time, most recently
diff --git a/java/com/google/gerrit/server/restapi/change/QueryChanges.java b/java/com/google/gerrit/server/restapi/change/QueryChanges.java
index cf0d4cfcc3..cbbaa5251d 100644
--- a/java/com/google/gerrit/server/restapi/change/QueryChanges.java
+++ b/java/com/google/gerrit/server/restapi/change/QueryChanges.java
@@ -27,6 +27,7 @@ import com.google.gerrit.extensions.restapi.TopLevelResource;
import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.index.query.QueryRequiresAuthException;
import com.google.gerrit.index.query.QueryResult;
+import com.google.gerrit.server.AnonymousUser;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.DynamicOptions;
import com.google.gerrit.server.change.ChangeJson;
@@ -95,7 +96,9 @@ public class QueryChanges implements RestReadView<TopLevelResource>, DynamicOpti
this.start = start;
}
- @Option(name = "--no-limit", usage = "Return all results, overriding the default limit")
+ @Option(
+ name = "--no-limit",
+ usage = "Return all results, overriding the default limit. Ignored for anonymous users.")
public void setNoLimit(boolean on) {
this.noLimit = on;
}
@@ -168,7 +171,7 @@ public class QueryChanges implements RestReadView<TopLevelResource>, DynamicOpti
if (start != null) {
queryProcessor.setStart(start);
}
- if (noLimit != null) {
+ if (noLimit != null && !AnonymousUser.class.isAssignableFrom(userProvider.get().getClass())) {
queryProcessor.setNoLimit(noLimit);
}
if (skipVisibility != null) {
diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
index a1668ef4a1..a4f91d700a 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
@@ -2786,7 +2786,7 @@ public class ChangeIT extends AbstractDaemonTest {
}
@Test
- public void queryChangesNoLimit() throws Exception {
+ public void queryChangesNoLimitRegisteredUser() throws Exception {
projectOperations
.allProjectsForUpdate()
.add(
@@ -2804,6 +2804,26 @@ public class ChangeIT extends AbstractDaemonTest {
}
@Test
+ public void queryChangesNoLimitIgnoredForAnonymousUser() throws Exception {
+ int limit = 2;
+ projectOperations
+ .allProjectsForUpdate()
+ .add(
+ allowCapability(GlobalCapability.QUERY_LIMIT)
+ .group(SystemGroupBackend.ANONYMOUS_USERS)
+ .range(0, limit))
+ .update();
+ for (int i = 0; i < 3; i++) {
+ createChange();
+ }
+ requestScopeOperations.setApiUserAnonymous();
+ List<ChangeInfo> resultsWithDefaultLimit = gApi.changes().query().get();
+ List<ChangeInfo> resultsWithNoLimit = gApi.changes().query().withNoLimit().get();
+ assertThat(resultsWithDefaultLimit).hasSize(limit);
+ assertThat(resultsWithNoLimit).hasSize(limit);
+ }
+
+ @Test
public void queryChangesStart() throws Exception {
PushOneCommit.Result r1 = createChange();
createChange();