package it;
import com.sonar.orchestrator.Orchestrator;
-import it.organization.IssueAssignTest;
+import it.issue.OrganizationIssueAssignTest;
import it.organization.OrganizationMembershipTest;
-import it.organization.OrganizationQualityProfilesPageTest;
import it.organization.OrganizationTest;
+import it.qualityProfile.OrganizationQualityProfilesPageTest;
+import it.uiExtension.OrganizationUiExtensionsTest;
import it.user.OrganizationIdentityProviderTest;
import org.junit.BeforeClass;
import org.junit.ClassRule;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- IssueAssignTest.class,
OrganizationIdentityProviderTest.class,
+ OrganizationIssueAssignTest.class,
OrganizationMembershipTest.class,
OrganizationQualityProfilesPageTest.class,
- OrganizationTest.class
+ OrganizationTest.class,
+ OrganizationUiExtensionsTest.class,
})
public class Category6Suite {
public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
.addPlugin(xooPlugin())
.addPlugin(pluginArtifact("base-auth-plugin"))
+ .addPlugin(pluginArtifact("ui-extensions-plugin"))
.build();
@BeforeClass
--- /dev/null
+/*
+ * 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 it.issue;
+
+import com.sonar.orchestrator.Orchestrator;
+import it.Category6Suite;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonarqube.ws.Issues;
+import org.sonarqube.ws.Issues.Issue;
+import org.sonarqube.ws.client.HttpException;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.issue.AssignRequest;
+import org.sonarqube.ws.client.issue.BulkChangeRequest;
+import org.sonarqube.ws.client.issue.SearchWsRequest;
+import org.sonarqube.ws.client.organization.CreateWsRequest;
+import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
+import pageobjects.Navigation;
+import pageobjects.issues.IssuesPage;
+import util.issue.IssueRule;
+import util.user.UserRule;
+
+import static it.Category6Suite.enableOrganizationsSupport;
+import static java.lang.String.format;
+import static java.util.Collections.singletonList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.deleteOrganizationsIfExists;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.newOrganizationKey;
+import static util.ItUtils.restoreProfile;
+import static util.ItUtils.runProjectAnalysis;
+import static util.ItUtils.setServerProperty;
+
+public class OrganizationIssueAssignTest {
+
+ private final static String ORGANIZATION_KEY = newOrganizationKey();
+ private final static String OTHER_ORGANIZATION_KEY = newOrganizationKey();
+ private final static String SAMPLE_PROJECT_KEY = "sample";
+ private static final String ASSIGNEE_LOGIN = "bob";
+ private static final String OTHER_LOGIN = "neo";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Rule
+ public Navigation nav = Navigation.get(orchestrator);
+
+ @ClassRule
+ public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+
+ @ClassRule
+ public static UserRule userRule = UserRule.from(orchestrator);
+
+ @ClassRule
+ public static IssueRule issueRule = IssueRule.from(orchestrator);
+
+ private WsClient adminClient = newAdminWsClient(orchestrator);
+
+ @BeforeClass
+ public static void enableOrganizations() throws Exception {
+ enableOrganizationsSupport();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ userRule.deactivateUsers(ASSIGNEE_LOGIN, OTHER_LOGIN);
+ createOrganization(ORGANIZATION_KEY);
+ restoreProfile(orchestrator, getClass().getResource("/organization/IssueAssignTest/one-issue-per-file-profile.xml"), ORGANIZATION_KEY);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ userRule.deactivateUsers(ASSIGNEE_LOGIN, OTHER_LOGIN);
+ deleteOrganizationsIfExists(orchestrator, ORGANIZATION_KEY, OTHER_ORGANIZATION_KEY);
+ }
+
+ @Test
+ public void auto_assign_issues_to_user_if_default_assignee_is_member_of_project_organization() throws Exception {
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ provisionProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ setServerProperty(orchestrator, "sample", "sonar.issues.defaultAssigneeLogin", ASSIGNEE_LOGIN);
+
+ analyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+
+ assertThat(issueRule.getRandomIssue().getAssignee()).isEqualTo(ASSIGNEE_LOGIN);
+ }
+
+ @Test
+ public void does_not_auto_assign_issues_to_user_if_default_assignee_is_not_member_of_project_organization() throws Exception {
+ createOrganization(OTHER_ORGANIZATION_KEY);
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(OTHER_ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ provisionProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ setServerProperty(orchestrator, "sample", "sonar.issues.defaultAssigneeLogin", ASSIGNEE_LOGIN);
+
+ analyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+
+ assertThat(issueRule.getRandomIssue().hasAssignee()).isFalse();
+ }
+
+ @Test
+ public void assign_issue_to_user_being_member_of_same_organization_as_project_issue_organization() throws Exception {
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ Issue issue = issueRule.getRandomIssue();
+
+ adminClient.issues().assign(new AssignRequest(issue.getKey(), ASSIGNEE_LOGIN));
+
+ assertThat(issueRule.getByKey(issue.getKey()).getAssignee()).isEqualTo(ASSIGNEE_LOGIN);
+ }
+
+ @Test
+ public void fail_to_assign_issue_to_user_not_being_member_of_same_organization_as_project_issue_organization() throws Exception {
+ createOrganization(OTHER_ORGANIZATION_KEY);
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(OTHER_ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ Issue issue = issueRule.getRandomIssue();
+
+ expectedException.expect(HttpException.class);
+ expectedException.expectMessage(format("User 'bob' is not member of organization '%s'", ORGANIZATION_KEY));
+
+ adminClient.issues().assign(new AssignRequest(issue.getKey(), ASSIGNEE_LOGIN));
+ }
+
+ @Test
+ public void bulk_assign_issues_to_user_being_only_member_of_same_organization_as_project_issue_organization() throws Exception {
+ createOrganization(OTHER_ORGANIZATION_KEY);
+ restoreProfile(orchestrator, getClass().getResource("/organization/IssueAssignTest/one-issue-per-file-profile.xml"), OTHER_ORGANIZATION_KEY);
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ // User is only member of "organization-key", not of "other-organization-key"
+ adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ provisionAndAnalyseProject("sample2", OTHER_ORGANIZATION_KEY);
+ List<String> issues = issueRule.search(new org.sonarqube.ws.client.issue.SearchWsRequest()).getIssuesList().stream().map(Issue::getKey).collect(Collectors.toList());
+
+ Issues.BulkChangeWsResponse response = adminClient.issues().bulkChange(BulkChangeRequest.builder().setIssues(issues).setAssign(ASSIGNEE_LOGIN).build());
+
+ assertThat(response.getIgnored()).isGreaterThan(0);
+ assertThat(issueRule.search(new SearchWsRequest().setProjectKeys(singletonList("sample"))).getIssuesList()).extracting(Issue::getAssignee).containsOnly(ASSIGNEE_LOGIN);
+ assertThat(issueRule.search(new SearchWsRequest().setProjectKeys(singletonList("sample2"))).getIssuesList()).extracting(Issue::hasAssignee).containsOnly(false);
+ }
+
+ @Test
+ public void single_assign_search_show_only_members_in_global_issues() {
+ createOrganization(OTHER_ORGANIZATION_KEY);
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ userRule.createUser(OTHER_LOGIN, "pwd");
+ provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ IssuesPage page = nav.logIn().asAdmin().openIssues();
+ page.getFirstIssue()
+ .shouldAllowAssign()
+ .assigneeSearchResultCount(OTHER_LOGIN, 0)
+ .assigneeSearchResultCount(ASSIGNEE_LOGIN, 1);
+ }
+
+ @Test
+ public void bulk_assign_search_only_members_of_organization_in_project_issues() {
+ createOrganization(OTHER_ORGANIZATION_KEY);
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ userRule.createUser(OTHER_LOGIN, "pwd");
+ provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ IssuesPage page = nav.logIn().asAdmin().openComponentIssues(SAMPLE_PROJECT_KEY);
+ page
+ .bulkChangeOpen()
+ .bulkChangeAssigneeSearchCount(ASSIGNEE_LOGIN, 1)
+ .bulkChangeAssigneeSearchCount(OTHER_LOGIN, 0);
+ }
+
+ @Test
+ public void bulk_assign_search_all_users_in_global_issues() {
+ createOrganization(OTHER_ORGANIZATION_KEY);
+ userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
+ adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
+ userRule.createUser(OTHER_LOGIN, "pwd");
+ provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
+ IssuesPage page = nav.logIn().asAdmin().openIssues();
+ page
+ .bulkChangeOpen()
+ .bulkChangeAssigneeSearchCount(ASSIGNEE_LOGIN, 1)
+ .bulkChangeAssigneeSearchCount(OTHER_LOGIN, 1);
+ }
+
+ private void createOrganization(String organizationKey) {
+ adminClient.organizations().create(new CreateWsRequest.Builder().setKey(organizationKey).setName(organizationKey).build()).getOrganization();
+ }
+
+ private void provisionAndAnalyseProject(String projectKey, String organization) {
+ provisionProject(projectKey, organization);
+ analyseProject(projectKey, organization);
+ }
+
+ private void provisionProject(String projectKey, String organization) {
+ adminClient.projects().create(
+ CreateRequest.builder()
+ .setKey(projectKey)
+ .setName(projectKey)
+ .setOrganization(organization)
+ .build());
+ }
+
+ private void analyseProject(String projectKey, String organization) {
+ addQualityProfileToProject(organization, projectKey);
+ runProjectAnalysis(orchestrator, "issue/xoo-with-scm",
+ "sonar.projectKey", projectKey,
+ "sonar.organization", organization,
+ "sonar.login", "admin",
+ "sonar.password", "admin",
+ "sonar.scm.disabled", "false",
+ "sonar.scm.provider", "xoo");
+ }
+
+ private void addQualityProfileToProject(String organization, String projectKey) {
+ adminClient.qualityProfiles().addProject(
+ AddProjectRequest.builder()
+ .setProjectKey(projectKey)
+ .setOrganization(organization)
+ .setLanguage("xoo")
+ .setProfileName("one-issue-per-file-profile")
+ .build());
+ }
+}
+++ /dev/null
-/*
- * 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 it.organization;
-
-import com.sonar.orchestrator.Orchestrator;
-import it.Category6Suite;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonarqube.ws.Issues;
-import org.sonarqube.ws.Issues.Issue;
-import org.sonarqube.ws.client.HttpException;
-import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.issue.AssignRequest;
-import org.sonarqube.ws.client.issue.BulkChangeRequest;
-import org.sonarqube.ws.client.issue.SearchWsRequest;
-import org.sonarqube.ws.client.organization.CreateWsRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
-import pageobjects.Navigation;
-import pageobjects.issues.IssuesPage;
-import util.issue.IssueRule;
-import util.user.UserRule;
-
-import static it.Category6Suite.enableOrganizationsSupport;
-import static java.lang.String.format;
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static util.ItUtils.deleteOrganizationsIfExists;
-import static util.ItUtils.newAdminWsClient;
-import static util.ItUtils.newOrganizationKey;
-import static util.ItUtils.restoreProfile;
-import static util.ItUtils.runProjectAnalysis;
-import static util.ItUtils.setServerProperty;
-
-public class IssueAssignTest {
-
- private final static String ORGANIZATION_KEY = newOrganizationKey();
- private final static String OTHER_ORGANIZATION_KEY = newOrganizationKey();
- private final static String SAMPLE_PROJECT_KEY = "sample";
- private static final String ASSIGNEE_LOGIN = "bob";
- private static final String OTHER_LOGIN = "neo";
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Rule
- public Navigation nav = Navigation.get(orchestrator);
-
- @ClassRule
- public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
-
- @ClassRule
- public static UserRule userRule = UserRule.from(orchestrator);
-
- @ClassRule
- public static IssueRule issueRule = IssueRule.from(orchestrator);
-
- private WsClient adminClient = newAdminWsClient(orchestrator);
-
- @BeforeClass
- public static void enableOrganizations() throws Exception {
- enableOrganizationsSupport();
- }
-
- @Before
- public void setUp() throws Exception {
- userRule.deactivateUsers(ASSIGNEE_LOGIN, OTHER_LOGIN);
- createOrganization(ORGANIZATION_KEY);
- restoreProfile(orchestrator, getClass().getResource("/organization/IssueAssignTest/one-issue-per-file-profile.xml"), ORGANIZATION_KEY);
- }
-
- @After
- public void tearDown() throws Exception {
- userRule.deactivateUsers(ASSIGNEE_LOGIN, OTHER_LOGIN);
- deleteOrganizationsIfExists(orchestrator, ORGANIZATION_KEY, OTHER_ORGANIZATION_KEY);
- }
-
- @Test
- public void auto_assign_issues_to_user_if_default_assignee_is_member_of_project_organization() throws Exception {
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- provisionProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- setServerProperty(orchestrator, "sample", "sonar.issues.defaultAssigneeLogin", ASSIGNEE_LOGIN);
-
- analyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
-
- assertThat(issueRule.getRandomIssue().getAssignee()).isEqualTo(ASSIGNEE_LOGIN);
- }
-
- @Test
- public void does_not_auto_assign_issues_to_user_if_default_assignee_is_not_member_of_project_organization() throws Exception {
- createOrganization(OTHER_ORGANIZATION_KEY);
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(OTHER_ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- provisionProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- setServerProperty(orchestrator, "sample", "sonar.issues.defaultAssigneeLogin", ASSIGNEE_LOGIN);
-
- analyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
-
- assertThat(issueRule.getRandomIssue().hasAssignee()).isFalse();
- }
-
- @Test
- public void assign_issue_to_user_being_member_of_same_organization_as_project_issue_organization() throws Exception {
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- Issue issue = issueRule.getRandomIssue();
-
- adminClient.issues().assign(new AssignRequest(issue.getKey(), ASSIGNEE_LOGIN));
-
- assertThat(issueRule.getByKey(issue.getKey()).getAssignee()).isEqualTo(ASSIGNEE_LOGIN);
- }
-
- @Test
- public void fail_to_assign_issue_to_user_not_being_member_of_same_organization_as_project_issue_organization() throws Exception {
- createOrganization(OTHER_ORGANIZATION_KEY);
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(OTHER_ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- Issue issue = issueRule.getRandomIssue();
-
- expectedException.expect(HttpException.class);
- expectedException.expectMessage(format("User 'bob' is not member of organization '%s'", ORGANIZATION_KEY));
-
- adminClient.issues().assign(new AssignRequest(issue.getKey(), ASSIGNEE_LOGIN));
- }
-
- @Test
- public void bulk_assign_issues_to_user_being_only_member_of_same_organization_as_project_issue_organization() throws Exception {
- createOrganization(OTHER_ORGANIZATION_KEY);
- restoreProfile(orchestrator, getClass().getResource("/organization/IssueAssignTest/one-issue-per-file-profile.xml"), OTHER_ORGANIZATION_KEY);
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- // User is only member of "organization-key", not of "other-organization-key"
- adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- provisionAndAnalyseProject("sample2", OTHER_ORGANIZATION_KEY);
- List<String> issues = issueRule.search(new org.sonarqube.ws.client.issue.SearchWsRequest()).getIssuesList().stream().map(Issue::getKey).collect(Collectors.toList());
-
- Issues.BulkChangeWsResponse response = adminClient.issues().bulkChange(BulkChangeRequest.builder().setIssues(issues).setAssign(ASSIGNEE_LOGIN).build());
-
- assertThat(response.getIgnored()).isGreaterThan(0);
- assertThat(issueRule.search(new SearchWsRequest().setProjectKeys(singletonList("sample"))).getIssuesList()).extracting(Issue::getAssignee).containsOnly(ASSIGNEE_LOGIN);
- assertThat(issueRule.search(new SearchWsRequest().setProjectKeys(singletonList("sample2"))).getIssuesList()).extracting(Issue::hasAssignee).containsOnly(false);
- }
-
- @Test
- public void single_assign_search_show_only_members_in_global_issues() {
- createOrganization(OTHER_ORGANIZATION_KEY);
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- userRule.createUser(OTHER_LOGIN, "pwd");
- provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- IssuesPage page = nav.logIn().asAdmin().openIssues();
- page.getFirstIssue()
- .shouldAllowAssign()
- .assigneeSearchResultCount(OTHER_LOGIN, 0)
- .assigneeSearchResultCount(ASSIGNEE_LOGIN, 1);
- }
-
- @Test
- public void bulk_assign_search_only_members_of_organization_in_project_issues() {
- createOrganization(OTHER_ORGANIZATION_KEY);
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- userRule.createUser(OTHER_LOGIN, "pwd");
- provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- IssuesPage page = nav.logIn().asAdmin().openComponentIssues(SAMPLE_PROJECT_KEY);
- page
- .bulkChangeOpen()
- .bulkChangeAssigneeSearchCount(ASSIGNEE_LOGIN, 1)
- .bulkChangeAssigneeSearchCount(OTHER_LOGIN, 0);
- }
-
- @Test
- public void bulk_assign_search_all_users_in_global_issues() {
- createOrganization(OTHER_ORGANIZATION_KEY);
- userRule.createUser(ASSIGNEE_LOGIN, ASSIGNEE_LOGIN);
- adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN);
- userRule.createUser(OTHER_LOGIN, "pwd");
- provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY);
- IssuesPage page = nav.logIn().asAdmin().openIssues();
- page
- .bulkChangeOpen()
- .bulkChangeAssigneeSearchCount(ASSIGNEE_LOGIN, 1)
- .bulkChangeAssigneeSearchCount(OTHER_LOGIN, 1);
- }
-
- private void createOrganization(String organizationKey) {
- adminClient.organizations().create(new CreateWsRequest.Builder().setKey(organizationKey).setName(organizationKey).build()).getOrganization();
- }
-
- private void provisionAndAnalyseProject(String projectKey, String organization) {
- provisionProject(projectKey, organization);
- analyseProject(projectKey, organization);
- }
-
- private void provisionProject(String projectKey, String organization) {
- adminClient.projects().create(
- CreateRequest.builder()
- .setKey(projectKey)
- .setName(projectKey)
- .setOrganization(organization)
- .build());
- }
-
- private void analyseProject(String projectKey, String organization) {
- addQualityProfileToProject(organization, projectKey);
- runProjectAnalysis(orchestrator, "issue/xoo-with-scm",
- "sonar.projectKey", projectKey,
- "sonar.organization", organization,
- "sonar.login", "admin",
- "sonar.password", "admin",
- "sonar.scm.disabled", "false",
- "sonar.scm.provider", "xoo");
- }
-
- private void addQualityProfileToProject(String organization, String projectKey) {
- adminClient.qualityProfiles().addProject(
- AddProjectRequest.builder()
- .setProjectKey(projectKey)
- .setOrganization(organization)
- .setLanguage("xoo")
- .setProfileName("one-issue-per-file-profile")
- .build());
- }
-}
+++ /dev/null
-/*
- * 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 it.organization;
-
-import com.codeborne.selenide.Condition;
-import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.SonarScanner;
-import it.Category6Suite;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.organization.CreateWsRequest;
-import pageobjects.Navigation;
-
-import static com.codeborne.selenide.Selenide.$;
-import static it.Category6Suite.enableOrganizationsSupport;
-import static util.ItUtils.deleteOrganizationsIfExists;
-import static util.ItUtils.newAdminWsClient;
-import static util.ItUtils.projectDir;
-import static util.selenium.Selenese.runSelenese;
-
-public class OrganizationQualityProfilesPageTest {
-
- private static WsClient adminWsClient;
- private static final String ORGANIZATION = "test-org";
-
- @ClassRule
- public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
-
- @BeforeClass
- public static void setUp() {
- adminWsClient = newAdminWsClient(orchestrator);
- enableOrganizationsSupport();
- createOrganization();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- deleteOrganizationsIfExists(orchestrator, ORGANIZATION);
- }
-
- @Before
- public void createSampleProfile() {
- createProfile("xoo", "sample");
- inheritProfile("xoo", "sample", "Basic");
- analyzeProject("shared/xoo-sample");
- addProfileToProject("xoo", "sample", "sample");
- }
-
- @After
- public void deleteSampleProfile() {
- setDefault("xoo", "Basic");
- deleteProfile("xoo", "sample");
- deleteProfile("xoo", "new name");
- }
-
- @Test
- public void testNoGlobalPage() {
- Navigation nav = Navigation.get(orchestrator);
- nav.open("/profiles");
- $(".page-wrapper-simple").should(Condition.visible);
- }
-
- @Test
- public void testHomePage() throws Exception {
- runSelenese(orchestrator,
- "/organization/OrganizationQualityProfilesPageTest/should_display_list.html",
- "/organization/OrganizationQualityProfilesPageTest/should_open_from_list.html",
- "/organization/OrganizationQualityProfilesPageTest/should_filter_by_language.html");
- }
-
- @Test
- public void testProfilePage() throws Exception {
- runSelenese(orchestrator,
- "/organization/OrganizationQualityProfilesPageTest/should_display_profile_rules.html",
- "/organization/OrganizationQualityProfilesPageTest/should_display_profile_inheritance.html",
- "/organization/OrganizationQualityProfilesPageTest/should_display_profile_projects.html",
- "/organization/OrganizationQualityProfilesPageTest/should_display_profile_exporters.html");
- }
-
- @Test
- public void testNotFound() {
- Navigation nav = Navigation.get(orchestrator);
- nav.open("/organizations/" + ORGANIZATION + "/quality_profiles/show?key=unknown");
- $(".quality-profile-not-found").should(Condition.visible);
-
- nav.open("/organizations/" + ORGANIZATION + "/quality_profiles/show?language=xoo&name=unknown");
- $(".quality-profile-not-found").should(Condition.visible);
- }
-
- @Test
- public void testProfileChangelog() throws Exception {
- runSelenese(orchestrator,
- "/organization/OrganizationQualityProfilesPageTest/should_display_changelog.html");
- }
-
- @Ignore("find a way to know profile key inside selenium tests")
- @Test
- public void testComparison() throws Exception {
- runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_compare.html");
- }
-
- @Test
- public void testCreation() throws Exception {
- runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_create.html");
- }
-
- @Test
- public void testDeletion() throws Exception {
- runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_delete.html");
- }
-
- @Test
- public void testCopying() throws Exception {
- runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_copy.html");
- }
-
- @Test
- public void testRenaming() throws Exception {
- runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_rename.html");
- }
-
- @Test
- public void testSettingDefault() throws Exception {
- runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_set_default.html");
- }
-
- @Test
- public void testRestoration() throws Exception {
- deleteProfile("xoo", "empty");
-
- runSelenese(orchestrator,
- "/organization/OrganizationQualityProfilesPageTest/should_restore.html",
- "/organization/OrganizationQualityProfilesPageTest/should_restore_built_in.html");
- }
-
- private static void createProfile(String language, String name) {
- adminWsClient.wsConnector().call(
- new PostRequest("api/qualityprofiles/create")
- .setParam("language", language)
- .setParam("name", name)
- .setParam("organization", ORGANIZATION));
- }
-
- private static void inheritProfile(String language, String name, String parentName) {
- adminWsClient.wsConnector().call(
- new PostRequest("api/qualityprofiles/change_parent")
- .setParam("language", language)
- .setParam("profileName", name)
- .setParam("parentName", parentName)
- .setParam("organization", ORGANIZATION));
- }
-
- private static void analyzeProject(String path) {
- orchestrator.executeBuild(SonarScanner.create(projectDir(path)).setProperties(
- "sonar.organization", ORGANIZATION,
- "sonar.login", "admin",
- "sonar.password", "admin"));
- }
-
- private static void addProfileToProject(String language, String profileName, String projectKey) {
- adminWsClient.wsConnector().call(
- new PostRequest("api/qualityprofiles/add_project")
- .setParam("language", language)
- .setParam("profileName", profileName)
- .setParam("organization", ORGANIZATION)
- .setParam("projectKey", projectKey));
- }
-
- private static void deleteProfile(String language, String name) {
- adminWsClient.wsConnector().call(
- new PostRequest("api/qualityprofiles/delete")
- .setParam("language", language)
- .setParam("profileName", name)
- .setParam("organization", ORGANIZATION));
- }
-
- private static void setDefault(String language, String name) {
- adminWsClient.wsConnector().call(
- new PostRequest("api/qualityprofiles/set_default")
- .setParam("language", language)
- .setParam("profileName", name)
- .setParam("organization", ORGANIZATION));
- }
-
- private static void createOrganization() {
- adminWsClient.organizations().create(new CreateWsRequest.Builder().setKey(ORGANIZATION).setName(ORGANIZATION).build());
- }
-}
private static final String URL = "https://www.foo.fr";
private static final String AVATAR_URL = "https://www.foo.fr/corporate_logo.png";
private static final String SETTING_ANYONE_CAN_CREATE_ORGANIZATIONS = "sonar.organizations.anyoneCanCreate";
+ private static final String USER_LOGIN = "foo";
@ClassRule
public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
public void setUp() throws Exception {
resetSettings(orchestrator, null, SETTING_ANYONE_CAN_CREATE_ORGANIZATIONS);
deleteOrganizationsIfExists(orchestrator, KEY, "an-org");
+ userRule.deactivateUsers(USER_LOGIN);
}
@After
verifyUserNotAuthenticated(service -> service.delete(KEY));
// verify logged in user without any permission can't create update nor delete an organization by default
- userRule.createUser("john", "doh");
- verifyUserNotAuthorized("john", "doh", service -> service.create(new CreateWsRequest.Builder().setName("An org").build()));
- verifyUserNotAuthorized("john", "doh", service -> service.update(new UpdateWsRequest.Builder().setKey(KEY).setName("new name").build()));
- verifyUserNotAuthorized("john", "doh", service -> service.delete(KEY));
+ userRule.createUser(USER_LOGIN, USER_LOGIN);
+ verifyUserNotAuthorized(USER_LOGIN, USER_LOGIN, service -> service.create(new CreateWsRequest.Builder().setName("An org").build()));
+ verifyUserNotAuthorized(USER_LOGIN, USER_LOGIN, service -> service.update(new UpdateWsRequest.Builder().setKey(KEY).setName("new name").build()));
+ verifyUserNotAuthorized(USER_LOGIN, USER_LOGIN, service -> service.delete(KEY));
ItUtils.setServerProperty(orchestrator, SETTING_ANYONE_CAN_CREATE_ORGANIZATIONS, "true");
// verify anonymous still can't create update nor delete an organization if property is true
verifyUserNotAuthenticated(service -> service.delete(KEY));
// verify logged in user without any permission can't create nor update nor delete an organization if property is true
- verifyUserNotAuthorized("john", "doh", service -> service.update(new UpdateWsRequest.Builder().setKey(KEY).setName("new name").build()));
- verifyUserNotAuthorized("john", "doh", service -> service.delete(KEY));
+ verifyUserNotAuthorized(USER_LOGIN, USER_LOGIN, service -> service.update(new UpdateWsRequest.Builder().setKey(KEY).setName("new name").build()));
+ verifyUserNotAuthorized(USER_LOGIN, USER_LOGIN, service -> service.delete(KEY));
// clean-up
adminOrganizationService.delete(KEY);
verifySingleSearchResult(
- verifyUserAuthorized("john", "doh", service -> service.create(new CreateWsRequest.Builder().setName("An org").build())).getOrganization(),
+ verifyUserAuthorized(USER_LOGIN, USER_LOGIN, service -> service.create(new CreateWsRequest.Builder().setName("An org").build())).getOrganization(),
"An org", null, null, null);
}
@Test
public void create_fails_if_user_is_not_root() {
- userRule.createUser("foo", "bar");
+ userRule.createUser(USER_LOGIN, USER_LOGIN);
CreateWsRequest createWsRequest = new CreateWsRequest.Builder()
.setName("bla bla")
.build();
- OrganizationService fooUserOrganizationService = ItUtils.newUserWsClient(orchestrator, "foo", "bar").organizations();
+ OrganizationService fooUserOrganizationService = ItUtils.newUserWsClient(orchestrator, USER_LOGIN, USER_LOGIN).organizations();
expect403HttpError(() -> fooUserOrganizationService.create(createWsRequest));
- userRule.setRoot("foo");
+ userRule.setRoot(USER_LOGIN);
assertThat(fooUserOrganizationService.create(createWsRequest).getOrganization().getKey()).isEqualTo("bla-bla");
// delete org, attempt recreate when no root anymore and ensure it can't anymore
fooUserOrganizationService.delete("bla-bla");
- userRule.unsetRoot("foo");
+ userRule.unsetRoot(USER_LOGIN);
expect403HttpError(() -> fooUserOrganizationService.create(createWsRequest));
}
.getOrganization();
verifySingleSearchResult(createdOrganization, KEY, null, null, null);
- userRule.createUser("bob", "bob");
+ userRule.createUser(USER_LOGIN, USER_LOGIN);
userRule.removeGroups("sonar-users");
- adminOrganizationService.addMember(KEY, "bob");
- addPermissionsToUser(KEY, "bob", "provisioning", "scan");
+ adminOrganizationService.addMember(KEY, USER_LOGIN);
+ addPermissionsToUser(KEY, USER_LOGIN, "provisioning", "scan");
ItUtils.runProjectAnalysis(orchestrator, "shared/xoo-sample",
- "sonar.organization", KEY, "sonar.login", "bob", "sonar.password", "bob");
+ "sonar.organization", KEY, "sonar.login", USER_LOGIN, "sonar.password", USER_LOGIN);
ComponentsService componentsService = ItUtils.newAdminWsClient(orchestrator).components();
assertThat(searchSampleProject(KEY, componentsService).getComponentsList()).hasSize(1);
}
GroupManagement groupManagement = userRule.forOrganization(KEY);
- userRule.createUser("bob", "bob");
- adminOrganizationService.addMember(KEY, "bob");
+ userRule.createUser(USER_LOGIN, USER_LOGIN);
+ adminOrganizationService.addMember(KEY, USER_LOGIN);
groupManagement.createGroup("grp1");
groupManagement.createGroup("grp2");
- groupManagement.associateGroupsToUser("bob", "grp1", "grp2");
- assertThat(groupManagement.getUserGroups("bob").getGroups())
+ groupManagement.associateGroupsToUser(USER_LOGIN, "grp1", "grp2");
+ assertThat(groupManagement.getUserGroups(USER_LOGIN).getGroups())
.extracting(Groups.Group::getName)
.contains("grp1", "grp2");
- addPermissionsToUser(KEY, "bob", "provisioning", "scan");
+ addPermissionsToUser(KEY, USER_LOGIN, "provisioning", "scan");
ItUtils.runProjectAnalysis(orchestrator, "shared/xoo-sample",
- "sonar.organization", KEY, "sonar.login", "bob", "sonar.password", "bob");
+ "sonar.organization", KEY, "sonar.login", USER_LOGIN, "sonar.password", USER_LOGIN);
ComponentsService componentsService = ItUtils.newAdminWsClient(orchestrator).components();
assertThat(searchSampleProject(KEY, componentsService).getComponentsList()).hasSize(1);
--- /dev/null
+/*
+ * 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 it.qualityProfile;
+
+import com.codeborne.selenide.Condition;
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import it.Category6Suite;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.organization.CreateWsRequest;
+import pageobjects.Navigation;
+
+import static com.codeborne.selenide.Selenide.$;
+import static it.Category6Suite.enableOrganizationsSupport;
+import static util.ItUtils.deleteOrganizationsIfExists;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.projectDir;
+import static util.selenium.Selenese.runSelenese;
+
+public class OrganizationQualityProfilesPageTest {
+
+ private static WsClient adminWsClient;
+ private static final String ORGANIZATION = "test-org";
+
+ @ClassRule
+ public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
+
+ @BeforeClass
+ public static void setUp() {
+ adminWsClient = newAdminWsClient(orchestrator);
+ enableOrganizationsSupport();
+ createOrganization();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ deleteOrganizationsIfExists(orchestrator, ORGANIZATION);
+ }
+
+ @Before
+ public void createSampleProfile() {
+ createProfile("xoo", "sample");
+ inheritProfile("xoo", "sample", "Basic");
+ analyzeProject("shared/xoo-sample");
+ addProfileToProject("xoo", "sample", "sample");
+ }
+
+ @After
+ public void deleteSampleProfile() {
+ setDefault("xoo", "Basic");
+ deleteProfile("xoo", "sample");
+ deleteProfile("xoo", "new name");
+ }
+
+ @Test
+ public void testNoGlobalPage() {
+ Navigation nav = Navigation.get(orchestrator);
+ nav.open("/profiles");
+ $(".page-wrapper-simple").should(Condition.visible);
+ }
+
+ @Test
+ public void testHomePage() throws Exception {
+ runSelenese(orchestrator,
+ "/organization/OrganizationQualityProfilesPageTest/should_display_list.html",
+ "/organization/OrganizationQualityProfilesPageTest/should_open_from_list.html",
+ "/organization/OrganizationQualityProfilesPageTest/should_filter_by_language.html");
+ }
+
+ @Test
+ public void testProfilePage() throws Exception {
+ runSelenese(orchestrator,
+ "/organization/OrganizationQualityProfilesPageTest/should_display_profile_rules.html",
+ "/organization/OrganizationQualityProfilesPageTest/should_display_profile_inheritance.html",
+ "/organization/OrganizationQualityProfilesPageTest/should_display_profile_projects.html",
+ "/organization/OrganizationQualityProfilesPageTest/should_display_profile_exporters.html");
+ }
+
+ @Test
+ public void testNotFound() {
+ Navigation nav = Navigation.get(orchestrator);
+ nav.open("/organizations/" + ORGANIZATION + "/quality_profiles/show?key=unknown");
+ $(".quality-profile-not-found").should(Condition.visible);
+
+ nav.open("/organizations/" + ORGANIZATION + "/quality_profiles/show?language=xoo&name=unknown");
+ $(".quality-profile-not-found").should(Condition.visible);
+ }
+
+ @Test
+ public void testProfileChangelog() throws Exception {
+ runSelenese(orchestrator,
+ "/organization/OrganizationQualityProfilesPageTest/should_display_changelog.html");
+ }
+
+ @Ignore("find a way to know profile key inside selenium tests")
+ @Test
+ public void testComparison() throws Exception {
+ runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_compare.html");
+ }
+
+ @Test
+ public void testCreation() throws Exception {
+ runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_create.html");
+ }
+
+ @Test
+ public void testDeletion() throws Exception {
+ runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_delete.html");
+ }
+
+ @Test
+ public void testCopying() throws Exception {
+ runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_copy.html");
+ }
+
+ @Test
+ public void testRenaming() throws Exception {
+ runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_rename.html");
+ }
+
+ @Test
+ public void testSettingDefault() throws Exception {
+ runSelenese(orchestrator, "/organization/OrganizationQualityProfilesPageTest/should_set_default.html");
+ }
+
+ @Test
+ public void testRestoration() throws Exception {
+ deleteProfile("xoo", "empty");
+
+ runSelenese(orchestrator,
+ "/organization/OrganizationQualityProfilesPageTest/should_restore.html",
+ "/organization/OrganizationQualityProfilesPageTest/should_restore_built_in.html");
+ }
+
+ private static void createProfile(String language, String name) {
+ adminWsClient.wsConnector().call(
+ new PostRequest("api/qualityprofiles/create")
+ .setParam("language", language)
+ .setParam("name", name)
+ .setParam("organization", ORGANIZATION));
+ }
+
+ private static void inheritProfile(String language, String name, String parentName) {
+ adminWsClient.wsConnector().call(
+ new PostRequest("api/qualityprofiles/change_parent")
+ .setParam("language", language)
+ .setParam("profileName", name)
+ .setParam("parentName", parentName)
+ .setParam("organization", ORGANIZATION));
+ }
+
+ private static void analyzeProject(String path) {
+ orchestrator.executeBuild(SonarScanner.create(projectDir(path)).setProperties(
+ "sonar.organization", ORGANIZATION,
+ "sonar.login", "admin",
+ "sonar.password", "admin"));
+ }
+
+ private static void addProfileToProject(String language, String profileName, String projectKey) {
+ adminWsClient.wsConnector().call(
+ new PostRequest("api/qualityprofiles/add_project")
+ .setParam("language", language)
+ .setParam("profileName", profileName)
+ .setParam("organization", ORGANIZATION)
+ .setParam("projectKey", projectKey));
+ }
+
+ private static void deleteProfile(String language, String name) {
+ adminWsClient.wsConnector().call(
+ new PostRequest("api/qualityprofiles/delete")
+ .setParam("language", language)
+ .setParam("profileName", name)
+ .setParam("organization", ORGANIZATION));
+ }
+
+ private static void setDefault(String language, String name) {
+ adminWsClient.wsConnector().call(
+ new PostRequest("api/qualityprofiles/set_default")
+ .setParam("language", language)
+ .setParam("profileName", name)
+ .setParam("organization", ORGANIZATION));
+ }
+
+ private static void createOrganization() {
+ adminWsClient.organizations().create(new CreateWsRequest.Builder().setKey(ORGANIZATION).setName(ORGANIZATION).build());
+ }
+}
import com.codeborne.selenide.Condition;
import com.sonar.orchestrator.Orchestrator;
+import it.Category6Suite;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.WebDriverRunner.url;
-import static java.util.Collections.emptyMap;
-import static java.util.Locale.ENGLISH;
-import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+import static it.Category6Suite.enableOrganizationsSupport;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.newAdminWsClient;
-import static util.ItUtils.pluginArtifact;
-import static util.ItUtils.xooPlugin;
+import static util.ItUtils.newOrganizationKey;
public class OrganizationUiExtensionsTest {
@ClassRule
- public static final Orchestrator orchestrator = Orchestrator.builderEnv()
- .addPlugin(xooPlugin())
- .addPlugin(pluginArtifact("ui-extensions-plugin"))
- .build();
+ public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
@Rule
public Navigation nav = Navigation.get(orchestrator);
@BeforeClass
public static void setUp() throws Exception {
- orchestrator.resetData();
adminClient = newAdminWsClient(orchestrator);
- orchestrator.getServer().post("api/organizations/enable_support", emptyMap());
+ enableOrganizationsSupport();
}
@Test
}
private static String createOrganization() {
- String keyAndName = randomAlphabetic(32).toLowerCase(ENGLISH);
+ String keyAndName = newOrganizationKey();
adminClient.organizations().create(new CreateWsRequest.Builder().setKey(keyAndName).setName(keyAndName).build()).getOrganization();
return keyAndName;
}