]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7266 Project admin can manage project permissions
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 3 Feb 2016 15:40:08 +0000 (16:40 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 3 Feb 2016 15:43:32 +0000 (16:43 +0100)
server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java

index f0147087cf5d0669b15bcb7568f440f49a364a5e..1c182c9faa63dddeca6f0536d858227e18cb1659 100644 (file)
@@ -38,7 +38,6 @@ import org.sonarqube.ws.WsPermissions.SearchTemplatesWsResponse.TemplateIdQualif
 import org.sonarqube.ws.client.permission.SearchTemplatesWsRequest;
 
 import static org.sonar.api.utils.DateUtils.formatDateTime;
-import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
 public class SearchTemplatesAction implements PermissionsWsAction {
@@ -61,7 +60,7 @@ public class SearchTemplatesAction implements PermissionsWsAction {
   public void define(WebService.NewController context) {
     context.createAction("search_templates")
       .setDescription("List permission templates.<br />" +
-        "It requires administration permissions to access.")
+        "It requires to be authenticated.")
       .setResponseExample(getClass().getResource("search_templates-example.json"))
       .setSince("5.2")
       .addSearchQuery("defau", "permission template names")
@@ -70,7 +69,7 @@ public class SearchTemplatesAction implements PermissionsWsAction {
 
   @Override
   public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    checkGlobalAdminUser(userSession);
+    userSession.checkLoggedIn();
 
     SearchTemplatesWsResponse searchTemplatesWsResponse = doHandle(toSearchTemplatesWsRequest(wsRequest));
     writeProtobuf(searchTemplatesWsResponse, wsRequest, wsResponse);
index a7e464a533f79d3926bb5a21c21d550ff3853e46..0bad77f9b990f9534e9ea95af8ec998351633d08 100644 (file)
@@ -34,14 +34,12 @@ import org.sonar.api.resources.ResourceType;
 import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
-import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.permission.PermissionTemplateDto;
 import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.UnauthorizedException;
 import org.sonar.server.i18n.I18nRule;
 import org.sonar.server.tester.UserSessionRule;
@@ -53,7 +51,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
-import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN;
 import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
 import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
 import static org.sonar.core.util.Uuids.UUID_EXAMPLE_03;
@@ -99,7 +96,7 @@ public class SearchTemplatesActionTest {
 
     ws = new WsActionTester(underTest);
 
-    userSession.login().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+    userSession.login();
   }
 
   @Test
@@ -174,14 +171,6 @@ public class SearchTemplatesActionTest {
     ws.newRequest().execute();
   }
 
-  @Test
-  public void fail_if_not_global_admin() {
-    expectedException.expect(ForbiddenException.class);
-    userSession.login().setGlobalPermissions(QUALITY_PROFILE_ADMIN);
-
-    ws.newRequest().execute();
-  }
-
   @Test
   public void display_all_project_permissions() {
     String result = newRequest();