]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6784 Remove RoR WS from Permissions declaration
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 6 Oct 2015 06:20:28 +0000 (08:20 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 6 Oct 2015 06:20:28 +0000 (08:20 +0200)
server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java

index 932740d47482fd0f8c44b66b7fadb25fa5b01210..a106538f562f4e9897bbfe56a38958f120b3ed4c 100644 (file)
 
 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.<String>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.<String>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);
-  }
-
 }
index f8e8932e28c5b539add225ac970f1d45a0a991a7..05d459db6d6c760c7975cd32fe55630a5b47e85c 100644 (file)
@@ -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