aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2018-03-22 17:19:25 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2018-04-04 08:49:17 +0200
commit41d6681a6828be8ce51ec955afd8e4168a1af85f (patch)
treebd767939933cf7f11b930e1858a30b3d14e960ab
parentf06a639eee611734771ee8d7e335b7bc9a9b3016 (diff)
downloadsonarqube-41d6681a6828be8ce51ec955afd8e4168a1af85f.tar.gz
sonarqube-41d6681a6828be8ce51ec955afd8e4168a1af85f.zip
SONAR-10285 WS org/enable_support is now only available on SonarCloud
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java28
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java22
-rw-r--r--tests/src/test/java/org/sonarqube/pageobjects/Navigation.java6
-rw-r--r--tests/src/test/java/org/sonarqube/tests/Category6Suite.java4
-rw-r--r--tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java1
-rw-r--r--tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java6
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java1
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java2
8 files changed, 51 insertions, 19 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
index dccacc427fd..f27020591f8 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
@@ -19,26 +19,38 @@
*/
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);
+ }
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java
index 3ced226dcae..66c96ce2047 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java
@@ -20,18 +20,34 @@
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);
}
diff --git a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
index b85f3a79566..e162bca4398 100644
--- a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
+++ b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
@@ -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) {
diff --git a/tests/src/test/java/org/sonarqube/tests/Category6Suite.java b/tests/src/test/java/org/sonarqube/tests/Category6Suite.java
index 8fc6f4f49b5..4fd84037fd5 100644
--- a/tests/src/test/java/org/sonarqube/tests/Category6Suite.java
+++ b/tests/src/test/java/org/sonarqube/tests/Category6Suite.java
@@ -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();
}
diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
index 226c736032f..e2321a43ef3 100644
--- a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
@@ -68,6 +68,7 @@ public class AnalysisEsResilienceTest {
.getOrchestratorBuilder()
.addPlugin(ItUtils.xooPlugin())
.setServerProperty("sonar.search.httpPort", "" + esHttpPort)
+ .setServerProperty("sonar.sonarcloud.enabled", "true")
.build();
}
diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java
index 683b808fbbe..7d382d88158 100644
--- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java
@@ -21,13 +21,14 @@
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();
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
index 49be3215f07..a2d272d3072 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
@@ -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();
}
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java
index 1414b129683..3189bd666b0 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java
@@ -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();