]> source.dussan.org Git - sonarqube.git/commitdiff
Clean-up category "organization"
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 10 Nov 2017 10:06:13 +0000 (11:06 +0100)
committerEric Hartmann <hartmann.eric@gmail.Com>
Tue, 14 Nov 2017 12:10:17 +0000 (13:10 +0100)
15 files changed:
cix.sh
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java
tests/src/test/java/org/sonarqube/tests/Category4Suite.java
tests/src/test/java/org/sonarqube/tests/Category6Suite.java
tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationWebExtensionsTest.java [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java
tests/src/test/java/org/sonarqube/tests/organization/RootUserOnOrganizationTest.java [deleted file]
tests/src/test/java/org/sonarqube/tests/organization/RootUserTest.java
tests/src/test/java/org/sonarqube/tests/ui/OrganizationUiExtensionsTest.java [deleted file]
tests/src/test/java/org/sonarqube/tests/user/RootUserInStandaloneModeTest.java [new file with mode: 0644]

diff --git a/cix.sh b/cix.sh
index 6d7f8d0fd5b1aef2e36139b170c31f4c2a12ea13..90b86f23891a8e5940eb4cf001a6eba2783d6e5a 100755 (executable)
--- a/cix.sh
+++ b/cix.sh
@@ -54,6 +54,7 @@ case "$RUN_ACTIVITY" in
 
         Category6)
           CATEGORY=Category6 && runCategory
+          CATEGORY=organization && runCategory
           ;;
 
         *)
index 00c08c1048065f4f5f9532e943189f76aa9d2823..460ea8d8ae9fd1632fd49cad1f71e3447a6d8a68 100644 (file)
@@ -65,9 +65,9 @@ public class SettingTester {
     setSetting(null, key, value);
   }
 
-  public void setGlobalSettings(String... properties) {
-    for (int i = 0; i < properties.length; i += 2) {
-      setSetting(null, properties[i], properties[i + 1]);
+  public void setGlobalSettings(String... keyValues) {
+    for (int i = 0; i < keyValues.length; i += 2) {
+      setSetting(null, keyValues[i], keyValues[i + 1]);
     }
   }
 
index 55361639e587e772a494c7692435668329315504..f8f0e52c1bb706deb66a98bf981176ede1bf09a9 100644 (file)
@@ -30,7 +30,7 @@ import org.sonarqube.tests.ce.CeWsTest;
 import org.sonarqube.tests.component.ComponentsWsTest;
 import org.sonarqube.tests.component.ProjectsWsTest;
 import org.sonarqube.tests.dbCleaner.PurgeTest;
-import org.sonarqube.tests.organization.RootUserTest;
+import org.sonarqube.tests.user.RootUserInStandaloneModeTest;
 import org.sonarqube.tests.projectEvent.EventTest;
 import org.sonarqube.tests.projectEvent.ProjectActivityPageTest;
 import org.sonarqube.tests.qualityProfile.QualityProfilesUiTest;
@@ -57,7 +57,7 @@ import static util.ItUtils.xooPlugin;
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
   // organization
-  RootUserTest.class,
+  RootUserInStandaloneModeTest.class,
   // server system
   ServerSystemTest.class,
   SystemInfoTest.class,
index 8fc6f4f49b5b4fef7480ac9e80fc02dfb9ed13c5..a7cec719ffc3763bac643c53236d703dc8ee92a3 100644 (file)
@@ -26,17 +26,11 @@ 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;
-import org.sonarqube.tests.organization.BillingTest;
-import org.sonarqube.tests.organization.OrganizationMembershipTest;
-import org.sonarqube.tests.organization.OrganizationMembershipUiTest;
-import org.sonarqube.tests.organization.OrganizationTest;
-import org.sonarqube.tests.organization.PersonalOrganizationTest;
-import org.sonarqube.tests.organization.RootUserOnOrganizationTest;
 import org.sonarqube.tests.projectAdministration.ProjectDeleteTest;
 import org.sonarqube.tests.projectAdministration.ProjectKeyUpdateTest;
 import org.sonarqube.tests.projectAdministration.ProjectProvisioningTest;
@@ -50,7 +44,6 @@ import org.sonarqube.tests.qualityProfile.OrganizationQualityProfilesUiTest;
 import org.sonarqube.tests.qualityProfile.QualityProfilesEditTest;
 import org.sonarqube.tests.qualityProfile.QualityProfilesWsTest;
 import org.sonarqube.tests.rule.RulesWsTest;
-import org.sonarqube.tests.ui.OrganizationUiExtensionsTest;
 import org.sonarqube.tests.user.OrganizationIdentityProviderTest;
 
 import static util.ItUtils.pluginArtifact;
@@ -64,19 +57,12 @@ import static util.ItUtils.xooPlugin;
   OrganizationIdentityProviderTest.class,
   OrganizationIssueAssignTest.class,
   OrganizationIssuesPageTest.class,
-  OrganizationMembershipTest.class,
-  OrganizationMembershipUiTest.class,
   OrganizationQualityGateUiTest.class,
   OrganizationQualityProfilesUiTest.class,
-  OrganizationTest.class,
-  RootUserOnOrganizationTest.class,
-  OrganizationUiExtensionsTest.class,
-  PersonalOrganizationTest.class,
   BuiltInQualityProfilesTest.class,
   QualityProfilesEditTest.class,
   QualityProfilesWsTest.class,
   CustomQualityProfilesTest.class,
-  BillingTest.class,
   IssueTagsTest.class,
   LeakProjectsPageTest.class,
   SearchProjectsTest.class,
@@ -104,7 +90,6 @@ public class Category6Suite {
 
     .addPlugin(xooPlugin())
     .addPlugin(pluginArtifact("base-auth-plugin"))
-    .addPlugin(pluginArtifact("fake-billing-plugin"))
     .addPlugin(pluginArtifact("ui-extensions-plugin"))
 
     // reduce memory for Elasticsearch to 128M
index e0a8d9c2ea1309ec2e606c67f469dba760a1b854..911305356e265da313fcc768138a876a80bc46e2 100644 (file)
@@ -22,13 +22,13 @@ package org.sonarqube.tests.organization;
 import com.sonar.orchestrator.Orchestrator;
 import com.sonar.orchestrator.build.BuildResult;
 import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category6Suite;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.GetRequest;
@@ -36,7 +36,6 @@ import org.sonarqube.ws.client.WsResponse;
 import org.sonarqube.ws.client.organization.UpdateProjectVisibilityWsRequest;
 import org.sonarqube.ws.client.project.CreateRequest;
 import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
-import org.sonarqube.qa.util.pageobjects.Navigation;
 import util.ItUtils;
 
 import static java.lang.String.format;
@@ -45,15 +44,13 @@ import static org.sonarqube.ws.WsCe.TaskResponse;
 import static util.ItUtils.expectHttpError;
 import static util.ItUtils.newProjectKey;
 import static util.ItUtils.projectDir;
-import static util.ItUtils.resetSettings;
-import static util.ItUtils.setServerProperty;
 
 public class BillingTest {
 
   private static final String PROPERTY_PREVENT_ANALYSIS = "sonar.billing.preventProjectAnalysis";
 
   @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
 
   @Rule
   public Tester tester = new Tester(orchestrator);
@@ -64,7 +61,7 @@ public class BillingTest {
   @Before
   @After
   public void reset() {
-    resetSettings(orchestrator, null, PROPERTY_PREVENT_ANALYSIS, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate");
+    tester.settings().resetSettings(PROPERTY_PREVENT_ANALYSIS, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate");
   }
 
   @Before
@@ -75,7 +72,7 @@ public class BillingTest {
 
   @Test
   public void execute_successfully_ce_analysis_on_organization() {
-    setServerProperty(orchestrator, PROPERTY_PREVENT_ANALYSIS, "false");
+    tester.settings().setGlobalSettings(PROPERTY_PREVENT_ANALYSIS, "false");
 
     String taskUuid = executeAnalysis(newProjectKey());
 
@@ -85,7 +82,7 @@ public class BillingTest {
 
   @Test
   public void fail_to_execute_ce_analysis_on_organization() {
-    setServerProperty(orchestrator, PROPERTY_PREVENT_ANALYSIS, "true");
+    tester.settings().setGlobalSettings(PROPERTY_PREVENT_ANALYSIS, "true");
 
     String taskUuid = executeAnalysis(newProjectKey());
 
@@ -99,15 +96,15 @@ public class BillingTest {
     User user = tester.users().generate();
     tester.organizations().addMember(organization, user);
 
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
     assertWsResponseAsAdmin(new GetRequest("api/navigation/organization").setParam("organization", organization.getKey()),
       "\"canUpdateProjectsVisibilityToPrivate\":true");
 
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
     assertWsResponseAsAdmin(new GetRequest("api/navigation/organization").setParam("organization", organization.getKey()),
       "\"canUpdateProjectsVisibilityToPrivate\":false");
 
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
     assertWsResponseAsUser(new GetRequest("api/navigation/organization").setParam("organization", organization.getKey()),
       "\"canUpdateProjectsVisibilityToPrivate\":false", user);
   }
@@ -116,18 +113,18 @@ public class BillingTest {
   public void api_navigation_component_returns_canUpdateProjectVisibilityToPrivate() {
     String projectKey = createPublicProject();
 
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
     assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey),
       "\"canUpdateProjectVisibilityToPrivate\":true");
 
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
     assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey),
       "\"canUpdateProjectVisibilityToPrivate\":false");
   }
 
   @Test
   public void does_not_fail_to_update_default_projects_visibility_to_private() {
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
 
     tester.wsClient().organizations().updateProjectVisibility(UpdateProjectVisibilityWsRequest.builder()
       .setOrganization(organization.getKey())
@@ -140,7 +137,7 @@ public class BillingTest {
 
   @Test
   public void fail_to_update_organization_default_visibility_to_private() {
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
 
     expectHttpError(400,
       format("Organization %s cannot use private project", organization.getKey()),
@@ -151,7 +148,7 @@ public class BillingTest {
   @Test
   public void does_not_fail_to_update_project_visibility_to_private() {
     String projectKey = createPublicProject();
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
 
     tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build());
 
@@ -161,7 +158,7 @@ public class BillingTest {
   @Test
   public void fail_to_update_project_visibility_to_private() {
     String projectKey = createPublicProject();
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
 
     expectHttpError(400,
       format("Organization %s cannot use private project", organization.getKey()),
@@ -171,7 +168,7 @@ public class BillingTest {
   @Test
   public void does_not_fail_to_create_private_project() {
     String projectKey = newProjectKey();
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
 
     tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("public").build());
 
@@ -181,7 +178,7 @@ public class BillingTest {
   @Test
   public void fail_to_create_private_project() {
     String projectKey = newProjectKey();
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
 
     expectHttpError(400,
       format("Organization %s cannot use private project", organization.getKey()),
@@ -192,7 +189,7 @@ public class BillingTest {
   @Test
   public void ui_does_not_allow_to_turn_project_to_private() {
     String projectKey = createPublicProject();
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
 
     Navigation.create(orchestrator)
       .logIn().submitCredentials(orgAdministrator.getLogin())
@@ -204,7 +201,7 @@ public class BillingTest {
   @Test
   public void ui_allows_to_turn_project_to_private() {
     String projectKey = createPublicProject();
-    setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+    tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
 
     tester.openBrowser()
       .logIn().submitCredentials(orgAdministrator.getLogin())
index 1903f3c733600a03c2c8c6cf93358f7bcf52314c..7968fe4d50a680717a192de3b71f483da90af087 100644 (file)
@@ -21,9 +21,8 @@
 package org.sonarqube.tests.organization;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
@@ -34,12 +33,10 @@ import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.HttpException;
 import org.sonarqube.ws.client.permission.AddUserWsRequest;
 
-import static util.ItUtils.setServerProperty;
-
 public class OrganizationMembershipTest {
 
   @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
 
   @Rule
   public Tester tester = new Tester(orchestrator);
@@ -47,14 +44,14 @@ public class OrganizationMembershipTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  @BeforeClass
-  public static void setUp() {
-    setServerProperty(orchestrator, "sonar.organizations.anyoneCanCreate", "true");
+  @Before
+  public void setUp() {
+    tester.settings().setGlobalSettings("sonar.organizations.anyoneCanCreate", "true");
   }
 
-  @AfterClass
-  public static void tearDown() {
-    setServerProperty(orchestrator, "sonar.organizations.anyoneCanCreate", null);
+  @After
+  public void tearDown() {
+    tester.settings().resetSettings("sonar.organizations.anyoneCanCreate");
   }
 
   @Test
index bec9b244087aae420a72edab813eda59a20566ef..36064dd20f34c24aea71bb3b5eeaaebc523a6035 100644 (file)
@@ -26,16 +26,15 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.qa.util.pageobjects.organization.MembersPage;
-import org.sonarqube.tests.Category6Suite;
 import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.pageobjects.organization.MembersPage;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 
 public class OrganizationMembershipUiTest {
 
   @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
 
   @Rule
   public Tester tester = new Tester(orchestrator);
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java
new file mode 100644 (file)
index 0000000..7984124
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.tests.organization;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import static util.ItUtils.pluginArtifact;
+import static util.ItUtils.xooPlugin;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+  BillingTest.class,
+  OrganizationMembershipTest.class,
+  OrganizationMembershipUiTest.class,
+  OrganizationTest.class,
+  OrganizationWebExtensionsTest.class,
+  PersonalOrganizationTest.class,
+  RootUserTest.class
+})
+public class OrganizationSuite {
+
+  @ClassRule
+  public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
+
+    .addPlugin(xooPlugin())
+    .addPlugin(pluginArtifact("fake-billing-plugin"))
+    .addPlugin(pluginArtifact("ui-extensions-plugin"))
+    
+    // reduce memory for Elasticsearch to 128M
+    .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+
+    .build();
+}
index 39750b1e9c1c0e125b44b1d5f03bbd4db6edafca..158516a3ff9581dc99f222efb2e3d92846107a01 100644 (file)
@@ -21,7 +21,6 @@ package org.sonarqube.tests.organization;
 
 import com.sonar.orchestrator.Orchestrator;
 import com.sonar.orchestrator.build.BuildFailureException;
-import org.sonarqube.tests.Category6Suite;
 import java.util.List;
 import java.util.Locale;
 import org.junit.After;
@@ -67,7 +66,7 @@ public class OrganizationTest {
   private static final String AVATAR_URL = "https://www.foo.fr/corporate_logo.png";
 
   @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
   @Rule
   public Tester tester = new Tester(orchestrator);
   @Rule
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationWebExtensionsTest.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationWebExtensionsTest.java
new file mode 100644 (file)
index 0000000..6387a8e
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.tests.organization;
+
+import com.codeborne.selenide.Condition;
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.Organizations.Organization;
+import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
+
+import static com.codeborne.selenide.Condition.text;
+import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.WebDriverRunner.url;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class OrganizationWebExtensionsTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
+
+  @Rule
+  public Tester tester = new Tester(orchestrator);
+
+  @Test
+  public void organization_page() {
+    Organization organization = tester.organizations().generate();
+    tester.openBrowser().open("/organizations/" + organization.getKey() + "/projects");
+
+    $("#organization-navigation-more").click();
+    $(By.linkText("Organization Page")).shouldBe(Condition.visible).click();
+
+    assertThat(url()).contains("uiextensionsplugin/organization_page");
+    $("body").shouldHave(text("uiextensionsplugin/organization_page"));
+  }
+
+  @Test
+  public void organization_admin_page() {
+    Organization organization = tester.organizations().generate();
+    User administrator = tester.users().generateAdministrator(organization);
+    tester.openBrowser()
+      .logIn().submitCredentials(administrator.getLogin())
+      .open("/organizations/" + organization.getKey() + "/projects");
+
+    $("#organization-navigation-admin").click();
+    $(By.linkText("Organization Admin Page")).shouldBe(Condition.visible).click();
+
+    assertThat(url()).contains("uiextensionsplugin/organization_admin_page");
+    $("body").shouldHave(text("uiextensionsplugin/organization_admin_page"));
+  }
+}
index 9faddde8421e5e15272a1050dd090d24363e7cdb..5c421aaf580c7d6b6dea4188c8483078b8b0ad68 100644 (file)
@@ -21,7 +21,6 @@
 package org.sonarqube.tests.organization;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
 import java.util.List;
 import org.junit.After;
 import org.junit.Before;
@@ -41,7 +40,7 @@ public class PersonalOrganizationTest {
   private static final String SETTING_CREATE_PERSONAL_ORG = "sonar.organizations.createPersonalOrg";
 
   @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
 
   @Rule
   public Tester tester = new Tester(orchestrator);
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/RootUserOnOrganizationTest.java b/tests/src/test/java/org/sonarqube/tests/organization/RootUserOnOrganizationTest.java
deleted file mode 100644 (file)
index 5b32621..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests.organization;
-
-import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
-import java.sql.SQLException;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.qa.util.TesterSession;
-import org.sonarqube.qa.util.Tester;
-import org.sonarqube.ws.WsRoot;
-import org.sonarqube.ws.WsUsers;
-import util.user.UserRule;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static util.ItUtils.expectBadRequestError;
-import static util.ItUtils.expectForbiddenError;
-
-public class RootUserOnOrganizationTest {
-
-  @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
-
-  @Rule
-  public Tester tester = new Tester(orchestrator);
-
-  @Test
-  public void system_administrator_is_flagged_as_root_when_he_enables_organization_support() {
-    assertThat(tester.wsClient().roots().search().getRootsList())
-      .extracting(WsRoot.Root::getLogin)
-      .containsExactly(UserRule.ADMIN_LOGIN);
-  }
-
-  @Test
-  public void a_root_can_flag_other_user_as_root() {
-    WsUsers.CreateWsResponse.User user = tester.users().generate();
-    tester.wsClient().roots().setRoot(user.getLogin());
-
-    assertThat(tester.wsClient().roots().search().getRootsList())
-      .extracting(WsRoot.Root::getLogin)
-      .containsExactlyInAnyOrder(UserRule.ADMIN_LOGIN, user.getLogin());
-  }
-
-  @Test
-  public void last_root_can_not_be_unset_root() throws SQLException {
-    expectBadRequestError(() -> tester.wsClient().roots().unsetRoot(UserRule.ADMIN_LOGIN));
-  }
-
-  @Test
-  public void root_can_be_set_and_unset_via_web_services() {
-    WsUsers.CreateWsResponse.User user1 = tester.users().generate();
-    WsUsers.CreateWsResponse.User user2 = tester.users().generate();
-    TesterSession user1Session = tester.as(user1.getLogin());
-    TesterSession user2Session = tester.as(user2.getLogin());
-
-    // non root can not set or unset root another user not itself
-    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user2.getLogin()));
-    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user1.getLogin()));
-    expectForbiddenError(() -> user1Session.wsClient().roots().unsetRoot(user1.getLogin()));
-    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(user1.getLogin()));
-    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(user2.getLogin()));
-    // admin (the first root) sets root1 as root
-    tester.wsClient().roots().setRoot(user1.getLogin());
-    // root1 can set root root2
-    user1Session.wsClient().roots().setRoot(user2.getLogin());
-    // root2 can unset root root1
-    user2Session.wsClient().roots().unsetRoot(user1.getLogin());
-    // root2 can unset root itself as it's not the last root
-    user2Session.wsClient().roots().unsetRoot(user2.getLogin());
-  }
-
-}
index 6d66e5fc33c6b46d10350c0a7899e8c396a48772..2a7d0d3f8bcf70e0e4a1822b80ece208f1e34d48 100644 (file)
 package org.sonarqube.tests.organization;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category4Suite;
+import java.sql.SQLException;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.TesterSession;
+import org.sonarqube.ws.WsRoot;
+import org.sonarqube.ws.WsUsers;
+import util.user.UserRule;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.expectBadRequestError;
 import static util.ItUtils.expectForbiddenError;
 
 public class RootUserTest {
 
   @ClassRule
-  public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = OrganizationSuite.ORCHESTRATOR;
 
   @Rule
-  public Tester tester = new Tester(orchestrator).disableOrganizations();
+  public Tester tester = new Tester(orchestrator);
 
   @Test
-  public void nobody_is_root_by_default_when_organizations_are_disabled() {
-    // anonymous
-    expectForbiddenError(() -> tester.wsClient().roots().search());
+  public void system_administrator_is_flagged_as_root_when_he_enables_organization_support() {
+    assertThat(tester.wsClient().roots().search().getRootsList())
+      .extracting(WsRoot.Root::getLogin)
+      .containsExactly(UserRule.ADMIN_LOGIN);
+  }
+
+  @Test
+  public void a_root_can_flag_other_user_as_root() {
+    WsUsers.CreateWsResponse.User user = tester.users().generate();
+    tester.wsClient().roots().setRoot(user.getLogin());
 
-    // admin
-    expectForbiddenError(() -> tester.wsClient().roots().search());
+    assertThat(tester.wsClient().roots().search().getRootsList())
+      .extracting(WsRoot.Root::getLogin)
+      .containsExactlyInAnyOrder(UserRule.ADMIN_LOGIN, user.getLogin());
+  }
+
+  @Test
+  public void last_root_can_not_be_unset_root() throws SQLException {
+    expectBadRequestError(() -> tester.wsClient().roots().unsetRoot(UserRule.ADMIN_LOGIN));
   }
+
+  @Test
+  public void root_can_be_set_and_unset_via_web_services() {
+    WsUsers.CreateWsResponse.User user1 = tester.users().generate();
+    WsUsers.CreateWsResponse.User user2 = tester.users().generate();
+    TesterSession user1Session = tester.as(user1.getLogin());
+    TesterSession user2Session = tester.as(user2.getLogin());
+
+    // non root can not set or unset root another user not itself
+    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user2.getLogin()));
+    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user1.getLogin()));
+    expectForbiddenError(() -> user1Session.wsClient().roots().unsetRoot(user1.getLogin()));
+    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(user1.getLogin()));
+    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(user2.getLogin()));
+    // admin (the first root) sets root1 as root
+    tester.wsClient().roots().setRoot(user1.getLogin());
+    // root1 can set root root2
+    user1Session.wsClient().roots().setRoot(user2.getLogin());
+    // root2 can unset root root1
+    user2Session.wsClient().roots().unsetRoot(user1.getLogin());
+    // root2 can unset root itself as it's not the last root
+    user2Session.wsClient().roots().unsetRoot(user2.getLogin());
+  }
+
 }
diff --git a/tests/src/test/java/org/sonarqube/tests/ui/OrganizationUiExtensionsTest.java b/tests/src/test/java/org/sonarqube/tests/ui/OrganizationUiExtensionsTest.java
deleted file mode 100644 (file)
index be96edb..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests.ui;
-
-import com.codeborne.selenide.Condition;
-import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.sonarqube.qa.util.Tester;
-import org.sonarqube.ws.Organizations.Organization;
-import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
-
-import static com.codeborne.selenide.Condition.text;
-import static com.codeborne.selenide.Selenide.$;
-import static com.codeborne.selenide.WebDriverRunner.url;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class OrganizationUiExtensionsTest {
-
-  @ClassRule
-  public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
-
-  @Rule
-  public Tester tester = new Tester(orchestrator);
-
-  @Test
-  public void organization_page() {
-    Organization organization = tester.organizations().generate();
-    tester.openBrowser().open("/organizations/" + organization.getKey() + "/projects");
-
-    $("#organization-navigation-more").click();
-    $(By.linkText("Organization Page")).shouldBe(Condition.visible).click();
-
-    assertThat(url()).contains("uiextensionsplugin/organization_page");
-    $("body").shouldHave(text("uiextensionsplugin/organization_page"));
-  }
-
-  @Test
-  public void organization_admin_page() {
-    Organization organization = tester.organizations().generate();
-    User administrator = tester.users().generateAdministrator(organization);
-    tester.openBrowser()
-      .logIn().submitCredentials(administrator.getLogin())
-      .open("/organizations/" + organization.getKey() + "/projects");
-
-    $("#organization-navigation-admin").click();
-    $(By.linkText("Organization Admin Page")).shouldBe(Condition.visible).click();
-
-    assertThat(url()).contains("uiextensionsplugin/organization_admin_page");
-    $("body").shouldHave(text("uiextensionsplugin/organization_admin_page"));
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/user/RootUserInStandaloneModeTest.java b/tests/src/test/java/org/sonarqube/tests/user/RootUserInStandaloneModeTest.java
new file mode 100644 (file)
index 0000000..422910f
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.tests.user;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.sonarqube.tests.Category4Suite;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
+
+import static util.ItUtils.expectForbiddenError;
+
+public class RootUserInStandaloneModeTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+
+  @Rule
+  public Tester tester = new Tester(orchestrator).disableOrganizations();
+
+  @Test
+  public void nobody_is_root_by_default_when_organizations_are_disabled() {
+    // anonymous
+    expectForbiddenError(() -> tester.wsClient().roots().search());
+
+    // admin
+    expectForbiddenError(() -> tester.wsClient().roots().search());
+  }
+}