]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7515 api/system/info is now internal
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 29 Apr 2016 14:58:10 +0000 (16:58 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 3 May 2016 11:56:30 +0000 (13:56 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/ws/InfoAction.java
server/sonar-server/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java

index acff7359c11405c93751fb266f0f959600973a80..ff9ad2433c8c4d72d071a0d0f1ceac264b2011e5 100644 (file)
@@ -50,10 +50,11 @@ public class InfoAction implements SystemWsAction {
   @Override
   public void define(WebService.NewController controller) {
     controller.createAction("info")
-      .setDescription("Detailed information about system configuration." +
-        "<br/>" +
-        "Requires user to be authenticated with Administer System permissions.")
+      .setDescription("Detailed information about system configuration.<br/>" +
+        "Requires 'Administer' permissions.<br/>" +
+        "Since 5.5, this web service becomes internal in order to more easily update result.")
       .setSince("5.1")
+      .setInternal(true)
       .setResponseExample(getClass().getResource("/org/sonar/server/platform/ws/example-system-info.json"))
       .setHandler(this);
   }
index c4a61be4f8054dc98b184247439494c6a21be6cf..6744c4b75689d23559f271e7a9a85c9ed9172736 100644 (file)
@@ -24,15 +24,13 @@ import java.util.Map;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.internal.SimpleGetRequest;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.platform.monitoring.Monitor;
 import org.sonar.server.platform.monitoring.ProcessSystemInfoClient;
 import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.WsTester;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -46,13 +44,22 @@ public class InfoActionTest {
   Monitor monitor1 = mock(Monitor.class);
   Monitor monitor2 = mock(Monitor.class);
   ProcessSystemInfoClient processSystemInfoClient = mock(ProcessSystemInfoClient.class, Mockito.RETURNS_MOCKS);
-  InfoAction underTest = new InfoAction(userSessionRule, processSystemInfoClient, monitor1, monitor2);
+
+  WsActionTester ws = new WsActionTester(new InfoAction(userSessionRule, processSystemInfoClient, monitor1, monitor2));
+
+  @Test
+  public void test_definition() throws Exception {
+    assertThat(ws.getDef().key()).isEqualTo("info");
+    assertThat(ws.getDef().isInternal()).isTrue();
+    assertThat(ws.getDef().responseExampleAsString()).isNotEmpty();
+    assertThat(ws.getDef().params()).isEmpty();
+  }
 
   @Test(expected = ForbiddenException.class)
   public void should_fail_when_does_not_have_admin_right() {
     userSessionRule.setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION);
 
-    underTest.handle(mock(Request.class), mock(Response.class));
+    ws.newRequest().execute();
   }
 
   @Test
@@ -69,9 +76,8 @@ public class InfoActionTest {
     when(monitor2.name()).thenReturn("Monitor Two");
     when(monitor2.attributes()).thenReturn(attributes2);
 
-    WsTester.TestResponse response = new WsTester.TestResponse();
-    underTest.handle(new SimpleGetRequest(), response);
+    TestResponse response = ws.newRequest().execute();
     // response does not contain empty "Monitor Three"
-    assertThat(response.outputAsString()).isEqualTo("{\"Monitor One\":{\"foo\":\"bar\"},\"Monitor Two\":{\"one\":1,\"two\":2}}");
+    assertThat(response.getInput()).isEqualTo("{\"Monitor One\":{\"foo\":\"bar\"},\"Monitor Two\":{\"one\":1,\"two\":2}}");
   }
 }