.setHandler(this)
.setPost(true)
.setSince("5.2")
- .setChangelog(new Change("6.4", "It's no longer possible to add a user to the default group"));
+ .setChangelog(
+ new Change("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
defineGroupWsParameters(action);
defineLoginWsParameter(action);
*/
package org.sonar.server.usergroups.ws;
+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.NewAction;
.setHandler(this)
.setPost(true)
.setResponseExample(getClass().getResource("create-example.json"))
- .setSince("5.2");
+ .setSince("5.2")
+ .setChangelog(
+ new Change("8.4", "Field 'id' format in the response changes from integer to string."));
action.createParam(PARAM_ORGANIZATION_KEY)
.setDescription("Key of organization. If unset then default organization is used.")
*/
package org.sonar.server.usergroups.ws;
+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;
PARAM_GROUP_ID, PARAM_GROUP_NAME))
.setHandler(this)
.setSince("5.2")
- .setPost(true);
+ .setPost(true)
+ .setChangelog(
+ new Change("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
defineGroupWsParameters(action);
}
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Optional.ofNullable;
+import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.server.exceptions.BadRequestException.checkRequest;
import static org.sonar.server.exceptions.NotFoundException.checkFound;
import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
private static void defineGroupIdWsParameter(WebService.NewAction action) {
action.createParam(PARAM_GROUP_ID)
- .setDeprecatedSince("8.3")
- .setDescription("Group id")
- .setExampleValue("42");
+ .setDescription("Group id, use 'name' instead")
+ .setDeprecatedSince("8.4")
+ .setExampleValue(UUID_EXAMPLE_01);
}
private static void defineGroupNameWsParameter(WebService.NewAction action) {
*/
package org.sonar.server.usergroups.ws;
+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.NewAction;
PARAM_GROUP_ID, PARAM_GROUP_NAME))
.setHandler(this)
.setPost(true)
- .setSince("5.2");
+ .setSince("5.2")
+ .setChangelog(
+ new Change("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
defineGroupWsParameters(action);
defineLoginWsParameter(action);
import static org.sonar.api.utils.Paging.forPageIndex;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_ID;
import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_ORGANIZATION_KEY;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.UserGroups.Group;
.addPagingParams(100, MAX_LIMIT)
.addSearchQuery("sonar-users", "names")
.setChangelog(
+ new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
new Change("6.4", "Paging response fields moved to a Paging object"),
- new Change("6.4", "'default' response field has been added"),
- new Change("8.3", "field " + PARAM_GROUP_ID + "in the response is deprecated"));
+ new Change("6.4", "'default' response field has been added"));
action.createParam(PARAM_ORGANIZATION_KEY)
.setDescription("Key of organization. If not set then groups are searched in default organization.")
import static java.lang.String.format;
import static org.sonar.api.user.UserGroupValidation.GROUP_NAME_MAX_LENGTH;
+import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.server.exceptions.NotFoundException.checkFound;
import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
.setPost(true)
.setResponseExample(getClass().getResource("update.example.json"))
.setSince("5.2")
- .setChangelog(new Change("6.4", "The default group is no longer editable"));
+ .setChangelog(
+ new Change("8.4", "Parameter 'id' format changes from integer to string"),
+ new Change("6.4", "The default group is no longer editable"));
action.createParam(PARAM_GROUP_ID)
.setDescription("Identifier of the group.")
- .setExampleValue("42")
+ .setExampleValue(UUID_EXAMPLE_01)
.setRequired(true);
action.createParam(PARAM_GROUP_NAME)
package org.sonar.server.usergroups.ws;
import java.util.List;
+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.NewAction;
.setResponseExample(getClass().getResource("users-example.json"))
.addSelectionModeParam()
.addSearchQuery("freddy", "names", "logins")
- .addPagingParams(25);
+ .addPagingParams(25)
+ .setChangelog(
+ new Change("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
defineGroupWsParameters(action);
}
{
"group": {
- "id": "42",
+ "id": "AU-Tpxb--iU5OvuD2FLy",
"organization": "my-org",
"name": "some-product-bu",
"description": "Business Unit for Some Awesome Product",
},
"groups": [
{
- "id": 3,
+ "id": "AU-Tpxb--iU5OvuD2FLy",
"name": "users",
"description": "Users",
"membersCount": 17,
"default": true
},
{
- "id": 4,
+ "id": "AU-Tpxb--iU5OvuD2FLz",
"name": "administrators",
"description": "Administrators",
"membersCount": 2,
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.GroupDto;
import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
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.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_NAME;
private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private WsActionTester ws = new WsActionTester(new AddUserAction(db.getDbClient(), userSession, newGroupWsSupport()));
+ @Test
+ public void verify_definition() {
+ Action wsDef = ws.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 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
+ }
+
@Test
public void add_user_to_group_referenced_by_its_id() {
insertDefaultGroupOnDefaultOrganization();
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
public class CreateActionTest {
assertThat(action.isPost()).isTrue();
assertThat(action.responseExampleAsString()).isNotEmpty();
assertThat(action.params()).hasSize(3);
+ assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Field 'id' format in the response changes from integer to string."));
}
@Test
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
+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.DbTester;
import org.sonar.db.component.ComponentDbTester;
import org.sonar.server.ws.WsActionTester;
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.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_ID;
private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private WsActionTester ws = new WsActionTester(new DeleteAction(db.getDbClient(), userSession, newGroupWsSupport()));
+ @Test
+ public void verify_definition() {
+ Action wsDef = ws.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 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
+ }
+
@Test
public void response_has_no_content() {
addAdmin(db.getDefaultOrganization());
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
+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.DbTester;
import org.sonar.db.organization.OrganizationDto;
import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_NAME;
import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_LOGIN;
private WsActionTester ws = new WsActionTester(
new RemoveUserAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), defaultOrganizationProvider, new DefaultGroupFinder(db.getDbClient()))));
+ @Test
+ public void verify_definition() {
+ Action wsDef = ws.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 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
+ }
+
@Test
public void does_nothing_if_user_is_not_in_group() {
// keep an administrator
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
private WsActionTester ws = new WsActionTester(new SearchAction(db.getDbClient(), userSession, newGroupWsSupport(), new DefaultGroupFinder(db.getDbClient())));
-
@Test
public void define_search_action() {
WebService.Action action = ws.getDef();
assertThat(action.key()).isEqualTo("search");
assertThat(action.responseExampleAsString()).isNotEmpty();
assertThat(action.params()).hasSize(5);
+ assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
+ tuple("6.4", "Paging response fields moved to a Paging object"),
+ tuple("6.4", "'default' response field has been added"));
}
@Test
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.test.JsonAssert.assertJson;
private WsActionTester ws = new WsActionTester(
new UpdateAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), defaultOrganizationProvider, new DefaultGroupFinder(db.getDbClient()))));
+ @Test
+ public void verify_definition() {
+ Action wsDef = ws.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 'id' format changes from integer to string"),
+ tuple("6.4", "The default group is no longer editable"));
+ }
+
@Test
public void update_both_name_and_description() {
insertDefaultGroupOnDefaultOrganization();
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.sonar.api.server.ws.Change;
+import org.sonar.api.server.ws.WebService.Action;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.server.ws.WebService.SelectionMode;
import org.sonar.api.utils.System2;
import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.db.user.UserTesting.newUserDto;
import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_ID;
private WsActionTester ws = new WsActionTester(
new UsersAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), defaultOrganizationProvider, new DefaultGroupFinder(db.getDbClient()))));
+ @Test
+ public void verify_definition() {
+ Action wsDef = ws.getDef();
+
+ assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.since()).isEqualTo("5.2");
+ assertThat(wsDef.isPost()).isEqualTo(false);
+ assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
+ }
+
@Test
public void fail_if_unknown_group_uuid() {
loginAsAdminOnDefaultOrganization();