import com.google.common.collect.ImmutableList;
import java.util.Optional;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.GroupPermissionChange;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.PermissionChange;
import org.sonar.server.permission.PermissionService;
import org.sonar.server.permission.PermissionUpdater;
"<li>'Administer' rights on the specified project</li>" +
"</ul>")
.setSince("5.2")
+ .setChangelog(
+ new Change("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'name' instead."))
.setPost(true)
.setHandler(this);
"</ul>")
.addPagingParams(DEFAULT_PAGE_SIZE, RESULTS_MAX_SIZE)
.setChangelog(
+ new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
new Change("7.4", "The response list is returning all groups even those without permissions, the groups with permission are at the top of the list."))
.setResponseExample(Resources.getResource(getClass(), "groups-example.json"))
.setHandler(this);
package org.sonar.server.permission.ws;
import java.util.Optional;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.GroupPermissionChange;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.PermissionChange;
import org.sonar.server.permission.PermissionService;
import org.sonar.server.permission.PermissionUpdater;
"</ul>")
.setSince("5.2")
.setPost(true)
+ .setChangelog(
+ new Change("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."))
.setHandler(this);
wsParameters.createPermissionParameter(action);
import com.google.common.base.Joiner;
import org.sonar.api.server.ws.WebService;
import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.core.util.Uuids;
import org.sonar.server.permission.PermissionService;
+import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID;
this.permissionService = permissionService;
String allProjectsPermissionsOnOneLine = Joiner.on(", ").join(permissionService.getAllProjectPermissions());
permissionParamDescription = String.format("Permission" +
- "<ul>" +
- "<li>Possible values for global permissions: %s</li>" +
- "<li>Possible values for project permissions %s</li>" +
- "</ul>",
+ "<ul>" +
+ "<li>Possible values for global permissions: %s</li>" +
+ "<li>Possible values for project permissions %s</li>" +
+ "</ul>",
GlobalPermissions.ALL_ON_ONE_LINE,
allProjectsPermissionsOnOneLine);
projectPermissionParamDescription = String.format("Permission" +
- "<ul>" +
- "<li>Possible values for project permissions %s</li>" +
- "</ul>",
+ "<ul>" +
+ "<li>Possible values for project permissions %s</li>" +
+ "</ul>",
allProjectsPermissionsOnOneLine);
}
public static void createGroupIdParameter(WebService.NewAction action) {
action.createParam(PARAM_GROUP_ID)
- .setDescription("Group id")
- .setExampleValue("42");
+ .setDescription("Group id, use 'name' param instead")
+ .setDeprecatedSince("8.4")
+ .setExampleValue(UUID_EXAMPLE_01);
}
public static void createProjectParameters(WebService.NewAction action) {
public static void createTemplateParameters(WebService.NewAction action) {
action.createParam(PARAM_TEMPLATE_ID)
.setDescription("Template id")
- .setExampleValue(Uuids.UUID_EXAMPLE_01);
+ .setExampleValue(UUID_EXAMPLE_01);
createOrganizationParameter(action);
action.createParam(PARAM_TEMPLATE_NAME)
.setDescription("Template name")
*/
package org.sonar.server.permission.ws.template;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Add a group to a permission template.<br /> " +
"The group id or group name must be provided. <br />" +
"Requires the following permission: 'Administer System'.")
+ .setChangelog(
+ new Change("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."))
.setHandler(this);
createTemplateParameters(action);
*/
package org.sonar.server.permission.ws.template;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Remove a group from a permission template.<br /> " +
"The group id or group name must be provided. <br />" +
"Requires the following permission: 'Administer System'.")
+ .setChangelog(
+ new Change("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."))
.setHandler(this);
createTemplateParameters(action);
"permissions": []
},
{
- "id": "1",
+ "id": "AU-Tpxb--iU5OvuD2FLy",
"name": "sonar-administrators",
"description": "System administrators",
"permissions": []
},
{
- "id": "2",
+ "id": "AU-Tpxb--iU5OvuD2FLz",
"name": "sonar-users",
"description": "Any new users created will automatically join this group",
"permissions": []
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.api.web.UserRole;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.web.UserRole.CODEVIEWER;
import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
import static org.sonar.api.web.UserRole.USER;
return new AddGroupAction(db.getDbClient(), userSession, newPermissionUpdater(), newPermissionWsSupport(), wsParameters, permissionService);
}
+ @Test
+ public void verify_definition() {
+ Action wsDef = wsTester.getDef();
+
+ assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.since()).isEqualTo("5.2");
+ assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'name' instead."));
+ }
+
@Test
public void add_permission_to_group_referenced_by_its_name() {
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.security.DefaultGroups;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.component.ResourceTypesRule;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.server.ws.WebService.Param.PAGE;
import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
db.commit();
}
+ @Test
+ public void verify_definition() {
+ Action wsDef = wsTester.getDef();
+
+ assertThat(wsDef.isInternal()).isEqualTo(true);
+ assertThat(wsDef.since()).isEqualTo("5.2");
+ assertThat(wsDef.isPost()).isEqualTo(false);
+ assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder(
+ tuple("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
+ tuple("7.4", "The response list is returning all groups even those without permissions, the groups with permission are at the top of the list."));
+ }
+
@Test
public void search_for_groups_with_one_permission() {
loginAsAdmin(db.getDefaultOrganization());
.setParam(PARAM_PERMISSION, SCAN.getKey())
.execute()
.getInput();
- assertJson(json).isSimilarTo("{\n" +
- " \"paging\": {\n" +
- " \"pageIndex\": 1,\n" +
- " \"pageSize\": 20,\n" +
- " \"total\": 3\n" +
- " },\n" +
- " \"groups\": [\n" +
- " {\n" +
- " \"name\": \"Anyone\",\n" +
- " \"permissions\": [\n" +
- " \"scan\"\n" +
- " ]\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"group-1-name\",\n" +
- " \"description\": \"" + group1.getDescription() + "\",\n" +
- " \"permissions\": [\n" +
- " \"scan\"\n" +
- " ]\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"group-2-name\",\n" +
- " \"description\": \"" + group2.getDescription() + "\",\n" +
- " \"permissions\": [\n" +
- " \"scan\"\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- "}\n");
+ assertJson(json).isSimilarTo("{\n" +
+ " \"paging\": {\n" +
+ " \"pageIndex\": 1,\n" +
+ " \"pageSize\": 20,\n" +
+ " \"total\": 3\n" +
+ " },\n" +
+ " \"groups\": [\n" +
+ " {\n" +
+ " \"name\": \"Anyone\",\n" +
+ " \"permissions\": [\n" +
+ " \"scan\"\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"group-1-name\",\n" +
+ " \"description\": \"" + group1.getDescription() + "\",\n" +
+ " \"permissions\": [\n" +
+ " \"scan\"\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"group-2-name\",\n" +
+ " \"description\": \"" + group2.getDescription() + "\",\n" +
+ " \"permissions\": [\n" +
+ " \"scan\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ "}\n");
}
@Test
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.api.web.UserRole;
import org.sonar.core.util.Uuids;
import org.sonar.db.component.ComponentDto;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.web.UserRole.ADMIN;
import static org.sonar.api.web.UserRole.CODEVIEWER;
import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
return new RemoveGroupAction(db.getDbClient(), userSession, newPermissionUpdater(), newPermissionWsSupport(), wsParameters, permissionService);
}
+ @Test
+ public void verify_definition() {
+ Action wsDef = wsTester.getDef();
+
+ assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.since()).isEqualTo("5.2");
+ assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."));
+ }
+
@Test
public void remove_permission_using_group_name() {
db.users().insertPermissionOnGroup(aGroup, ADMINISTER);
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.api.web.UserRole;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.db.component.ResourceTypesRule;
import org.sonar.server.ws.TestRequest;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.security.DefaultGroups.ANYONE;
import static org.sonar.api.web.UserRole.ADMIN;
import static org.sonar.api.web.UserRole.CODEVIEWER;
group = db.users().insertGroup(db.getDefaultOrganization(), "group-name");
}
+ @Test
+ public void verify_definition() {
+ Action wsDef = wsTester.getDef();
+
+ assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.since()).isEqualTo("5.2");
+ assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."));
+ }
+
@Test
public void add_group_to_template() {
loginAsAdmin(db.getDefaultOrganization());
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.db.component.ResourceTypesRule;
import org.sonar.db.permission.PermissionQuery;
import org.sonar.server.ws.TestRequest;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.security.DefaultGroups.ANYONE;
import static org.sonar.api.web.UserRole.CODEVIEWER;
import static org.sonar.db.permission.OrganizationPermission.SCAN;
addGroupToTemplate(template, group.getUuid(), PERMISSION);
}
+ @Test
+ public void verify_definition() {
+ Action wsDef = wsTester.getDef();
+
+ assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.since()).isEqualTo("5.2");
+ assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."));
+ }
+
@Test
public void remove_group_from_template() {
newRequest(group.getName(), template.getUuid(), PERMISSION);