From: Simon Brandhof Date: Tue, 7 Feb 2017 14:53:03 +0000 (+0100) Subject: SONAR-8716 drop usages of UserSessionRule#setGlobalPermissions() X-Git-Tag: 6.3-RC1~118 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0aee578a114d5f3c2b5618eaceba0c651908bc02;p=sonarqube.git SONAR-8716 drop usages of UserSessionRule#setGlobalPermissions() --- diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java index 4be933ac23f..4decaa49146 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java @@ -88,7 +88,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -158,7 +158,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -194,7 +194,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -225,7 +225,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -272,7 +272,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -318,7 +318,7 @@ public class ProjectDataLoaderMediumTest { dbClient.organizationDao().insert(dbSession, organizationDto); // No snapshot attached on the project -> provisioned project ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -348,7 +348,7 @@ public class ProjectDataLoaderMediumTest { // No module properties ComponentDto subModule = ComponentTesting.newModuleDto(module); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, subModule); // Sub module properties @@ -386,7 +386,7 @@ public class ProjectDataLoaderMediumTest { dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(module.getId())); ComponentDto subModule = ComponentTesting.newModuleDto(module); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, subModule); // Sub module properties @@ -423,7 +423,7 @@ public class ProjectDataLoaderMediumTest { // No module property ComponentDto subModule = ComponentTesting.newModuleDto(module); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, subModule); // No sub module property @@ -458,7 +458,7 @@ public class ProjectDataLoaderMediumTest { dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId())); ComponentDto subModule = ComponentTesting.newModuleDto(module); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, subModule); // No sub module property @@ -474,8 +474,8 @@ public class ProjectDataLoaderMediumTest { } @Test - public void fail_when_no_browse_permission_and_no_scan_permission() { - userSessionRule.logIn("john").setGlobalPermissions(); + public void fail_when_no_browse_permission_nor_scan_permission() { + userSessionRule.logIn(); OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); @@ -527,7 +527,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -548,7 +548,7 @@ public class ProjectDataLoaderMediumTest { OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); dbClient.organizationDao().insert(dbSession, organizationDto); ComponentDto project = ComponentTesting.newProjectDto(organizationDto); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, project); addDefaultProfile(); @@ -586,7 +586,7 @@ public class ProjectDataLoaderMediumTest { tester.get(FileSourceDao.class).insert(newFileSourceDto(projectFile).setSrcHash("123456").setRevision("987654321")); ComponentDto module = ComponentTesting.newModuleDto(project); - userSessionRule.logIn("john").setGlobalPermissions(SCAN_EXECUTION); + userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid()); dbClient.componentDao().insert(dbSession, module); // File on module diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java index 74021169580..514c8e3fbef 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java @@ -42,7 +42,6 @@ import org.sonarqube.ws.WsProjectLinks.SearchWsResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; @@ -75,12 +74,11 @@ public class SearchActionTest { ComponentFinder componentFinder = new ComponentFinder(dbClient); underTest = new SearchAction(dbClient, userSession, componentFinder); ws = new WsActionTester(underTest); - - userSession.logIn("login").setGlobalPermissions(SYSTEM_ADMIN); } @Test public void example() { + logInAsRoot(); ComponentDto project = insertProject(); insertHomepageLink(project.uuid()); insertCustomLink(project.uuid()); @@ -94,6 +92,7 @@ public class SearchActionTest { @Test public void request_by_project_id() throws IOException { + logInAsRoot(); ComponentDto project = insertProject(); insertHomepageLink(project.uuid()); @@ -105,6 +104,7 @@ public class SearchActionTest { @Test public void request_by_project_key() throws IOException { + logInAsRoot(); ComponentDto project = insertProject(); insertHomepageLink(project.uuid()); @@ -116,6 +116,7 @@ public class SearchActionTest { @Test public void response_fields() throws IOException { + logInAsRoot(); ComponentDto project = insertProject(); ComponentLinkDto homepageLink = insertHomepageLink(project.uuid()); ComponentLinkDto customLink = insertCustomLink(project.uuid()); @@ -131,6 +132,7 @@ public class SearchActionTest { @Test public void several_projects() throws IOException { + logInAsRoot(); ComponentDto project1 = insertProject(); ComponentDto project2 = insertProject("another", "abcd"); ComponentLinkDto customLink1 = insertCustomLink(project1.uuid()); @@ -144,6 +146,7 @@ public class SearchActionTest { @Test public void request_does_not_fail_when_link_has_no_name() throws IOException { + logInAsRoot(); ComponentDto project = db.components().insertProject(); ComponentLinkDto foo = new ComponentLinkDto().setComponentUuid(project.uuid()).setHref("foo").setType("type"); insertLink(foo); @@ -153,6 +156,7 @@ public class SearchActionTest { @Test public void request_does_not_fail_when_link_has_no_type() throws IOException { + logInAsRoot(); ComponentDto project = db.components().insertProject(); ComponentLinkDto foo = new ComponentLinkDto().setComponentUuid(project.uuid()).setHref("foo").setName("name"); insertLink(foo); @@ -161,24 +165,18 @@ public class SearchActionTest { } @Test - public void global_admin() throws IOException { - userSession.logIn("login").setGlobalPermissions(SYSTEM_ADMIN); - checkItWorks(); - } - - @Test - public void project_admin() throws IOException { - userSession.logIn("login"); + public void project_administrator_can_search_for_links() throws IOException { ComponentDto project = insertProject(); - userSession.addProjectUuidPermissions(UserRole.ADMIN, project.uuid()); + userSession.logIn().addProjectUuidPermissions(UserRole.ADMIN, project.uuid()); + checkItWorks(project); } @Test - public void project_user() throws IOException { - userSession.logIn("login"); + public void project_user_can_search_for_links() throws IOException { ComponentDto project = insertProject(); - userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); + userSession.logIn().addProjectUuidPermissions(UserRole.USER, project.uuid()); + checkItWorks(project); } @@ -199,12 +197,13 @@ public class SearchActionTest { @Test public void fail_when_both_id_and_key_are_provided() { - insertProject(); + ComponentDto project = insertProject(); + logInAsRoot(); expectedException.expect(IllegalArgumentException.class); ws.newRequest() - .setParam(PARAM_PROJECT_KEY, PROJECT_KEY) - .setParam(PARAM_PROJECT_ID, PROJECT_UUID) + .setParam(PARAM_PROJECT_KEY, project.key()) + .setParam(PARAM_PROJECT_ID, project.uuid()) .execute(); } @@ -273,7 +272,7 @@ public class SearchActionTest { assertThat(response.getLinks(0).getName()).isEqualTo("Homepage"); } - private void checkItWorks() throws IOException { - checkItWorks(insertProject()); + private UserSessionRule logInAsRoot() { + return userSession.logIn().setRoot(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java index aedd5625bac..8f800eb8b4f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java @@ -32,7 +32,6 @@ import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.component.ComponentDbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; import org.sonar.db.metric.MetricDto; @@ -47,8 +46,6 @@ import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse; import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse.Status; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.core.permission.GlobalPermissions.PROVISIONING; -import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.SnapshotTesting.newAnalysis; import static org.sonar.db.measure.MeasureTesting.newMeasureDto; @@ -67,11 +64,10 @@ public class ProjectStatusActionTest { public UserSessionRule userSession = UserSessionRule.standalone(); @Rule public DbTester db = DbTester.create(System2.INSTANCE); - ComponentDbTester componentDb = new ComponentDbTester(db); - WsActionTester ws; - DbClient dbClient; - DbSession dbSession; + private WsActionTester ws; + private DbClient dbClient; + private DbSession dbSession; @Before public void setUp() { @@ -83,9 +79,9 @@ public class ProjectStatusActionTest { @Test public void json_example() throws IOException { - userSession.setGlobalPermissions(SYSTEM_ADMIN); + ComponentDto project = db.components().insertProject(db.organizations().insert()); + userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project) .setPeriodMode(1, "last_period") .setPeriodDate(1, 956789123456L) @@ -112,9 +108,7 @@ public class ProjectStatusActionTest { @Test public void return_status_by_project_id() throws IOException { - userSession.setGlobalPermissions(SYSTEM_ADMIN); - - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); + ComponentDto project = db.components().insertProject(db.organizations().insert()); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project) .setPeriodMode(1, "last_period") .setPeriodDate(1, 956789123456L) @@ -131,9 +125,10 @@ public class ProjectStatusActionTest { newMeasureDto(metric, project, snapshot) .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json")))); dbSession.commit(); + userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); String response = ws.newRequest() - .setParam(PARAM_PROJECT_ID, "project-uuid") + .setParam(PARAM_PROJECT_ID, project.uuid()) .execute().getInput(); assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json")); @@ -141,9 +136,7 @@ public class ProjectStatusActionTest { @Test public void return_status_by_project_key() throws IOException { - userSession.setGlobalPermissions(SYSTEM_ADMIN); - - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key")); + ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("project-key")); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project) .setPeriodMode(1, "last_period") .setPeriodDate(1, 956789123456L) @@ -160,6 +153,7 @@ public class ProjectStatusActionTest { newMeasureDto(metric, project, snapshot) .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json")))); dbSession.commit(); + userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); String response = ws.newRequest() .setParam(PARAM_PROJECT_KEY, "project-key") @@ -170,11 +164,10 @@ public class ProjectStatusActionTest { @Test public void return_undefined_status_if_measure_is_not_found() { - userSession.setGlobalPermissions(SYSTEM_ADMIN); - - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); + ComponentDto project = db.components().insertProject(db.organizations().insert()); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)); dbSession.commit(); + userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); ProjectStatusWsResponse result = call(snapshot.getUuid()); @@ -184,40 +177,38 @@ public class ProjectStatusActionTest { @Test public void return_undefined_status_if_snapshot_is_not_found() { - userSession.setGlobalPermissions(SYSTEM_ADMIN); - componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); + ComponentDto project = db.components().insertProject(db.organizations().insert()); + userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); - ProjectStatusWsResponse result = callByProjectUuid("project-uuid"); + ProjectStatusWsResponse result = callByProjectUuid(project.uuid()); assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE); assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0); } @Test - public void not_fail_with_project_admin_permission() { - userSession.addProjectUuidPermissions(UserRole.ADMIN, "project-uuid"); - - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); + public void project_administrator_is_allowed_to_get_project_status() { + ComponentDto project = db.components().insertProject(db.organizations().insert()); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)); dbSession.commit(); + userSession.addProjectUuidPermissions(UserRole.ADMIN, project.uuid()); call(snapshot.getUuid()); } @Test - public void not_fail_with_browse_permission() { - userSession.addProjectUuidPermissions(UserRole.USER, "project-uuid"); - - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); + public void project_user_is_allowed_to_get_project_status() { + ComponentDto project = db.components().insertProject(db.organizations().insert()); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)); dbSession.commit(); + userSession.addProjectUuidPermissions(UserRole.USER, project.uuid()); call(snapshot.getUuid()); } @Test public void fail_if_no_snapshot_id_found() { - userSession.setGlobalPermissions(SYSTEM_ADMIN); + userSession.logIn().setRoot(); expectedException.expect(NotFoundException.class); expectedException.expectMessage("Analysis with id 'task-uuid' is not found"); @@ -227,18 +218,20 @@ public class ProjectStatusActionTest { @Test public void fail_if_insufficient_privileges() { - userSession.setGlobalPermissions(PROVISIONING); - - ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); + ComponentDto project = db.components().insertProject(db.organizations().insert()); SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)); dbSession.commit(); + userSession.logIn(); expectedException.expect(ForbiddenException.class); + call(snapshot.getUuid()); } @Test public void fail_if_project_id_and_ce_task_id_provided() { + userSession.logIn().setRoot(); + expectedException.expect(BadRequestException.class); expectedException.expectMessage("One (and only one) of the following parameters must be provided 'analysisId', 'projectId', 'projectKey'"); @@ -250,6 +243,8 @@ public class ProjectStatusActionTest { @Test public void fail_if_no_parameter_provided() { + userSession.logIn().setRoot(); + expectedException.expect(BadRequestException.class); expectedException.expectMessage("One (and only one) of the following parameters must be provided 'analysisId', 'projectId', 'projectKey'"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java index 03d32fd8712..422544813b3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java @@ -38,7 +38,6 @@ import org.sonar.server.ws.WsActionTester; import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.core.permission.GlobalPermissions.QUALITY_GATE_ADMIN; -import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN; import static org.sonar.server.qualitygate.QualityGates.SONAR_QUALITYGATE_PROPERTY; public class SelectActionTest { @@ -164,7 +163,7 @@ public class SelectActionTest { public void fail_when_not_quality_gates_admin() throws Exception { String gateId = String.valueOf(gate.getId()); - userSession.logIn().setGlobalPermissions(QUALITY_PROFILE_ADMIN); + userSession.logIn(); expectedException.expect(ForbiddenException.class); callByKey(gateId, project.getKey()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java index bd53d42e820..7b58db290d7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java @@ -65,7 +65,6 @@ import static org.mockito.Mockito.when; import static org.sonar.api.measures.CoreMetrics.QUALITY_PROFILES_KEY; import static org.sonar.api.web.page.Page.Scope.COMPONENT; import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN; -import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.component.ComponentTesting.newDirectory; import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newModuleDto; @@ -331,10 +330,10 @@ public class ComponentActionTest { } @Test - public void work_with_only_system_admin() throws Exception { + public void project_administrator_is_allowed_to_get_information() throws Exception { init(createPages()); componentDbTester.insertProjectAndSnapshot(project); - userSessionRule.setGlobalPermissions(SYSTEM_ADMIN); + userSessionRule.addProjectUuidPermissions(UserRole.ADMIN, project.uuid()); execute(project.key()); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java index 2710029bca4..9691696dc56 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java @@ -30,7 +30,6 @@ import org.sonar.api.resources.ResourceTypeTree; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.web.page.Page; import org.sonar.api.web.page.PageDefinition; -import org.sonar.core.permission.GlobalPermissions; import org.sonar.core.platform.PluginRepository; import org.sonar.db.Database; import org.sonar.db.dialect.H2; @@ -107,26 +106,10 @@ public class GlobalActionTest { } @Test - public void return_global_pages_for_anonymous() throws Exception { + public void the_returned_global_pages_do_not_include_administration_pages() throws Exception { init(createPages(), new ResourceTypeTree[] {}); - executeAndVerify("global_pages_for_anonymous.json"); - } - - @Test - public void return_global_pages_for_user() throws Exception { - init(createPages(), new ResourceTypeTree[] {}); - userSessionRule.logIn("obiwan"); - - executeAndVerify("global_pages_for_user.json"); - } - - @Test - public void return_global_pages_for_admin_user() throws Exception { - init(createPages(), new ResourceTypeTree[] {}); - userSessionRule.logIn("obiwan").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); - - executeAndVerify("global_pages_for_admin.json"); + executeAndVerify("global_pages.json"); } @Test diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json new file mode 100644 index 00000000000..014d6a56615 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json @@ -0,0 +1,12 @@ +{ + "globalPages": [ + { + "key": "another_plugin/page", + "name": "My Another Page" + }, + { + "key": "my_plugin/page", + "name": "My Plugin Page" + } + ] +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_admin.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_admin.json deleted file mode 100644 index 014d6a56615..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_admin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globalPages": [ - { - "key": "another_plugin/page", - "name": "My Another Page" - }, - { - "key": "my_plugin/page", - "name": "My Plugin Page" - } - ] -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_anonymous.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_anonymous.json deleted file mode 100644 index 014d6a56615..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_anonymous.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globalPages": [ - { - "key": "another_plugin/page", - "name": "My Another Page" - }, - { - "key": "my_plugin/page", - "name": "My Plugin Page" - } - ] -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_user.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_user.json deleted file mode 100644 index 014d6a56615..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages_for_user.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globalPages": [ - { - "key": "another_plugin/page", - "name": "My Another Page" - }, - { - "key": "my_plugin/page", - "name": "My Plugin Page" - } - ] -}