]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10285 WS org/enable_support is now only available on SonarCloud
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 22 Mar 2018 16:19:25 +0000 (17:19 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 4 Apr 2018 06:49:17 +0000 (08:49 +0200)
server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java
tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
tests/src/test/java/org/sonarqube/tests/Category6Suite.java
tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java

index dccacc427fd355cadeea9b2741154425850aa0e6..f27020591f87df4e51ad0a136dc0dd2fb2d5dde5 100644 (file)
  */
 package org.sonar.server.organization.ws;
 
+import org.sonar.api.config.Configuration;
 import org.sonar.core.platform.Module;
 
+import static org.sonar.core.config.WebConstants.SONARCLOUD_ENABLED;
+
 public class OrganizationsWsModule extends Module {
 
+  private final Configuration config;
+
+  public OrganizationsWsModule(Configuration config) {
+    this.config = config;
+  }
+
   @Override
   protected void configureModule() {
     add(
       OrganizationsWs.class,
       OrganizationsWsSupport.class,
       // actions
-      AddMemberAction.class,
-      CreateAction.class,
-      DeleteAction.class,
-      EnableSupportAction.class,
-      RemoveMemberAction.class,
       SearchAction.class,
       SearchMembersAction.class,
-      SearchMyOrganizationsAction.class,
-      UpdateAction.class,
-      UpdateProjectVisibilityAction.class);
+      SearchMyOrganizationsAction.class);
+    if (config.getBoolean(SONARCLOUD_ENABLED).orElse(false)) {
+      add(
+        EnableSupportAction.class,
+        AddMemberAction.class,
+        CreateAction.class,
+        DeleteAction.class,
+        RemoveMemberAction.class,
+        UpdateAction.class,
+        UpdateProjectVisibilityAction.class);
+    }
   }
 
 }
index 3ced226dcae798c9f84feed3ccb00f83cfeefeb0..66c96ce204716aba01ce0add9b24bb3c4d039ddd 100644 (file)
 package org.sonar.server.organization.ws;
 
 import org.junit.Test;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.core.platform.ComponentContainer;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
 
 public class OrganizationsWsModuleTest {
-  private OrganizationsWsModule underTest = new OrganizationsWsModule();
+
+  private ComponentContainer container = new ComponentContainer();
+  private MapSettings mapSettings = new MapSettings();
+  private OrganizationsWsModule underTest = new OrganizationsWsModule(mapSettings.asConfig());
+
+  @Test
+  public void verify_component_count_when_not_on_sonar_cloud() {
+    mapSettings.setProperty("sonar.sonarcloud.enabled", false);
+
+    underTest.configure(container);
+
+    assertThat(container.getPicoContainer().getComponentAdapters())
+      .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 5);
+  }
 
   @Test
-  public void verify_component_count() {
-    ComponentContainer container = new ComponentContainer();
+  public void verify_component_count_when_on_sonar_cloud() {
+    mapSettings.setProperty("sonar.sonarcloud.enabled", true);
+
     underTest.configure(container);
+
     assertThat(container.getPicoContainer().getComponentAdapters())
       .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12);
   }
index b85f3a79566f736d8bfc219c320bfcf5a6bc333a..e162bca439818502542963156a4863cfd088a8c0 100644 (file)
@@ -31,12 +31,12 @@ import javax.annotation.Nullable;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.html5.WebStorage;
-import org.sonarqube.pageobjects.measures.MeasuresPage;
-import org.sonarqube.tests.Tester;
 import org.sonarqube.pageobjects.issues.IssuesPage;
+import org.sonarqube.pageobjects.measures.MeasuresPage;
 import org.sonarqube.pageobjects.organization.MembersPage;
 import org.sonarqube.pageobjects.projects.ProjectsPage;
 import org.sonarqube.pageobjects.settings.SettingsPage;
+import org.sonarqube.tests.Tester;
 
 import static com.codeborne.selenide.Condition.visible;
 import static com.codeborne.selenide.Selenide.$;
@@ -59,7 +59,7 @@ public class Navigation {
     clearStorage(d -> d.getLocalStorage().clear());
     clearStorage(d -> d.getSessionStorage().clear());
     clearStorage(d -> clearBrowserLocalStorage());
-    return Selenide.open("/", Navigation.class);
+    return Selenide.open("/projects", Navigation.class);
   }
 
   private static void clearStorage(Consumer<WebStorage> cleaner) {
index 8fc6f4f49b5b4fef7480ac9e80fc02dfb9ed13c5..4fd84037fd535be33076bf2cbd9fe7e832b43cc5 100644 (file)
@@ -26,8 +26,8 @@ import org.junit.ClassRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.sonarqube.tests.authorisation.PermissionTemplateTest;
-import org.sonarqube.tests.issue.IssueNotificationsTest;
 import org.sonarqube.tests.ce.ReportFailureNotificationTest;
+import org.sonarqube.tests.issue.IssueNotificationsTest;
 import org.sonarqube.tests.issue.IssueTagsTest;
 import org.sonarqube.tests.issue.OrganizationIssueAssignTest;
 import org.sonarqube.tests.issue.OrganizationIssuesPageTest;
@@ -110,5 +110,7 @@ public class Category6Suite {
     // reduce memory for Elasticsearch to 128M
     .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
 
+    .setServerProperty("sonar.sonarcloud.enabled", "true")
+
     .build();
 }
index 226c736032feec6222b6e7236fc539718b8c98e9..e2321a43ef3b86c999e360063eb860328e123897 100644 (file)
@@ -68,6 +68,7 @@ public class AnalysisEsResilienceTest {
       .getOrchestratorBuilder()
       .addPlugin(ItUtils.xooPlugin())
       .setServerProperty("sonar.search.httpPort", "" + esHttpPort)
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
       .build();
   }
 
index 683b808fbbed334760636b57320649f71a1ad753..7d382d881588a122795ecff074781359b6d95291 100644 (file)
 package org.sonarqube.tests.issue;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
 import java.util.List;
 import java.util.stream.Collectors;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.pageobjects.issues.IssuesPage;
+import org.sonarqube.tests.Category6Suite;
 import org.sonarqube.tests.Tester;
 import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.Issues.Issue;
@@ -38,7 +39,6 @@ import org.sonarqube.ws.client.issue.BulkChangeRequest;
 import org.sonarqube.ws.client.issue.SearchWsRequest;
 import org.sonarqube.ws.client.project.CreateRequest;
 import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
-import org.sonarqube.pageobjects.issues.IssuesPage;
 import util.issue.IssueRule;
 
 import static java.lang.String.format;
@@ -66,7 +66,7 @@ public class OrganizationIssueAssignTest {
   private User user;
 
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     org1 = tester.organizations().generate();
     org2 = tester.organizations().generate();
     user = tester.users().generate();
index 49be3215f074f8bc6f925a0e7ee44e180873c208..a2d272d3072d0ae64495689d26c8d97de4d61ff1 100644 (file)
@@ -52,6 +52,7 @@ public class ActiveRuleEsResilienceTest {
       .getOrchestratorBuilder()
       .setServerProperty("sonar.search.recovery.delayInMs", "1000")
       .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
       .addPlugin(ItUtils.xooPlugin())
       .build();
   }
index 1414b129683f2de0475440added5d3c23b47c2ba..3189bd666b07879cd95b31190ef25affff67bc86 100644 (file)
@@ -86,7 +86,7 @@ public class OrganizationQualityProfilesUiTest {
       "/organization/OrganizationQualityProfilesUiTest/should_display_profile_inheritance.html",
       "/organization/OrganizationQualityProfilesUiTest/should_display_profile_exporters.html");
 
-    tester.openBrowser().openHome().logIn().submitCredentials(user.getLogin())
+    tester.openBrowser().logIn().submitCredentials(user.getLogin())
       .openQualityProfile("xoo", "sample", organization.getKey())
       .shouldHaveAssociatedProject("Sample")
       .shouldAllowToChangeProjects();