From: Teryk Bellahsene Date: Tue, 6 Oct 2015 06:20:28 +0000 (+0200) Subject: SONAR-6784 Remove RoR WS from Permissions declaration X-Git-Tag: 5.2-RC1~57 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=93a3a34b9f09111b4f0d845dab4b1e6de6cd87f4;p=sonarqube.git SONAR-6784 Remove RoR WS from Permissions declaration --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java index 932740d4748..a106538f562 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java @@ -20,12 +20,7 @@ package org.sonar.server.permission.ws; -import com.google.common.collect.ImmutableSet; -import org.sonar.api.security.DefaultGroups; -import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.WebService; -import org.sonar.core.permission.GlobalPermissions; -import org.sonar.core.permission.ProjectPermissions; public class PermissionsWs implements WebService { @@ -47,59 +42,6 @@ public class PermissionsWs implements WebService { action.define(controller); } - defineAddAction(controller); - defineRemoveAction(controller); - controller.done(); } - - private static void defineAddAction(NewController controller) { - NewAction action = controller.createAction("add") - .setDescription("Add a global or a project permission. Requires Administer System permission for global permissions, " + - "requires Administer permission on project for project permissions") - .setSince("3.7") - .setPost(true) - .setHandler(RailsHandler.INSTANCE); - action.createParam("permission") - .setDescription("Key of the permission to add") - .setRequired(true) - .setPossibleValues(ImmutableSet.builder().addAll(GlobalPermissions.ALL).addAll(ProjectPermissions.ALL).build()) - .setExampleValue("shareDashboard"); - action.createParam("user") - .setDescription("User login. Required if group is not set") - .setExampleValue("myuser"); - action.createParam("group") - .setDescription("Group name or \"" + DefaultGroups.ANYONE + "\". Required if user is not set") - .setExampleValue(DefaultGroups.ADMINISTRATORS); - action.createParam("component") - .setDescription("Key of the project. Required if a project permission is set. Available since version 4.0") - .setExampleValue("org.codehaus.sonar"); - RailsHandler.addFormatParam(action); - } - - private static void defineRemoveAction(NewController controller) { - NewAction action = controller.createAction("remove") - .setDescription("Remove a global or a project permission. Requires Administer System permission for global permissions, " + - "requires Administer permission on project for project permissions") - .setSince("3.7") - .setPost(true) - .setHandler(RailsHandler.INSTANCE); - - action.createParam("permission") - .setDescription("Key of the permission to remove") - .setRequired(true) - .setPossibleValues(ImmutableSet.builder().addAll(GlobalPermissions.ALL).addAll(ProjectPermissions.ALL).build()) - .setExampleValue("shareDashboard"); - action.createParam("user") - .setDescription("User login. Required if group is not set") - .setExampleValue("myuser"); - action.createParam("group") - .setDescription("Group name or \"" + DefaultGroups.ANYONE + "\". Required if user is not set") - .setExampleValue(DefaultGroups.ADMINISTRATORS); - action.createParam("component") - .setDescription("Key of the project. Required if a project permission is set. Available since version 4.0") - .setExampleValue("org.codehaus.sonar"); - RailsHandler.addFormatParam(action); - } - } diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java index f8e8932e28c..05d459db6d6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java @@ -22,7 +22,6 @@ package org.sonar.server.permission.ws; import org.junit.Before; import org.junit.Test; -import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbClient; import org.sonar.server.user.UserSession; @@ -53,27 +52,7 @@ public class PermissionsWsTest { assertThat(controller).isNotNull(); assertThat(controller.description()).isNotEmpty(); assertThat(controller.since()).isEqualTo("3.7"); - assertThat(controller.actions()).hasSize(4); - } - - @Test - public void define_add_action() { - WebService.Action action = controller().action("add"); - assertThat(action).isNotNull(); - assertThat(action.handler()).isInstanceOf(RailsHandler.INSTANCE.getClass()); - assertThat(action.params()).hasSize(5); - - WebService.Param permission = action.param("permission"); - assertThat(permission).isNotNull(); - assertThat(permission.possibleValues()).hasSize(9); - } - - @Test - public void define_remove_action() { - WebService.Action action = controller().action("remove"); - assertThat(action).isNotNull(); - assertThat(action.handler()).isInstanceOf(RailsHandler.INSTANCE.getClass()); - assertThat(action.params()).hasSize(5); + assertThat(controller.actions()).hasSize(2); } @Test