diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-02-03 16:40:08 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-02-03 16:43:32 +0100 |
commit | 7eb1385f692e3cc6edd85c18f3dad57f64f04a9f (patch) | |
tree | 9603a37a0919dbae260acd15948cdb263a0183a3 | |
parent | 972b5acb8aee5140a4f5b100fa8f1716c4b46ba9 (diff) | |
download | sonarqube-7eb1385f692e3cc6edd85c18f3dad57f64f04a9f.tar.gz sonarqube-7eb1385f692e3cc6edd85c18f3dad57f64f04a9f.zip |
SONAR-7266 Project admin can manage project permissions
2 files changed, 3 insertions, 15 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java index f0147087cf5..1c182c9faa6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java @@ -38,7 +38,6 @@ import org.sonarqube.ws.WsPermissions.SearchTemplatesWsResponse.TemplateIdQualif import org.sonarqube.ws.client.permission.SearchTemplatesWsRequest; import static org.sonar.api.utils.DateUtils.formatDateTime; -import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class SearchTemplatesAction implements PermissionsWsAction { @@ -61,7 +60,7 @@ public class SearchTemplatesAction implements PermissionsWsAction { public void define(WebService.NewController context) { context.createAction("search_templates") .setDescription("List permission templates.<br />" + - "It requires administration permissions to access.") + "It requires to be authenticated.") .setResponseExample(getClass().getResource("search_templates-example.json")) .setSince("5.2") .addSearchQuery("defau", "permission template names") @@ -70,7 +69,7 @@ public class SearchTemplatesAction implements PermissionsWsAction { @Override public void handle(Request wsRequest, Response wsResponse) throws Exception { - checkGlobalAdminUser(userSession); + userSession.checkLoggedIn(); SearchTemplatesWsResponse searchTemplatesWsResponse = doHandle(toSearchTemplatesWsRequest(wsRequest)); writeProtobuf(searchTemplatesWsResponse, wsRequest, wsResponse); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java index a7e464a533f..0bad77f9b99 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java @@ -34,14 +34,12 @@ import org.sonar.api.resources.ResourceType; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.permission.PermissionTemplateDto; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; -import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.i18n.I18nRule; import org.sonar.server.tester.UserSessionRule; @@ -53,7 +51,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; -import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_03; @@ -99,7 +96,7 @@ public class SearchTemplatesActionTest { ws = new WsActionTester(underTest); - userSession.login().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); + userSession.login(); } @Test @@ -175,14 +172,6 @@ public class SearchTemplatesActionTest { } @Test - public void fail_if_not_global_admin() { - expectedException.expect(ForbiddenException.class); - userSession.login().setGlobalPermissions(QUALITY_PROFILE_ADMIN); - - ws.newRequest().execute(); - } - - @Test public void display_all_project_permissions() { String result = newRequest(); |