diff options
2 files changed, 4 insertions, 9 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ReindexAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ReindexAction.java index 2d2a2618528..fc3b35c86f9 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ReindexAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ReindexAction.java @@ -22,7 +22,6 @@ package org.sonar.server.issue.ws; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.project.ProjectDto; @@ -55,11 +54,7 @@ public class ReindexAction implements IssuesWsAction { .createAction(ACTION) .setPost(true) .setDescription("Reindex issues for a project.<br> " + - "Requires one of the following permissions: " + - "<ul>" + - "<li>'Administer System'</li>" + - "<li>'Administer' rights on the specified project</li>" + - "</ul>") + "Require 'Administer System' permission.") .setSince("9.8") .setHandler(this); @@ -72,12 +67,12 @@ public class ReindexAction implements IssuesWsAction { @Override public void handle(Request request, Response response) throws Exception { - String projectKey = request.mandatoryParam(PARAM_PROJECT); + userSession.checkIsSystemAdministrator(); + String projectKey = request.mandatoryParam(PARAM_PROJECT); ProjectDto projectDto; try (DbSession dbSession = dbClient.openSession(false)) { projectDto = dbClient.projectDao().selectProjectByKey(dbSession, projectKey).orElseThrow(() -> new NotFoundException("project not found")); - userSession.checkProjectPermission(UserRole.ADMIN, projectDto); } issueIndexer.indexProject(projectDto.getUuid()); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ReindexActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ReindexActionTest.java index fb18d387348..00fa5b1046e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ReindexActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ReindexActionTest.java @@ -92,7 +92,7 @@ public class ReindexActionTest { @Test public void fail_if_parameter_not_present() { - userSession.anonymous(); + userSession.logIn().setSystemAdministrator(); TestRequest testRequest = tester.newRequest(); assertThatThrownBy(testRequest::execute) .isInstanceOf(IllegalArgumentException.class) |