aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2018-04-03 16:58:02 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-05 20:20:47 +0200
commit726406c0d2b168abb40287f58e271934a42d072b (patch)
tree0be621604c37f2deff99a86dc605e40dcee605bf
parentd11fb8ece1a77f028a7ba95004df46ce725a0c00 (diff)
downloadsonarqube-726406c0d2b168abb40287f58e271934a42d072b.tar.gz
sonarqube-726406c0d2b168abb40287f58e271934a42d072b.zip
SONAR-10285 WS org enable support is now only available on SonarCloud
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java8
-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/tests/Category6Suite.java2
-rw-r--r--tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java1
-rw-r--r--tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java4
-rw-r--r--tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java4
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java3
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java2
9 files changed, 51 insertions, 23 deletions
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java
index 715020b7812..a3287db9f2f 100644
--- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java
+++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java
@@ -139,12 +139,8 @@ public class Tester extends ExternalResource implements TesterSession {
*/
public Navigation openBrowser() {
verifyStarted();
- return Navigation.create(orchestrator);
- }
-
- public Navigation openBrowser(String path) {
- verifyStarted();
- return Navigation.create(orchestrator, path);
+ // /projects is used as on SonarCloud instance, the "/" is redirected to SonarCloud website
+ return Navigation.create(orchestrator, "/projects");
}
private void verifyNotStarted() {
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 354def6d2ce..3a60efbdea1 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,25 +19,37 @@
*/
package org.sonar.server.organization.ws;
+import org.sonar.api.config.Configuration;
import org.sonar.core.platform.Module;
+import static org.sonar.process.ProcessProperties.Property.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,
- UpdateAction.class,
- UpdateProjectVisibilityAction.class);
+ SearchMembersAction.class);
+ if (config.getBoolean(SONARCLOUD_ENABLED.getKey()).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 8a9e2cf0735..dc857653ccc 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 + 4);
+ }
@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 + 11);
}
diff --git a/tests/src/test/java/org/sonarqube/tests/Category6Suite.java b/tests/src/test/java/org/sonarqube/tests/Category6Suite.java
index 842aa61711c..c8bbc8001f3 100644
--- a/tests/src/test/java/org/sonarqube/tests/Category6Suite.java
+++ b/tests/src/test/java/org/sonarqube/tests/Category6Suite.java
@@ -83,5 +83,7 @@ public class Category6Suite {
.addPlugin(pluginArtifact("base-auth-plugin"))
.addPlugin(pluginArtifact("ui-extensions-plugin"))
+ .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 eee7c8edf6b..9cb1c5d39dd 100644
--- a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
@@ -69,6 +69,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/project/ProjectBadgesTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java
index 4a38bcb4d6b..fe8bc6c1f81 100644
--- a/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java
@@ -53,7 +53,7 @@ public class ProjectBadgesTest {
@Test
public void public_project_badges() {
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
- tester.openBrowser("/projects").openProjectDashboard(PROJECT_KEY);
+ tester.openBrowser().openProjectDashboard(PROJECT_KEY);
SelenideElement badgesModal = openBadgesModal();
ElementsCollection badgeButtons = badgesModal.$$(".badge-button").shouldHaveSize(2);
@@ -80,7 +80,7 @@ public class ProjectBadgesTest {
.setProperties("sonar.organization", org.getKey(), "sonar.login", user.getLogin(), "sonar.password", user.getLogin())
);
tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample").setVisibility("private"));
- tester.openBrowser("/projects").logIn().submitCredentials(user.getLogin()).openProjectDashboard(PROJECT_KEY);
+ tester.openBrowser().logIn().submitCredentials(user.getLogin()).openProjectDashboard(PROJECT_KEY);
shouldNotHaveBadges();
}
diff --git a/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java b/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java
index 87833c335d9..289539b2820 100644
--- a/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java
@@ -54,7 +54,7 @@ public class SonarCloudProjectBadgesTest {
@Test
public void public_project_badges() {
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
- tester.openBrowser("/projects").openProjectDashboard(PROJECT_KEY);
+ tester.openBrowser().openProjectDashboard(PROJECT_KEY);
SelenideElement badgesModal = openBadgesModal();
ElementsCollection badgeButtons = badgesModal.$$(".badge-button").shouldHaveSize(3);
@@ -86,7 +86,7 @@ public class SonarCloudProjectBadgesTest {
.setProperties("sonar.organization", org.getKey(), "sonar.login", user.getLogin(), "sonar.password", user.getLogin())
);
tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample").setVisibility("private"));
- tester.openBrowser("/projects").logIn().submitCredentials(user.getLogin()).openProjectDashboard(PROJECT_KEY);
+ tester.openBrowser().logIn().submitCredentials(user.getLogin()).openProjectDashboard(PROJECT_KEY);
shouldNotHaveBadges();
}
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 44a91226fda..1320f6447fe 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
@@ -29,8 +29,8 @@ import org.junit.Test;
import org.junit.rules.DisableOnDebug;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
-import org.sonarqube.tests.Byteman;
import org.sonarqube.qa.util.Tester;
+import org.sonarqube.tests.Byteman;
import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Qualityprofiles;
import org.sonarqube.ws.client.rules.SearchRequest;
@@ -53,6 +53,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 4a39d3f2aa2..fc6c84db04f 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();