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 {
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")
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
- checkGlobalAdminUser(userSession);
+ userSession.checkLoggedIn();
SearchTemplatesWsResponse searchTemplatesWsResponse = doHandle(toSearchTemplatesWsRequest(wsRequest));
writeProtobuf(searchTemplatesWsResponse, wsRequest, wsResponse);
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;
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;
ws = new WsActionTester(underTest);
- userSession.login().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+ userSession.login();
}
@Test
ws.newRequest().execute();
}
- @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();