From: Julien Lancelot Date: Tue, 13 Jun 2017 09:56:33 +0000 (+0200) Subject: Fix Selenium ITs that were using bundle 'admin' user X-Git-Tag: 6.5-M2~118 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=71531284395e2d0f674a2942235b78974dd9a35f;p=sonarqube.git Fix Selenium ITs that were using bundle 'admin' user The 'admin' user is replaced by a new random admin user in order to avoid the onboarding tutorial to be displayed --- diff --git a/it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java b/it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java index b0c86666fa9..6177ad28c3e 100644 --- a/it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java +++ b/it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java @@ -34,6 +34,7 @@ import org.sonarqube.ws.client.project.UpdateVisibilityRequest; import pageobjects.Navigation; import pageobjects.ProjectsManagementPage; import util.ItUtils; +import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; @@ -44,12 +45,18 @@ public class ProjectsAdministrationTest { @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); + private String adminUser; + @Before - public void deleteAnalysisData() throws SQLException { + public void initData() throws SQLException { orchestrator.resetData(); + adminUser = userRule.createAdminUser(); } @Test @@ -60,7 +67,7 @@ public class ProjectsAdministrationTest { // Remove 'Admin' permission for admin group on project 2 -> No one can access or admin this project, expect System Admin newAdminWsClient(orchestrator).permissions().removeGroup(new RemoveGroupWsRequest().setProjectKey("sample2").setGroupName("sonar-administrators").setPermission("admin")); - nav.logIn().asAdmin().openProjectsManagement() + nav.logIn().submitCredentials(adminUser).openProjectsManagement() .shouldHaveProject("sample1") .shouldHaveProject("sample2"); } @@ -76,7 +83,7 @@ public class ProjectsAdministrationTest { } private void createProjectAndVerify(String visibility) { - ProjectsManagementPage page = nav.logIn().asAdmin().openProjectsManagement(); + ProjectsManagementPage page = nav.logIn().submitCredentials(adminUser, adminUser).openProjectsManagement(); page .shouldHaveProjectsCount(0) .createProject("foo", "foo", visibility) diff --git a/it/it-tests/src/test/java/it/administration/UsersPageTest.java b/it/it-tests/src/test/java/it/administration/UsersPageTest.java index b5a7c12aff4..9779a6f82f9 100644 --- a/it/it-tests/src/test/java/it/administration/UsersPageTest.java +++ b/it/it-tests/src/test/java/it/administration/UsersPageTest.java @@ -22,6 +22,8 @@ package it.administration; import com.sonar.orchestrator.Orchestrator; import it.Category1Suite; import java.util.List; +import org.junit.After; +import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; @@ -37,6 +39,8 @@ import static util.ItUtils.newAdminWsClient; public class UsersPageTest { + private static final String ADMIN_USER_LOGIN = "admin-user"; + @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; @@ -45,6 +49,16 @@ public class UsersPageTest { private WsClient adminClient = newAdminWsClient(orchestrator); + @Before + public void initAdminUser() throws Exception { + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); + } + + @After + public void deleteAdminUser() { + userRule.resetUsers(); + } + @Test public void generate_and_revoke_user_token() { Selenese.runSelenese(orchestrator, "/administration/UsersPageTest/generate_and_revoke_user_token.html"); diff --git a/it/it-tests/src/test/java/it/issue/IssuesPageTest.java b/it/it-tests/src/test/java/it/issue/IssuesPageTest.java index fd28ef8a91a..feff031efb1 100644 --- a/it/it-tests/src/test/java/it/issue/IssuesPageTest.java +++ b/it/it-tests/src/test/java/it/issue/IssuesPageTest.java @@ -21,6 +21,7 @@ package it.issue; import com.sonar.orchestrator.Orchestrator; import it.Category2Suite; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -39,12 +40,14 @@ public class IssuesPageTest { @ClassRule public static Orchestrator ORCHESTRATOR = Category2Suite.ORCHESTRATOR; - @ClassRule - public static UserRule userRule = UserRule.from(ORCHESTRATOR); + @Rule + public UserRule userRule = UserRule.from(ORCHESTRATOR); @Rule public Navigation nav = Navigation.get(ORCHESTRATOR); + private String adminUser; + @BeforeClass public static void prepareData() { ORCHESTRATOR.resetData(); @@ -56,9 +59,14 @@ public class IssuesPageTest { runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample"); } + @Before + public void before() { + adminUser = userRule.createAdminUser(); + } + @Test public void should_display_actions() { - IssuesPage page = nav.logIn().asAdmin().openIssues(); + IssuesPage page = nav.logIn().submitCredentials(adminUser).openIssues(); Issue issue = page.getFirstIssue(); issue.shouldAllowAssign().shouldAllowChangeType(); } diff --git a/it/it-tests/src/test/java/it/issue/OrganizationIssueAssignTest.java b/it/it-tests/src/test/java/it/issue/OrganizationIssueAssignTest.java index 61a85920f72..ae0861dbbce 100644 --- a/it/it-tests/src/test/java/it/issue/OrganizationIssueAssignTest.java +++ b/it/it-tests/src/test/java/it/issue/OrganizationIssueAssignTest.java @@ -66,22 +66,23 @@ public class OrganizationIssueAssignTest { @ClassRule public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR; - @Rule public OrganizationRule organizations = new OrganizationRule(orchestrator); @Rule - public UserRule userRule = new UserRule(orchestrator); - @Rule - public IssueRule issueRule = IssueRule.from(orchestrator); + public UserRule userRule = UserRule.from(orchestrator); + @ClassRule + public static IssueRule issueRule = IssueRule.from(orchestrator); @Rule public Navigation nav = Navigation.get(orchestrator); private WsClient adminClient = newAdminWsClient(orchestrator); + private String adminUser; @Before public void setUp() throws Exception { createOrganization(ORGANIZATION_KEY); restoreProfile(orchestrator, getClass().getResource("/organization/IssueAssignTest/one-issue-per-file-profile.xml"), ORGANIZATION_KEY); + adminUser = userRule.createRootUser(); } @Test @@ -160,7 +161,7 @@ public class OrganizationIssueAssignTest { adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN); userRule.createUser(OTHER_LOGIN, "pwd"); provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY); - IssuesPage page = nav.logIn().asAdmin().openIssues(); + IssuesPage page = nav.logIn().submitCredentials(adminUser).openIssues(); page.getFirstIssue() .shouldAllowAssign() .assigneeSearchResultCount(OTHER_LOGIN, 0) @@ -174,7 +175,7 @@ public class OrganizationIssueAssignTest { 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); + IssuesPage page = nav.logIn().submitCredentials(adminUser).openComponentIssues(SAMPLE_PROJECT_KEY); page .bulkChangeOpen() .bulkChangeAssigneeSearchCount(ASSIGNEE_LOGIN, 1) @@ -188,7 +189,7 @@ public class OrganizationIssueAssignTest { adminClient.organizations().addMember(ORGANIZATION_KEY, ASSIGNEE_LOGIN); userRule.createUser(OTHER_LOGIN, "pwd"); provisionAndAnalyseProject(SAMPLE_PROJECT_KEY, ORGANIZATION_KEY); - IssuesPage page = nav.logIn().asAdmin().openIssues(); + IssuesPage page = nav.logIn().submitCredentials(adminUser).openIssues(); page .bulkChangeOpen() .bulkChangeAssigneeSearchCount(ASSIGNEE_LOGIN, 1) diff --git a/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java b/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java index 269acc7d9d3..cc3b24792ba 100644 --- a/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java +++ b/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java @@ -32,6 +32,7 @@ import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import pageobjects.Navigation; import pageobjects.ProjectDashboardPage; +import util.user.UserRule; import static com.codeborne.selenide.Condition.hasText; import static com.codeborne.selenide.Condition.text; @@ -40,18 +41,24 @@ import static util.ItUtils.projectDir; import static util.selenium.Selenese.runSelenese; public class ProjectDashboardTest { + @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); private static WsClient wsClient; + private String adminUser; @Before public void setUp() throws Exception { wsClient = newAdminWsClient(orchestrator); orchestrator.resetData(); + adminUser = userRule.createAdminUser(); } @Test @@ -79,8 +86,7 @@ public class ProjectDashboardTest { wsClient.wsConnector().call( new PostRequest("api/project_tags/set") .setParam("project", "sample") - .setParam("tags", "foo,bar,baz") - ); + .setParam("tags", "foo,bar,baz")); ProjectDashboardPage page = nav.openProjectDashboard("sample"); page @@ -93,13 +99,12 @@ public class ProjectDashboardTest { executeBuild("shared/xoo-sample", "sample-with-tags", "Sample with tags"); // Add some tags to another project to have them in the list wsClient.wsConnector().call( - new PostRequest("api/project_tags/set") - .setParam("project", "sample-with-tags") - .setParam("tags", "foo,bar,baz") - ); + new PostRequest("api/project_tags/set") + .setParam("project", "sample-with-tags") + .setParam("tags", "foo,bar,baz")); executeBuild("shared/xoo-sample", "sample", "Sample"); - ProjectDashboardPage page = nav.logIn().asAdmin().openProjectDashboard("sample"); + ProjectDashboardPage page = nav.logIn().submitCredentials(adminUser).openProjectDashboard("sample"); page .shouldHaveTags("No tags") .shouldBeEditable() @@ -129,8 +134,7 @@ public class ProjectDashboardTest { orchestrator.executeBuild( SonarScanner.create(projectDir(projectLocation)) .setProjectKey(projectKey) - .setProjectName(projectName) - ); + .setProjectName(projectName)); } } diff --git a/it/it-tests/src/test/java/it/measureHistory/DifferentialPeriodsTest.java b/it/it-tests/src/test/java/it/measureHistory/DifferentialPeriodsTest.java index 4ab4976304a..47bfede4f9a 100644 --- a/it/it-tests/src/test/java/it/measureHistory/DifferentialPeriodsTest.java +++ b/it/it-tests/src/test/java/it/measureHistory/DifferentialPeriodsTest.java @@ -26,10 +26,12 @@ 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.sonarqube.ws.client.WsClient; import pageobjects.Navigation; import util.ItUtils; +import util.user.UserRule; import static org.apache.commons.lang.time.DateUtils.addDays; import static org.assertj.core.api.Assertions.assertThat; @@ -51,6 +53,11 @@ public class DifferentialPeriodsTest { @ClassRule public static final Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + + private String adminUser; + @BeforeClass public static void createWsClient() throws Exception { CLIENT = newAdminWsClient(orchestrator); @@ -59,6 +66,7 @@ public class DifferentialPeriodsTest { @Before public void cleanUpAnalysisData() { orchestrator.resetData(); + adminUser = userRule.createAdminUser(); } @After @@ -93,7 +101,7 @@ public class DifferentialPeriodsTest { assertThat(getLeakPeriodValue(orchestrator, PROJECT_KEY, "violations")).isEqualTo(17); // Check on ui that it's possible to define leak period on project - Navigation.get(orchestrator).openHomepage().logIn().asAdmin().openSettings("sample") + Navigation.get(orchestrator).openHomepage().logIn().submitCredentials(adminUser).openSettings("sample") .assertSettingDisplayed("sonar.leak.period"); } diff --git a/it/it-tests/src/test/java/it/organization/BillingTest.java b/it/it-tests/src/test/java/it/organization/BillingTest.java index 5396a836c39..d43510e5e80 100644 --- a/it/it-tests/src/test/java/it/organization/BillingTest.java +++ b/it/it-tests/src/test/java/it/organization/BillingTest.java @@ -73,6 +73,7 @@ public class BillingTest { public Navigation nav = Navigation.get(orchestrator); private static WsClient adminClient; + private String adminUser; @BeforeClass public static void prepare() { @@ -85,6 +86,11 @@ public class BillingTest { resetSettings(orchestrator, null, PROPERTY_PREVENT_ANALYSIS, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate"); } + @Before + public void createAdminUser() throws Exception { + adminUser = userRule.createRootUser(); + } + @Test public void execute_successfully_ce_analysis_on_organization() { String organizationKey = createOrganization(); @@ -217,7 +223,7 @@ public class BillingTest { String projectKey = createPublicProject(createOrganization()); setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true"); - nav.logIn().asAdmin().openProjectPermissions(projectKey) + nav.logIn().submitCredentials(adminUser).openProjectPermissions(projectKey) .shouldBePublic() .shouldNotAllowPrivate(); } @@ -227,12 +233,12 @@ public class BillingTest { String projectKey = createPublicProject(createOrganization()); setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false"); - nav.logIn().asAdmin().openProjectPermissions(projectKey) + nav.logIn().submitCredentials(adminUser).openProjectPermissions(projectKey) .shouldBePublic() .turnToPrivate(); } - private static String createOrganization() { + private String createOrganization() { String key = newOrganizationKey(); adminClient.organizations().create(new CreateWsRequest.Builder().setKey(key).setName(key).build()).getOrganization(); return key; @@ -244,16 +250,16 @@ public class BillingTest { return projectKey; } - private static String executeAnalysis(String organizationKey) { + private String executeAnalysis(String organizationKey) { return executeAnalysis(newProjectKey(), organizationKey); } - private static String executeAnalysis(String projectKey, String organizationKey) { + private String executeAnalysis(String projectKey, String organizationKey) { BuildResult buildResult = orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"), "sonar.organization", organizationKey, "sonar.projectKey", projectKey, - "sonar.login", "admin", - "sonar.password", "admin")); + "sonar.login", adminUser, + "sonar.password", adminUser)); return ItUtils.extractCeTaskId(buildResult); } diff --git a/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java b/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java index a8f151e48b4..19dd64ec7fd 100644 --- a/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java +++ b/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java @@ -35,6 +35,7 @@ import org.sonarqube.ws.WsUsers.CreateWsResponse.User; import org.sonarqube.ws.client.HttpException; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.permission.AddUserWsRequest; +import pageobjects.Navigation; import util.OrganizationRule; import util.user.UserRule; @@ -46,20 +47,22 @@ public class OrganizationMembershipTest { private static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR; private static OrganizationRule organizations = new OrganizationRule(orchestrator); private static UserRule users = new UserRule(orchestrator); + private static Navigation nav = Navigation.get(orchestrator); @ClassRule public static TestRule chain = RuleChain.outerRule(orchestrator) .around(users) - .around(organizations); + .around(organizations) + .around(nav); @Rule public ExpectedException expectedException = ExpectedException.none(); - private static WsClient rootWsClient; + private static WsClient adminClient; @BeforeClass public static void setUp() { - rootWsClient = newAdminWsClient(orchestrator); + adminClient = newAdminWsClient(orchestrator); setServerProperty(orchestrator, "sonar.organizations.anyoneCanCreate", "true"); } @@ -92,7 +95,7 @@ public class OrganizationMembershipTest { User user = users.createUser(); addMembership(organization, user); - rootWsClient.permissions().addUser(new AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin").setOrganization(organization.getKey())); + adminClient.permissions().addUser(new AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin").setOrganization(organization.getKey())); organizations.assertThatMemberOf(organization, user); removeMembership(organization, user); @@ -105,10 +108,10 @@ public class OrganizationMembershipTest { User user = users.createUser(); addMembership(organization, user); - rootWsClient.permissions().addUser(new AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin").setOrganization(organization.getKey())); + adminClient.permissions().addUser(new AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin").setOrganization(organization.getKey())); organizations.assertThatMemberOf(organization, user); // Admin is the creator of the organization so he was granted with admin permission - rootWsClient.organizations().removeMember(organization.getKey(), "admin"); + adminClient.organizations().removeMember(organization.getKey(), "admin"); expectedException.expect(HttpException.class); expectedException.expectMessage("The last administrator member cannot be removed"); @@ -136,10 +139,10 @@ public class OrganizationMembershipTest { } private void addMembership(Organization organization, User user) { - rootWsClient.organizations().addMember(organization.getKey(), user.getLogin()); + adminClient.organizations().addMember(organization.getKey(), user.getLogin()); } private void removeMembership(Organization organization, User user) { - rootWsClient.organizations().removeMember(organization.getKey(), user.getLogin()); + adminClient.organizations().removeMember(organization.getKey(), user.getLogin()); } } diff --git a/it/it-tests/src/test/java/it/organization/OrganizationMembershipUiTest.java b/it/it-tests/src/test/java/it/organization/OrganizationMembershipUiTest.java index a03327d743b..702475a3b23 100644 --- a/it/it-tests/src/test/java/it/organization/OrganizationMembershipUiTest.java +++ b/it/it-tests/src/test/java/it/organization/OrganizationMembershipUiTest.java @@ -22,7 +22,9 @@ package it.organization; import com.sonar.orchestrator.Orchestrator; 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.Rule; @@ -55,6 +57,7 @@ public class OrganizationMembershipUiTest { public Navigation nav = Navigation.get(orchestrator); private static WsClient rootWsClient; + private String adminUser; @BeforeClass public static void setUp() { @@ -67,6 +70,17 @@ public class OrganizationMembershipUiTest { setServerProperty(orchestrator, "sonar.organizations.anyoneCanCreate", null); } + @Before + public void createRootUser() { + adminUser = users.createRootUser(); + } + + @After + public void purgeData() throws Exception { + organizations.deleteOrganizations(); + users.deactivateAllUsers(); + } + @Test public void should_display_members_page() { Organization organization = organizations.create(); @@ -74,7 +88,7 @@ public class OrganizationMembershipUiTest { addMembership(organization, member1); User member2 = users.createUser(p -> p.setName("bar")); addMembership(organization, member2); - User nonMember = users.createUser(); + users.createUser(); MembersPage page = nav.openOrganizationMembers(organization.getKey()); page @@ -91,53 +105,55 @@ public class OrganizationMembershipUiTest { @Test public void search_for_members() { Organization organization = organizations.create(); - User member1 = users.createUser(p -> p.setName("foo")); - addMembership(organization, member1); - User member2 = users.createUser(p -> p.setName("barGuy")); - addMembership(organization, member2); + + User user1 = users.createUser(); + rootWsClient.organizations().addMember(organization.getKey(), user1.getLogin()); + + User user2 = users.createUser(p -> p.setLogin("sameprefixuser1")); + rootWsClient.organizations().addMember(organization.getKey(), user2.getLogin()); + // Created to verify that only the user part of the org is returned - User userWithSameNamePrefix = users.createUser(p -> p.setName(member2.getName() + "barOtherGuy")); + users.createUser(p -> p.setLogin("sameprefixuser2")); MembersPage page = nav.openOrganizationMembers(organization.getKey()); page - .searchForMember("bar") + .searchForMember("sameprefixuser") .shouldHaveTotal(1); - page.getMembersByIdx(0) - .shouldBeNamed(member2.getLogin(), member2.getName()); + page.getMembersByIdx(0).shouldBeNamed(user2.getLogin(), user2.getName()); page - .searchForMember(member1.getName()) + .searchForMember(user1.getLogin()) .shouldHaveTotal(1); - page.getMembersByIdx(0) - .shouldBeNamed(member1.getLogin(), member1.getName()); + page.getMembersByIdx(0).shouldBeNamed(user1.getLogin(), user1.getName()); } @Test public void admin_can_add_members() { Organization organization = organizations.create(); - User user = users.createUser(); + String orgKey = organization.getKey(); + User user = users.createUser(p -> p.setLogin("foo")); + users.createUser(); - MembersPage page = nav.logIn().asAdmin().openOrganizationMembers(organization.getKey()); + MembersPage page = nav.logIn().submitCredentials(adminUser).openOrganizationMembers(orgKey); page .shouldHaveTotal(1) .addMember(user.getLogin()) .shouldHaveTotal(2); - page.getMembersByIdx(0) - .shouldBeNamed("admin", "Administrator") - .shouldHaveGroups(2); - page.getMembersByIdx(1) - .shouldBeNamed(user.getLogin(), user.getName()) - .shouldHaveGroups(1); + page.getMembersByIdx(0).shouldBeNamed("admin", "Administrator").shouldHaveGroups(2); + page.getMembersByIdx(1).shouldBeNamed(user.getLogin(), user.getName()).shouldHaveGroups(1); } @Test public void admin_can_remove_members() { Organization organization = organizations.create(); + String orgKey = organization.getKey(); + User user1 = users.createUser(); - addMembership(organization, user1); + rootWsClient.organizations().addMember(orgKey, user1.getLogin()); + User user2 = users.createUser(); - addMembership(organization, user2); + rootWsClient.organizations().addMember(orgKey, user2.getLogin()); - MembersPage page = nav.logIn().asAdmin().openOrganizationMembers(organization.getKey()); + MembersPage page = nav.logIn().submitCredentials(adminUser).openOrganizationMembers(orgKey); page.shouldHaveTotal(3) .getMembersByIdx(1).removeMembership(); page.shouldHaveTotal(2); @@ -146,10 +162,12 @@ public class OrganizationMembershipUiTest { @Test public void admin_can_manage_groups() { Organization organization = organizations.create(); - User user = users.createUser(); - addMembership(organization, user); + String orgKey = organization.getKey(); + + User user = users.createUser(p -> p.setLogin("foo")); + rootWsClient.organizations().addMember(orgKey, user.getLogin()); - MembersPage page = nav.logIn().asAdmin().openOrganizationMembers(organization.getKey()); + MembersPage page = nav.logIn().submitCredentials(adminUser).openOrganizationMembers(orgKey); // foo user page.getMembersByIdx(1) .manageGroupsOpen() @@ -167,9 +185,10 @@ public class OrganizationMembershipUiTest { @Test public void groups_count_should_be_updated_when_a_member_was_just_added() { Organization organization = organizations.create(); - User user = users.createUser(); + String orgKey = organization.getKey(); + User user = users.createUser(p -> p.setLogin("foo")); - MembersPage page = nav.logIn().asAdmin().openOrganizationMembers(organization.getKey()); + MembersPage page = nav.logIn().submitCredentials(adminUser).openOrganizationMembers(orgKey); page .addMember(user.getLogin()) .getMembersByIdx(1) diff --git a/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java b/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java index 0bc5a799134..4d5d8d0f41c 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java @@ -22,6 +22,8 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category1Suite; +import org.junit.After; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -29,6 +31,7 @@ import org.junit.Test; import pageobjects.BackgroundTaskItem; import pageobjects.BackgroundTasksPage; import pageobjects.Navigation; +import util.user.UserRule; import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan; import static util.ItUtils.projectDir; @@ -36,9 +39,14 @@ import static util.selenium.Selenese.runSelenese; public class BackgroundTasksTest { + private static final String ADMIN_USER_LOGIN = "admin-user"; + @ClassRule public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(ORCHESTRATOR); + @Rule public Navigation nav = Navigation.get(ORCHESTRATOR); @@ -48,15 +56,24 @@ public class BackgroundTasksTest { executeBuild("test-project-2", "Another Test Project"); } + @Before + public void before() { + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); + } + + @After + public void deleteAdminUser() { + userRule.resetUsers(); + } + @Test public void should_not_display_failing_and_search_and_filter_elements_on_project_level_page() throws Exception { - runSelenese(ORCHESTRATOR, - "/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html"); + runSelenese(ORCHESTRATOR, "/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html"); } @Test public void display_scanner_context() { - nav.logIn().submitCredentials("admin", "admin"); + nav.logIn().submitCredentials(ADMIN_USER_LOGIN); BackgroundTasksPage page = nav.openBackgroundTasksPage(); page.getTasks().shouldHave(sizeGreaterThan(0)); @@ -71,7 +88,7 @@ public class BackgroundTasksTest { public void display_error_stacktrace() { executeBuild("test-project", "Test Project", "2010-01-01"); - nav.logIn().submitCredentials("admin", "admin"); + nav.logIn().submitCredentials(ADMIN_USER_LOGIN); BackgroundTasksPage page = nav.openBackgroundTasksPage(); page.getTasks().shouldHave(sizeGreaterThan(0)); diff --git a/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java b/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java index cbcdc2e8095..602eeaab829 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java @@ -22,21 +22,35 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category1Suite; +import org.junit.After; import org.junit.Before; import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; +import util.user.UserRule; import static util.ItUtils.projectDir; import static util.selenium.Selenese.runSelenese; public class BulkDeletionTest { + private static final String ADMIN_USER_LOGIN = "admin-user"; + @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Before public void deleteData() { orchestrator.resetData(); + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); + } + + @After + public void deleteAdminUser() { + userRule.resetUsers(); } /** diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java index e8a26419dbb..16050604201 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java @@ -40,6 +40,7 @@ import org.sonar.wsclient.base.HttpException; import org.sonar.wsclient.user.UserParameters; import pageobjects.Navigation; import pageobjects.settings.SettingsPage; +import util.user.UserRule; import static org.apache.commons.lang.time.DateUtils.addDays; import static org.assertj.core.api.Assertions.assertThat; @@ -59,15 +60,20 @@ public class ProjectAdministrationTest { @Rule public ExpectedException expectedException = ExpectedException.none(); + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); private static final String PROJECT_KEY = "sample"; private static final String FILE_KEY = "sample:src/main/xoo/sample/Sample.xoo"; + private String adminUser; @Before public void deleteAnalysisData() throws SQLException { orchestrator.resetData(); + adminUser = userRule.createAdminUser(); } @Test @@ -163,7 +169,7 @@ public class ProjectAdministrationTest { public void display_project_settings() throws UnsupportedEncodingException { scanSample(null, null); - SettingsPage page = nav.logIn().asAdmin().openSettings("sample") + SettingsPage page = nav.logIn().submitCredentials(adminUser).openSettings("sample") .assertMenuContains("Analysis Scope") .assertMenuContains("Category 1") .assertMenuContains("DEV") @@ -186,7 +192,7 @@ public class ProjectAdministrationTest { public void display_module_settings() throws UnsupportedEncodingException { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-multi-modules-sample"))); - nav.logIn().asAdmin() + nav.logIn().submitCredentials(adminUser) .openSettings("com.sonarsource.it.samples:multi-modules-sample:module_a") .assertMenuContains("Analysis Scope") .assertSettingDisplayed("sonar.coverage.exclusions"); diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectLinksPageTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectLinksPageTest.java index 1929df4edea..f12ede6e94e 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectLinksPageTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectLinksPageTest.java @@ -37,6 +37,7 @@ import org.sonarqube.ws.client.projectlinks.DeleteWsRequest; import pageobjects.Navigation; import pageobjects.ProjectLinkItem; import pageobjects.ProjectLinksPage; +import util.user.UserRule; import static com.codeborne.selenide.Condition.hasText; import static com.codeborne.selenide.Selenide.$; @@ -51,8 +52,12 @@ public class ProjectLinksPageTest { @Rule public Navigation nav = Navigation.get(ORCHESTRATOR); + @Rule + public UserRule userRule = UserRule.from(ORCHESTRATOR); + private static WsClient wsClient; private long customLinkId; + private String adminUser; @BeforeClass public static void setUp() { @@ -67,6 +72,7 @@ public class ProjectLinksPageTest { @Before public void prepare() { customLinkId = Long.parseLong(createCustomLink().getLink().getId()); + adminUser = userRule.createAdminUser(); } @After @@ -147,7 +153,7 @@ public class ProjectLinksPageTest { } private ProjectLinksPage openPage() { - nav.logIn().submitCredentials("admin", "admin"); + nav.logIn().submitCredentials(adminUser, adminUser); return nav.openProjectLinks("sample"); } } diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java index 8df89782810..157d1f6ce5d 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java @@ -22,12 +22,14 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category1Suite; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import pageobjects.Navigation; import pageobjects.ProjectPermissionsPage; +import util.user.UserRule; import static util.ItUtils.projectDir; import static util.selenium.Selenese.runSelenese; @@ -37,8 +39,12 @@ public class ProjectPermissionsTest { @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); + private String adminUser; @BeforeClass public static void beforeClass() { @@ -46,6 +52,11 @@ public class ProjectPermissionsTest { executeBuild("project-permissions-project-2", "Another Test Project"); } + @Before + public void before() { + adminUser = userRule.createAdminUser(); + } + @Test public void test_project_permissions_page_shows_only_single_project() throws Exception { runSelenese(orchestrator, "/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html"); @@ -53,7 +64,7 @@ public class ProjectPermissionsTest { @Test public void change_project_visibility() { - ProjectPermissionsPage page = nav.logIn().asAdmin().openProjectPermissions("project-permissions-project"); + ProjectPermissionsPage page = nav.logIn().submitCredentials(adminUser).openProjectPermissions("project-permissions-project"); page .shouldBePublic() .turnToPrivate() diff --git a/it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java b/it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java index c664fa9725e..59944ac9fe0 100644 --- a/it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java +++ b/it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java @@ -30,6 +30,7 @@ import org.junit.Test; import pageobjects.Navigation; import pageobjects.ProjectActivityPage; import pageobjects.ProjectAnalysisItem; +import util.user.UserRule; import static util.ItUtils.projectDir; @@ -38,6 +39,9 @@ public class ProjectActivityPageTest { @ClassRule public static Orchestrator ORCHESTRATOR = Category4Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(ORCHESTRATOR); + @Rule public Navigation nav = Navigation.get(ORCHESTRATOR); @@ -81,7 +85,8 @@ public class ProjectActivityPageTest { } private ProjectActivityPage openPage() { - nav.logIn().submitCredentials("admin", "admin"); + String userAdmin = userRule.createAdminUser(); + nav.logIn().submitCredentials(userAdmin, userAdmin); return nav.openProjectActivity("sample"); } diff --git a/it/it-tests/src/test/java/it/projectSearch/LeakProjectsPageTest.java b/it/it-tests/src/test/java/it/projectSearch/LeakProjectsPageTest.java index cfa30558bcb..779ccb4da2c 100644 --- a/it/it-tests/src/test/java/it/projectSearch/LeakProjectsPageTest.java +++ b/it/it-tests/src/test/java/it/projectSearch/LeakProjectsPageTest.java @@ -86,7 +86,7 @@ public class LeakProjectsPageTest { analyzeProject(projectKey1, "shared/xoo-sample", null); // Check the facets and project cards - ProjectsPage page = nav.logIn().asAdmin().openProjects(organization.getKey()); + ProjectsPage page = nav.openProjects(organization.getKey()); page.changePerspective("Leak"); assertThat(url()).endsWith("/projects?view=leak"); page.shouldHaveTotal(2); diff --git a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java index 610d9ba0eb0..a3c9b0f9793 100644 --- a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java +++ b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java @@ -22,6 +22,7 @@ package it.projectSearch; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category1Suite; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -30,10 +31,11 @@ import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import pageobjects.Navigation; import pageobjects.projects.ProjectsPage; +import util.user.UserRule; import static com.codeborne.selenide.WebDriverRunner.url; import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.newAdminWsClient; +import static util.ItUtils.newUserWsClient; import static util.ItUtils.projectDir; public class ProjectsPageTest { @@ -41,20 +43,29 @@ public class ProjectsPageTest { @ClassRule public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(ORCHESTRATOR); + @Rule public Navigation nav = Navigation.get(ORCHESTRATOR); - private static WsClient wsClient; private static final String PROJECT_KEY = "key-foo"; + private WsClient userAdminWsClient; + private String adminUser; @BeforeClass public static void setUp() { - wsClient = newAdminWsClient(ORCHESTRATOR); ORCHESTRATOR.resetData(); ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProjectKey(PROJECT_KEY)); ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("duplications/file-duplications")).setProjectKey("key-bar")); } + @Before + public void before() { + adminUser = userRule.createAdminUser(); + userAdminWsClient = newUserWsClient(ORCHESTRATOR, adminUser, adminUser); + } + @Test public void should_display_projects() { ProjectsPage page = nav.openProjects(); @@ -97,16 +108,16 @@ public class ProjectsPageTest { page.shouldHaveTotal(2).shouldDisplayAllProjectsWidthSort("-analysis_date"); // all projects by default for logged in user - page = nav.logIn().asAdmin().openProjects(); + page = nav.logIn().submitCredentials(adminUser).openProjects(); page.shouldHaveTotal(2).shouldDisplayAllProjects(); // favorite one project - wsClient.favorites().add(PROJECT_KEY); + userAdminWsClient.favorites().add(PROJECT_KEY); page = nav.openProjects(); page.shouldHaveTotal(1).shouldDisplayFavoriteProjects(); // un-favorite this project - wsClient.favorites().remove(PROJECT_KEY); + userAdminWsClient.favorites().remove(PROJECT_KEY); page = nav.openProjects(); page.shouldHaveTotal(2).shouldDisplayAllProjects(); @@ -132,11 +143,10 @@ public class ProjectsPageTest { @Test public void should_add_tag_to_facet() { // Add some tags to this project - wsClient.wsConnector().call( + userAdminWsClient.wsConnector().call( new PostRequest("api/project_tags/set") .setParam("project", PROJECT_KEY) - .setParam("tags", "aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,zz") - ); + .setParam("tags", "aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,zz")); ProjectsPage page = nav.openProjects(); page.getFacetByProperty("tags") @@ -148,7 +158,7 @@ public class ProjectsPageTest { @Test public void should_switch_between_perspectives() { - ProjectsPage page = nav.logIn().asAdmin().openProjects(); + ProjectsPage page = nav.logIn().submitCredentials(adminUser).openProjects(); page.changePerspective("Risk"); assertThat(url()).endsWith("/projects?view=visualizations&visualization=risk"); page.changePerspective("Leak"); diff --git a/it/it-tests/src/test/java/it/qualityProfile/OrganizationQualityProfilesUiTest.java b/it/it-tests/src/test/java/it/qualityProfile/OrganizationQualityProfilesUiTest.java index f3eb040aebe..6b0d23c1c54 100644 --- a/it/it-tests/src/test/java/it/qualityProfile/OrganizationQualityProfilesUiTest.java +++ b/it/it-tests/src/test/java/it/qualityProfile/OrganizationQualityProfilesUiTest.java @@ -32,9 +32,9 @@ import org.junit.Test; import org.sonarqube.ws.Organizations; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.organization.CreateWsRequest; import pageobjects.Navigation; import util.OrganizationRule; +import util.user.UserRule; import static com.codeborne.selenide.Selenide.$; import static util.ItUtils.newAdminWsClient; @@ -43,20 +43,24 @@ import static util.selenium.Selenese.runSelenese; public class OrganizationQualityProfilesUiTest { + private final static String ROOT_USER = "root-user"; + private static WsClient adminWsClient; @ClassRule public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR; - @Rule public OrganizationRule organizationRule = new OrganizationRule(orchestrator); + @Rule + public UserRule userRule = UserRule.from(orchestrator); private static Organizations.Organization organization; @Before public void setUp() { adminWsClient = newAdminWsClient(orchestrator); - organization = adminWsClient.organizations().create(new CreateWsRequest.Builder().setKey("test-org").setName("test-org").build()).getOrganization(); + organization = organizationRule.create(o -> o.setKey("test-org").setName("test-org")); + userRule.createRootUser(ROOT_USER, ROOT_USER); } @Before diff --git a/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesUiTest.java b/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesUiTest.java index b0406584fa3..a4b14866186 100644 --- a/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesUiTest.java +++ b/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesUiTest.java @@ -28,10 +28,12 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import pageobjects.Navigation; +import util.user.UserRule; import static com.codeborne.selenide.Selenide.$; import static util.ItUtils.newAdminWsClient; @@ -40,8 +42,14 @@ import static util.selenium.Selenese.runSelenese; public class QualityProfilesUiTest { + private static final String ADMIN_USER_LOGIN = "admin-user"; + @ClassRule public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; + + @Rule + public UserRule userRule = UserRule.from(orchestrator); + private static WsClient adminWsClient; @BeforeClass @@ -50,6 +58,16 @@ public class QualityProfilesUiTest { orchestrator.resetData(); } + @Before + public void initAdminUser() throws Exception { + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); + } + + @After + public void deleteAdminUser() { + userRule.resetUsers(); + } + @Before public void createSampleProfile() { createProfile("xoo", "sample"); diff --git a/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java b/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java index 6e4ae6eadae..4433a9a3908 100644 --- a/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java +++ b/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java @@ -29,7 +29,10 @@ import okhttp3.Response; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.json.simple.JSONValue; +import org.junit.After; +import org.junit.Before; import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.MediaTypes; import org.sonarqube.ws.ServerId.ShowWsResponse; @@ -39,6 +42,7 @@ import org.sonarqube.ws.client.WsResponse; import pageobjects.Navigation; import pageobjects.ServerIdPage; import util.ItUtils; +import util.user.UserRule; import static org.apache.commons.lang.StringUtils.startsWithAny; import static org.assertj.core.api.Assertions.assertThat; @@ -50,9 +54,24 @@ import static util.selenium.Selenese.runSelenese; public class ServerSystemTest { + private static final String ADMIN_USER_LOGIN = "admin-user"; + @ClassRule public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + + @Before + public void initAdminUser() { + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); + } + + @After + public void deleteAdminUser() { + userRule.resetUsers(); + } + @Test public void get_sonarqube_version() { Map json = callStatus(); @@ -71,7 +90,7 @@ public class ServerSystemTest { @Test public void generate_server_id() throws IOException { - Navigation nav = Navigation.get(orchestrator).openHomepage().logIn().asAdmin(); + Navigation nav = Navigation.get(orchestrator).openHomepage().logIn().submitCredentials(ADMIN_USER_LOGIN); String validIpAddress = getValidIpAddress(); nav.openServerId() diff --git a/it/it-tests/src/test/java/it/settings/LicensesPageTest.java b/it/it-tests/src/test/java/it/settings/LicensesPageTest.java index aed51ee04d1..f9779f3465e 100644 --- a/it/it-tests/src/test/java/it/settings/LicensesPageTest.java +++ b/it/it-tests/src/test/java/it/settings/LicensesPageTest.java @@ -21,6 +21,7 @@ package it.settings; import com.sonar.orchestrator.Orchestrator; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -30,6 +31,7 @@ import org.sonarqube.ws.client.setting.ValuesRequest; import pageobjects.Navigation; import pageobjects.licenses.LicenseItem; import pageobjects.licenses.LicensesPage; +import util.user.UserRule; import static com.codeborne.selenide.Condition.text; import static org.assertj.core.api.Assertions.assertThat; @@ -40,8 +42,12 @@ public class LicensesPageTest { private static Orchestrator orchestrator; private static WsClient wsClient; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); + private String adminUser; @BeforeClass public static void start() { @@ -60,9 +66,14 @@ public class LicensesPageTest { } } + @Before + public void before() { + adminUser = userRule.createAdminUser(); + } + @Test public void display_licenses() { - LicensesPage page = nav.logIn().asAdmin().openLicenses(); + LicensesPage page = nav.logIn().submitCredentials(adminUser).openLicenses(); page.getLicenses().shouldHaveSize(2); page.getLicensesAsItems().get(0).getName().shouldHave(text("Typed property")); @@ -73,7 +84,7 @@ public class LicensesPageTest { public void change_licenses() { String EXAMPLE_LICENSE = "TmFtZTogRGV2ZWxvcHBlcnMKUGx1Z2luOiBhdXRvY29udHJvbApFeHBpcmVzOiAyMDEyLTA0LTAxCktleTogNjI5N2MxMzEwYzg2NDZiZTE5MDU1MWE4ZmZmYzk1OTBmYzEyYTIyMgo="; - LicensesPage page = nav.logIn().asAdmin().openLicenses(); + LicensesPage page = nav.logIn().submitCredentials(adminUser).openLicenses(); LicenseItem licenseItem = page.getLicenseByKey("typed.license.secured"); licenseItem.setLicense(EXAMPLE_LICENSE); diff --git a/it/it-tests/src/test/java/it/settings/PropertySetsTest.java b/it/it-tests/src/test/java/it/settings/PropertySetsTest.java index a7dbfa2729e..2372f42073a 100644 --- a/it/it-tests/src/test/java/it/settings/PropertySetsTest.java +++ b/it/it-tests/src/test/java/it/settings/PropertySetsTest.java @@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException; import java.util.List; import java.util.Map; import org.junit.After; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -35,6 +36,7 @@ import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.setting.ValuesRequest; import pageobjects.Navigation; import pageobjects.settings.SettingsPage; +import util.user.UserRule; import static com.google.common.collect.Lists.newArrayList; import static java.util.Arrays.asList; @@ -48,16 +50,25 @@ public class PropertySetsTest { @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); static SettingsService SETTINGS; + private String adminUser; @BeforeClass public static void initSettingsService() throws Exception { SETTINGS = newAdminWsClient(orchestrator).settingsService(); } + @Before + public void before() { + adminUser = userRule.createAdminUser(); + } + @After public void reset_settings() throws Exception { resetSettings(orchestrator, null, "sonar.demo", "sonar.autogenerated", "sonar.test.jira.servers"); @@ -65,7 +76,7 @@ public class PropertySetsTest { @Test public void support_property_sets() throws UnsupportedEncodingException { - SettingsPage page = nav.logIn().asAdmin().openSettings(null).openCategory("DEV") + SettingsPage page = nav.logIn().submitCredentials(adminUser).openSettings(null).openCategory("DEV") .assertSettingDisplayed("sonar.test.jira.servers"); page.getPropertySetInput("sonar.test.jira.servers") @@ -82,7 +93,7 @@ public class PropertySetsTest { @Test public void support_property_sets_with_auto_generated_keys() throws UnsupportedEncodingException { - SettingsPage page = nav.logIn().asAdmin().openSettings(null).openCategory("DEV") + SettingsPage page = nav.logIn().submitCredentials(adminUser).openSettings(null).openCategory("DEV") .assertSettingDisplayed("sonar.autogenerated"); page.getPropertySetInput("sonar.autogenerated") diff --git a/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java b/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java index 62a98f154d5..a38ba2f3eac 100644 --- a/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java +++ b/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java @@ -29,6 +29,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import pageobjects.EncryptionPage; import pageobjects.Navigation; +import util.user.UserRule; import static com.codeborne.selenide.Condition.visible; import static org.assertj.core.api.Assertions.assertThat; @@ -41,14 +42,17 @@ import static util.ItUtils.xooPlugin; */ public class SettingsTestRestartingOrchestrator { - Orchestrator orchestrator; - @Rule public ExpectedException thrown = ExpectedException.none(); + private Orchestrator orchestrator; + + private UserRule userRule; + @After public void stop() { if (orchestrator != null) { + userRule.resetUsers(); orchestrator.stop(); } } @@ -61,9 +65,10 @@ public class SettingsTestRestartingOrchestrator { .addPlugin(pluginArtifact("license-plugin")) .setServerProperty("sonar.secretKeyPath", secretKeyUrl.getFile()) .build(); - orchestrator.start(); + startOrchestrator(); - Navigation nav = Navigation.get(orchestrator).openHomepage().logIn().asAdmin(); + String adminUser = userRule.createAdminUser(); + Navigation nav = Navigation.get(orchestrator).openHomepage().logIn().submitCredentials(adminUser); nav.openSettings(null) .assertMenuContains("General") @@ -86,7 +91,7 @@ public class SettingsTestRestartingOrchestrator { .addPlugin(xooPlugin()) .setServerProperty("sonar.deprecatedKey", "true") .build(); - orchestrator.start(); + startOrchestrator(); SonarScanner withDeprecatedKey = SonarScanner.create(projectDir("shared/xoo-sample")) .setProperty("sonar.deprecatedKey", "true"); @@ -95,10 +100,16 @@ public class SettingsTestRestartingOrchestrator { // should not fail orchestrator.executeBuilds(withDeprecatedKey, withNewKey); - Navigation.get(orchestrator).openHomepage().logIn().asAdmin().openSettings(null) + String adminUser = userRule.createAdminUser(); + Navigation.get(orchestrator).openHomepage().logIn().submitCredentials(adminUser).openSettings(null) .assertMenuContains("General") .assertSettingDisplayed("sonar.newKey") .assertSettingNotDisplayed("sonar.deprecatedKey"); } + private void startOrchestrator() { + orchestrator.start(); + userRule = UserRule.from(orchestrator); + } + } diff --git a/it/it-tests/src/test/java/it/uiExtension/OrganizationUiExtensionsTest.java b/it/it-tests/src/test/java/it/uiExtension/OrganizationUiExtensionsTest.java index 7e1e8610130..c7a93d19575 100644 --- a/it/it-tests/src/test/java/it/uiExtension/OrganizationUiExtensionsTest.java +++ b/it/it-tests/src/test/java/it/uiExtension/OrganizationUiExtensionsTest.java @@ -22,6 +22,7 @@ package it.uiExtension; import com.codeborne.selenide.Condition; import com.sonar.orchestrator.Orchestrator; import it.Category6Suite; +import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; @@ -31,6 +32,7 @@ import org.openqa.selenium.By; import org.sonarqube.ws.Organizations.Organization; import pageobjects.Navigation; import util.OrganizationRule; +import util.user.UserRule; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Selenide.$; @@ -41,14 +43,23 @@ public class OrganizationUiExtensionsTest { private static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR; private static OrganizationRule organizations = new OrganizationRule(orchestrator); + private static UserRule userRule = UserRule.from(orchestrator); @ClassRule public static TestRule chain = RuleChain.outerRule(orchestrator) - .around(organizations); + .around(organizations) + .around(userRule); @Rule public Navigation nav = Navigation.get(orchestrator); + private String adminUser; + + @Before + public void before() { + adminUser = userRule.createRootUser(); + } + @Test public void organization_page() { Organization organization = organizations.create(); @@ -64,7 +75,7 @@ public class OrganizationUiExtensionsTest { @Test public void organization_admin_page() { Organization organization = organizations.create(); - nav.logIn().asAdmin().open("/organizations/" + organization.getKey() + "/projects"); + nav.logIn().submitCredentials(adminUser).open("/organizations/" + organization.getKey() + "/projects"); $("#context-navigation a.navbar-admin-link").click(); $(By.linkText("Organization Admin Page")).shouldBe(Condition.visible).click(); diff --git a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java index 867f8d75afe..16905e08ef6 100644 --- a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java +++ b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java @@ -22,12 +22,14 @@ package it.uiExtension; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category4Suite; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.openqa.selenium.By; import pageobjects.Navigation; +import util.user.UserRule; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Selenide.$; @@ -41,8 +43,12 @@ public class UiExtensionsTest { @ClassRule public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); + private String adminUser; @BeforeClass public static void setUp() throws Exception { @@ -50,6 +56,11 @@ public class UiExtensionsTest { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); } + @Before + public void before() { + adminUser = userRule.createAdminUser(); + } + @Test public void test_static_files() { runSelenese(orchestrator, "/uiExtension/UiExtensionsTest/static-files.html"); @@ -69,7 +80,7 @@ public class UiExtensionsTest { @Test public void global_admin_page() { - nav.logIn().asAdmin().open("/about"); + nav.logIn().submitCredentials(adminUser).open("/about"); $(".navbar-admin-link").click(); $("#settings-navigation-configuration").click(); @@ -92,7 +103,7 @@ public class UiExtensionsTest { @Test public void project_admin_page() { - nav.logIn().asAdmin().open("/dashboard?id=sample"); + nav.logIn().submitCredentials(adminUser).open("/dashboard?id=sample"); $("#component-navigation-admin").click(); $(By.linkText("Project Admin Page")).click(); diff --git a/it/it-tests/src/test/java/it/user/ForceAuthenticationTest.java b/it/it-tests/src/test/java/it/user/ForceAuthenticationTest.java index 8c86213b527..a69dd90d679 100644 --- a/it/it-tests/src/test/java/it/user/ForceAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/ForceAuthenticationTest.java @@ -22,7 +22,7 @@ package it.user; import com.sonar.orchestrator.Orchestrator; import it.Category4Suite; import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; @@ -39,6 +39,7 @@ import static org.sonarqube.ws.client.WsRequest.Method.GET; import static org.sonarqube.ws.client.WsRequest.Method.POST; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.newWsClient; +import static util.ItUtils.resetSettings; import static util.ItUtils.setServerProperty; public class ForceAuthenticationTest { @@ -48,17 +49,17 @@ public class ForceAuthenticationTest { @ClassRule public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; - @ClassRule - public static UserRule userRule = UserRule.from(orchestrator); + @Rule + public UserRule userRule = UserRule.from(orchestrator); @Rule public Navigation nav = Navigation.get(orchestrator); - static WsClient anonymousClient; - static WsClient adminWsClient; + private static WsClient anonymousClient; + private static WsClient adminWsClient; - @BeforeClass - public static void setUp() throws Exception { + @Before + public void setUp() throws Exception { userRule.resetUsers(); userRule.createUser(LOGIN, LOGIN); setServerProperty(orchestrator, "sonar.forceAuthentication", "true"); @@ -68,7 +69,7 @@ public class ForceAuthenticationTest { @AfterClass public static void tearDown() throws Exception { - setServerProperty(orchestrator, "sonar.forceAuthentication", null); + resetSettings(orchestrator, null, "sonar.forceAuthentication"); } @Test @@ -111,9 +112,10 @@ public class ForceAuthenticationTest { @Test public void redirect_to_login_page() { + String userAdmin = userRule.createAdminUser(); Navigation page = nav.openHomepage(); page.shouldBeRedirectToLogin(); - page.openLogin().submitCredentials("admin", "admin").shouldBeLoggedIn(); + page.openLogin().submitCredentials(userAdmin, userAdmin).shouldBeLoggedIn(); page.logOut().shouldBeRedirectToLogin(); } diff --git a/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java b/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java index b0825c67179..b3f31f9d0cb 100644 --- a/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java @@ -24,8 +24,7 @@ import com.sonar.orchestrator.Orchestrator; import it.Category4Suite; import java.util.UUID; import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; @@ -36,9 +35,7 @@ import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.permission.AddGroupWsRequest; import org.sonarqube.ws.client.permission.AddUserWsRequest; -import org.sonarqube.ws.client.permission.RemoveGroupWsRequest; import org.sonarqube.ws.client.usertoken.GenerateWsRequest; import org.sonarqube.ws.client.usertoken.RevokeWsRequest; import org.sonarqube.ws.client.usertoken.SearchWsRequest; @@ -56,11 +53,15 @@ import static util.selenium.Selenese.runSelenese; public class LocalAuthenticationTest { + private static final String ADMIN_USER_LOGIN = "admin-user"; + + private static final String LOGIN = "george.orwell"; + @ClassRule public static Orchestrator ORCHESTRATOR = Category4Suite.ORCHESTRATOR; - @ClassRule - public static UserRule userRule = UserRule.from(ORCHESTRATOR); + @Rule + public UserRule userRule = UserRule.from(ORCHESTRATOR); @Rule public Navigation nav = Navigation.get(ORCHESTRATOR); @@ -69,12 +70,8 @@ public class LocalAuthenticationTest { private static UserTokensService userTokensWsClient; - private static final String LOGIN = "george.orwell"; - - @BeforeClass - public static void setUp() { - ORCHESTRATOR.resetData(); - + @Before + public void setUp() { adminWsClient = newAdminWsClient(ORCHESTRATOR); userTokensWsClient = adminWsClient.userTokens(); @@ -83,10 +80,11 @@ public class LocalAuthenticationTest { addUserPermission(LOGIN, "admin"); userRule.createUser("simple-user", "password"); + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); } - @AfterClass - public static void deleteAndRestoreData() { + @After + public void deleteAndRestoreData() { userRule.resetUsers(); } @@ -246,15 +244,4 @@ public class LocalAuthenticationTest { .setPermission(permission)); } - private static void removeGroupPermission(String groupName, String permission) { - adminWsClient.permissions().removeGroup(new RemoveGroupWsRequest() - .setGroupName(groupName) - .setPermission(permission)); - } - - private static void addGroupPermission(String groupName, String permission) { - adminWsClient.permissions().addGroup(new AddGroupWsRequest() - .setGroupName(groupName) - .setPermission(permission)); - } } diff --git a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java index d6736902c77..5b3ac57ffcc 100644 --- a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java +++ b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java @@ -31,6 +31,7 @@ import org.junit.Test; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import pageobjects.Navigation; +import util.user.UserRule; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Condition.visible; @@ -45,8 +46,12 @@ public class MyAccountPageTest { public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; private static WsClient adminWsClient; + @Rule + public UserRule userRule = UserRule.from(orchestrator); + @Rule public Navigation nav = Navigation.get(orchestrator); + private String adminUser; @BeforeClass public static void setUp() { @@ -55,6 +60,7 @@ public class MyAccountPageTest { @Before public void initUser() { + adminUser = userRule.createAdminUser(); createUser("account-user", "User With Account", "user@example.com"); } @@ -101,7 +107,7 @@ public class MyAccountPageTest { @Test public void notifications() { - nav.logIn().asAdmin().openNotifications() + nav.logIn().submitCredentials(adminUser).openNotifications() .addGlobalNotification("ChangesOnMyIssue") .addGlobalNotification("NewIssues") .removeGlobalNotification("ChangesOnMyIssue"); diff --git a/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java b/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java index 656fb1a6f42..bb8fb26b857 100644 --- a/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java @@ -49,6 +49,7 @@ import static org.junit.Assert.fail; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.newUserWsClient; import static util.ItUtils.pluginArtifact; +import static util.ItUtils.resetSettings; import static util.ItUtils.setServerProperty; import static util.selenium.Selenese.runSelenese; @@ -59,12 +60,13 @@ import static util.selenium.Selenese.runSelenese; */ public class RealmAuthenticationTest { + private static final String TECH_USER = "techUser"; + private static final String USER_LOGIN = "tester"; + private static final String ADMIN_USER_LOGIN = "admin-user"; + @Rule public ExpectedException thrown = ExpectedException.none(); - static final String TECH_USER = "techUser"; - static final String USER_LOGIN = "tester"; - /** * Property from security-plugin for user management. */ @@ -76,15 +78,23 @@ public class RealmAuthenticationTest { .setServerProperty("sonar.security.realm", "FakeRealm") .build(); - @ClassRule - public static UserRule USER_RULE = UserRule.from(orchestrator); + @Rule + public UserRule userRule = UserRule.from(orchestrator); @Before @After public void resetData() throws Exception { - setServerProperty(orchestrator, USERS_PROPERTY, null); - setServerProperty(orchestrator, "sonar.security.updateUserAttributes", null); - USER_RULE.resetUsers(); + resetSettings(orchestrator, null, USERS_PROPERTY, "sonar.security.updateUserAttributes"); + } + + @Before + public void initAdminUser() throws Exception { + userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN); + } + + @After + public void deleteAdminUser() { + userRule.resetUsers(); } /** @@ -312,7 +322,7 @@ public class RealmAuthenticationTest { USER_LOGIN + ".email", "tester@example.org")); verifyAuthenticationIsOk(USER_LOGIN, "123"); - assertThat(USER_RULE.getUserByLogin(USER_LOGIN).get()) + assertThat(userRule.getUserByLogin(USER_LOGIN).get()) .extracting(Users.User::isLocal, Users.User::getExternalIdentity, Users.User::getExternalProvider) .containsOnly(false, USER_LOGIN, "sonarqube"); } diff --git a/it/it-tests/src/test/java/pageobjects/LoginPage.java b/it/it-tests/src/test/java/pageobjects/LoginPage.java index f9afa6a289b..88585279333 100644 --- a/it/it-tests/src/test/java/pageobjects/LoginPage.java +++ b/it/it-tests/src/test/java/pageobjects/LoginPage.java @@ -32,12 +32,12 @@ public class LoginPage { $("#login_form").should(Condition.exist); } - public Navigation submitCredentials(String login, String password) { - return submitCredentials(login, password, Navigation.class); + public Navigation submitCredentials(String login) { + return submitCredentials(login, login, Navigation.class); } - public Navigation asAdmin() { - return submitCredentials("admin", "admin"); + public Navigation submitCredentials(String login, String password) { + return submitCredentials(login, password, Navigation.class); } public Navigation useOAuth2() { diff --git a/it/it-tests/src/test/java/util/user/UserRule.java b/it/it-tests/src/test/java/util/user/UserRule.java index 370bb7892da..de0bce71faa 100644 --- a/it/it-tests/src/test/java/util/user/UserRule.java +++ b/it/it-tests/src/test/java/util/user/UserRule.java @@ -36,6 +36,7 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsResponse; +import org.sonarqube.ws.client.permission.AddUserWsRequest; import org.sonarqube.ws.client.user.CreateRequest; import org.sonarqube.ws.client.user.SearchRequest; import org.sonarqube.ws.client.user.UsersService; @@ -44,6 +45,7 @@ import util.selenium.Consumer; import static java.util.Arrays.asList; import static java.util.Arrays.stream; import static java.util.Objects.requireNonNull; +import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.guava.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; @@ -137,6 +139,35 @@ public class UserRule extends ExternalResource implements GroupManagement { return user; } + /** + * Create a new admin user with random login, having password same as login + */ + public String createAdminUser() { + String login = randomAlphabetic(10).toLowerCase(); + return createAdminUser(login, login); + } + + public String createAdminUser(String login, String password) { + createUser(login, password); + adminWsClient.permissions().addUser(new AddUserWsRequest().setLogin(login).setPermission("admin")); + adminWsClient.userGroups().addUser(org.sonarqube.ws.client.usergroup.AddUserWsRequest.builder().setLogin(login).setName("sonar-administrators").build()); + return login; + } + + /** + * Create a new root user with random login, having password same as login + */ + public String createRootUser() { + String login = randomAlphabetic(10).toLowerCase(); + return createRootUser(login, login); + } + + public String createRootUser(String login, String password) { + createUser(login, password); + setRoot(login); + return login; + } + public void setRoot(String login) { adminWsClient().rootService().setRoot(login); } diff --git a/it/it-tests/src/test/resources/administration/UsersPageTest/admin_should_change_its_own_password.html b/it/it-tests/src/test/resources/administration/UsersPageTest/admin_should_change_its_own_password.html index f7b84ad9f73..06e806cf259 100644 --- a/it/it-tests/src/test/resources/administration/UsersPageTest/admin_should_change_its_own_password.html +++ b/it/it-tests/src/test/resources/administration/UsersPageTest/admin_should_change_its_own_password.html @@ -27,12 +27,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait @@ -51,12 +51,12 @@ waitForElementPresent - css=[data-login=admin] + css=[data-login=admin-user] click - css=[data-login=admin] .js-user-change-password + css=[data-login=admin-user] .js-user-change-password @@ -67,17 +67,17 @@ type id=change-user-password-old-password - admin + admin-user type id=change-user-password-password - admin + new-admin-user type id=change-user-password-password-confirmation - admin + new-admin-user click diff --git a/it/it-tests/src/test/resources/administration/UsersPageTest/generate_and_revoke_user_token.html b/it/it-tests/src/test/resources/administration/UsersPageTest/generate_and_revoke_user_token.html index f0d1c67e06a..c81949c4d10 100644 --- a/it/it-tests/src/test/resources/administration/UsersPageTest/generate_and_revoke_user_token.html +++ b/it/it-tests/src/test/resources/administration/UsersPageTest/generate_and_revoke_user_token.html @@ -27,12 +27,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_create.html b/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_create.html index a94ad28f14d..0e67e0f4fab 100644 --- a/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_create.html +++ b/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_create.html @@ -9,91 +9,91 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/permission_templates
waitForElementPresentcss=.page-actions button
clickcss=.page-actions button
waitForElementPresentcss=#permission-template-name
typecss=#permission-template-nameCustom
typecss=#permission-template-descriptionDescription
typecss=#permission-template-project-key-pattern.*
clickcss=#permission-template-submit
waitForElementPresentcss=tr[data-name="Custom"]
assertTextcss=tr[data-name="Custom"] .js-name*Custom*
assertTextcss=tr[data-name="Custom"] .js-description*Description*
assertTextcss=tr[data-name="Custom"] .js-project-key-pattern*.*
open/sessions/logout
open/sessions/new
typepasswordroot-user
typeloginroot-user
clickAndWaitname=commit
open/permission_templates
waitForElementPresentcss=.page-actions button
clickcss=.page-actions button
waitForElementPresentcss=#permission-template-name
typecss=#permission-template-nameCustom
typecss=#permission-template-descriptionDescription
typecss=#permission-template-project-key-pattern.*
clickcss=#permission-template-submit
waitForElementPresentcss=tr[data-name="Custom"]
assertTextcss=tr[data-name="Custom"] .js-name*Custom*
assertTextcss=tr[data-name="Custom"] .js-description*Description*
assertTextcss=tr[data-name="Custom"] .js-project-key-pattern*.*
diff --git a/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_manage_project_creators.html b/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_manage_project_creators.html index c10e672f476..3d1c172a783 100644 --- a/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_manage_project_creators.html +++ b/it/it-tests/src/test/resources/authorisation/PermissionTemplatesPageTest/should_manage_project_creators.html @@ -9,101 +9,101 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/permission_templates
waitForElementPresentcss=td[data-permission="user"]
clickcss=td[data-permission="user"] .js-update-users
waitForElementPresentcss=#grant-to-project-creators
assertElementPresentcss=#grant-to-project-creators:not(:checked)
clickcss=#grant-to-project-creators
clickcss=.js-modal-close
waitForElementPresentcss=td[data-permission="user"] .js-project-creators
clickcss=td[data-permission="user"] .js-update-users
waitForElementPresentcss=#grant-to-project-creators
assertElementPresentcss=#grant-to-project-creators:checked
clickcss=#grant-to-project-creators
clickcss=.js-modal-close
waitForElementNotPresentcss=td[data-permission="user"] .js-project-creators
open/sessions/logout
open/sessions/new
typepasswordadmin-user
typeloginadmin-user
clickAndWaitname=commit
open/permission_templates
waitForElementPresentcss=td[data-permission="user"]
clickcss=td[data-permission="user"] .js-update-users
waitForElementPresentcss=#grant-to-project-creators
assertElementPresentcss=#grant-to-project-creators:not(:checked)
clickcss=#grant-to-project-creators
clickcss=.js-modal-close
waitForElementPresentcss=td[data-permission="user"] .js-project-creators
clickcss=td[data-permission="user"] .js-update-users
waitForElementPresentcss=#grant-to-project-creators
assertElementPresentcss=#grant-to-project-creators:checked
clickcss=#grant-to-project-creators
clickcss=.js-modal-close
waitForElementNotPresentcss=td[data-permission="user"] .js-project-creators
diff --git a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_copy.html b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_copy.html index 05481cc6417..88d01cd0da4 100644 --- a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_copy.html +++ b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_copy.html @@ -27,12 +27,12 @@ type password - admin + root-user type login - admin + root-user clickAndWait diff --git a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_create.html b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_create.html index 0e81c2ae583..41fae4ae338 100644 --- a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_create.html +++ b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_create.html @@ -27,12 +27,12 @@ type password - admin + root-user type login - admin + root-user clickAndWait diff --git a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_delete.html b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_delete.html index 0b6f9725b82..4f3a2793d29 100644 --- a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_delete.html +++ b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_delete.html @@ -27,12 +27,12 @@ type password - admin + root-user type login - admin + root-user clickAndWait diff --git a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_rename.html b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_rename.html index 84c26bcc183..3ae2ebd71d2 100644 --- a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_rename.html +++ b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_rename.html @@ -27,12 +27,12 @@ type password - admin + root-user type login - admin + root-user clickAndWait diff --git a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_restore.html b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_restore.html index e122c3f0318..807f14a50c6 100644 --- a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_restore.html +++ b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_restore.html @@ -27,12 +27,12 @@ type password - admin + root-user type login - admin + root-user clickAndWait diff --git a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_set_default.html b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_set_default.html index 6560ffa196d..d770d855393 100644 --- a/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_set_default.html +++ b/it/it-tests/src/test/resources/organization/OrganizationQualityProfilesUiTest/should_set_default.html @@ -27,12 +27,12 @@ type password - admin + root-user type login - admin + root-user clickAndWait diff --git a/it/it-tests/src/test/resources/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html b/it/it-tests/src/test/resources/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html index 375340060e7..e28cdbba827 100644 --- a/it/it-tests/src/test/resources/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html +++ b/it/it-tests/src/test/resources/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html @@ -27,12 +27,12 @@ type login - admin + admin-user type password - admin + admin-user click diff --git a/it/it-tests/src/test/resources/projectAdministration/BulkDeletionTest/bulk-delete-filter-projects.html b/it/it-tests/src/test/resources/projectAdministration/BulkDeletionTest/bulk-delete-filter-projects.html index 3752d35ee36..b6256e49b35 100644 --- a/it/it-tests/src/test/resources/projectAdministration/BulkDeletionTest/bulk-delete-filter-projects.html +++ b/it/it-tests/src/test/resources/projectAdministration/BulkDeletionTest/bulk-delete-filter-projects.html @@ -21,12 +21,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html b/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html index f27fd03f598..f336f7e93b9 100644 --- a/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html +++ b/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html @@ -26,12 +26,12 @@ type login - admin + admin-user type password - admin + admin-user click diff --git a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_copy.html b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_copy.html index c177580ffe1..ada80dbf6b3 100644 --- a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_copy.html +++ b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_copy.html @@ -27,12 +27,12 @@ type password - admin + admin-user type login - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_create.html b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_create.html index 0506fd2d2a5..61c550aec53 100644 --- a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_create.html +++ b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_create.html @@ -27,12 +27,12 @@ type password - admin + admin-user type login - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_delete.html b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_delete.html index 15bc4d429d3..6574ed04017 100644 --- a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_delete.html +++ b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_delete.html @@ -27,12 +27,12 @@ type password - admin + admin-user type login - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_rename.html b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_rename.html index ddeb8dabdc7..609e4871865 100644 --- a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_rename.html +++ b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_rename.html @@ -27,12 +27,12 @@ type password - admin + admin-user type login - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_restore.html b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_restore.html index ff6510a9c86..a1d952d31dc 100644 --- a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_restore.html +++ b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_restore.html @@ -27,12 +27,12 @@ type password - admin + admin-user type login - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_set_default.html b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_set_default.html index b2051f7c727..1a6425b6462 100644 --- a/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_set_default.html +++ b/it/it-tests/src/test/resources/qualityProfile/QualityProfilesUiTest/should_set_default.html @@ -27,12 +27,12 @@ type password - admin + admin-user type login - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/serverSystem/ServerSystemTest/system_info.html b/it/it-tests/src/test/resources/serverSystem/ServerSystemTest/system_info.html index eb9f7ea5cf1..e304586c59c 100644 --- a/it/it-tests/src/test/resources/serverSystem/ServerSystemTest/system_info.html +++ b/it/it-tests/src/test/resources/serverSystem/ServerSystemTest/system_info.html @@ -26,12 +26,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/user/ExternalAuthenticationTest/create-and-delete-user.html b/it/it-tests/src/test/resources/user/ExternalAuthenticationTest/create-and-delete-user.html index efdcbe2969e..f7d0dd6ffb6 100644 --- a/it/it-tests/src/test/resources/user/ExternalAuthenticationTest/create-and-delete-user.html +++ b/it/it-tests/src/test/resources/user/ExternalAuthenticationTest/create-and-delete-user.html @@ -21,12 +21,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/force-authentication.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/force-authentication.html index 96cd2485e47..4c5a751665d 100644 --- a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/force-authentication.html +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/force-authentication.html @@ -31,12 +31,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_successful.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_successful.html index af55b2bfe64..18da805f66b 100644 --- a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_successful.html +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_successful.html @@ -26,12 +26,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_wrong_password.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_wrong_password.html index 5b031cde7e4..dc66db8ee9b 100644 --- a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_wrong_password.html +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/login_wrong_password.html @@ -21,7 +21,7 @@ type login - admin + admin-user type diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html index 5dc242adcc4..c6519726f27 100644 --- a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html @@ -31,12 +31,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html index 41624fdd297..aecfd8af765 100644 --- a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html @@ -30,12 +30,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html index 0d9fbff40bb..5359e3308e0 100644 --- a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html @@ -40,12 +40,12 @@ type login - admin + admin-user type password - admin + admin-user clickAndWait