Merge "Fix failing tests"
diff --git a/java/com/google/gerrit/plugins/checks/api/RerunCheck.java b/java/com/google/gerrit/plugins/checks/api/RerunCheck.java
index 4c6b0a4..023e302 100644
--- a/java/com/google/gerrit/plugins/checks/api/RerunCheck.java
+++ b/java/com/google/gerrit/plugins/checks/api/RerunCheck.java
@@ -21,7 +21,6 @@
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView;
-import com.google.gerrit.plugins.checks.AdministrateCheckersPermission;
import com.google.gerrit.plugins.checks.Check;
import com.google.gerrit.plugins.checks.CheckJson;
import com.google.gerrit.plugins.checks.CheckKey;
@@ -34,7 +33,6 @@
import com.google.gerrit.plugins.checks.ChecksUpdate;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.UserInitiated;
-import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -46,8 +44,6 @@
@Singleton
public class RerunCheck implements RestModifyView<CheckResource, Input> {
private final Provider<CurrentUser> self;
- private final PermissionBackend permissionBackend;
- private final AdministrateCheckersPermission permission;
private final Checks checks;
private final Provider<ChecksUpdate> checksUpdate;
private final CheckJson.Factory checkJsonFactory;
@@ -56,15 +52,11 @@
@Inject
RerunCheck(
Provider<CurrentUser> self,
- PermissionBackend permissionBackend,
- AdministrateCheckersPermission permission,
Checks checks,
@UserInitiated Provider<ChecksUpdate> checksUpdate,
CheckJson.Factory checkJsonFactory,
Checkers checkers) {
this.self = self;
- this.permissionBackend = permissionBackend;
- this.permission = permission;
this.checks = checks;
this.checksUpdate = checksUpdate;
this.checkJsonFactory = checkJsonFactory;
@@ -77,7 +69,6 @@
if (!self.get().isIdentifiedUser()) {
throw new AuthException("Authentication required");
}
- permissionBackend.currentUser().check(permission);
if (checkResource.getRevisionResource().getEdit().isPresent()) {
throw new ResourceConflictException("checks are not supported on a change edit");
}
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/RerunCheckIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/RerunCheckIT.java
index 9cc539f..4084607 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/RerunCheckIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/RerunCheckIT.java
@@ -125,18 +125,6 @@
}
@Test
- public void cannotUpdateCheckWithoutAdministrateCheckers() throws Exception {
- requestScopeOperations.setApiUser(user.id());
- checkOperations.newCheck(checkKey).state(CheckState.SUCCESSFUL).upsert();
-
- AuthException thrown =
- assertThrows(
- AuthException.class,
- () -> checksApiFactory.revision(patchSetId).id(checkKey.checkerUuid()).rerun());
- assertThat(thrown).hasMessageThat().contains("not permitted");
- }
-
- @Test
public void cannotUpdateCheckAnonymously() throws Exception {
requestScopeOperations.setApiUserAnonymous();
checkOperations.newCheck(checkKey).state(CheckState.SUCCESSFUL).upsert();
@@ -147,4 +135,12 @@
() -> checksApiFactory.revision(patchSetId).id(checkKey.checkerUuid()).rerun());
assertThat(thrown).hasMessageThat().contains("Authentication required");
}
+
+ @Test
+ public void canRerunWithoutPermissions() throws Exception {
+ requestScopeOperations.setApiUser(user.id());
+ checkOperations.newCheck(checkKey).state(CheckState.SUCCESSFUL).upsert();
+ CheckInfo info = checksApiFactory.revision(patchSetId).id(checkKey.checkerUuid()).rerun();
+ assertThat(info.state).isEqualTo(CheckState.NOT_STARTED);
+ }
}