import org.sonarqube.ws.UserGroups;
import org.sonarqube.ws.Users;
import org.sonarqube.ws.Users.GroupsWsResponse.Group;
-import org.sonarqube.ws.client.user.GroupsRequest;
import org.sonarqube.ws.client.usergroups.AddUserRequest;
import org.sonarqube.ws.client.usergroups.CreateRequest;
+import org.sonarqube.ws.client.users.GroupsRequest;
import static java.util.Arrays.stream;
import static org.assertj.core.api.Assertions.assertThat;
}
public List<Group> getGroupsOfUser(@Nullable Organizations.Organization organization, String userLogin) {
- GroupsRequest request = GroupsRequest.builder()
+ GroupsRequest request = new GroupsRequest()
.setOrganization(organization != null ? organization.getKey() : null)
- .setLogin(userLogin)
- .build();
+ .setLogin(userLogin);
Users.GroupsWsResponse response = session.users().service().groups(request);
return response.getGroupsList();
}
import org.sonarqube.ws.client.organizations.OrganizationsService;
import org.sonarqube.ws.client.organizations.SearchMembersRequest;
import org.sonarqube.ws.client.organizations.SearchRequest;
-import org.sonarqube.ws.client.user.GroupsRequest;
+import org.sonarqube.ws.client.users.GroupsRequest;
import static java.util.Arrays.stream;
}
private void verifyMembersGroupMembership(String userLogin, @Nullable Organizations.Organization organization, boolean isMember) {
- List<Users.GroupsWsResponse.Group> groups = session.wsClient().users().groups(GroupsRequest.builder()
+ List<Users.GroupsWsResponse.Group> groups = session.wsClient().users().groups(new GroupsRequest()
.setLogin(userLogin)
.setOrganization(organization != null ? organization.getKey() : null)
- .setQuery("Members")
- .setSelected("selected")
- .build())
+ .setQ("Members")
+ .setSelected("selected"))
.getGroupsList();
Assertions.assertThat(groups).hasSize(isMember ? 1 : 0);
}
import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.organizations.AddMemberRequest;
-import org.sonarqube.ws.client.user.CreateRequest;
-import org.sonarqube.ws.client.user.SearchRequest;
-import org.sonarqube.ws.client.user.UsersService;
import org.sonarqube.ws.client.usergroups.AddUserRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
+import org.sonarqube.ws.client.users.UsersService;
import static java.util.Arrays.stream;
}
void deleteAll() {
- session.wsClient().users().search(SearchRequest.builder().build()).getUsersList()
+ session.wsClient().users().search(new SearchRequest()).getUsersList()
.stream()
.filter(u -> !"admin".equals(u.getLogin()))
.forEach(u -> {
}
@SafeVarargs
- public final User generate(Consumer<CreateRequest.Builder>... populators) {
+ public final User generate(Consumer<CreateRequest>... populators) {
int id = ID_GENERATOR.getAndIncrement();
String login = "login" + id;
- CreateRequest.Builder request = CreateRequest.builder()
+ CreateRequest request = new CreateRequest()
.setLogin(login)
.setPassword(login)
.setName("name" + id)
.setEmail(id + "@test.com");
stream(populators).forEach(p -> p.accept(request));
- return service().create(request.build()).getUser();
+ return service().create(request).getUser();
}
/**
* For standalone mode only
*/
@SafeVarargs
- public final User generateAdministrator(Consumer<CreateRequest.Builder>... populators) {
+ public final User generateAdministrator(Consumer<CreateRequest>... populators) {
User user = generate(populators);
session.wsClient().permissions().addUser(new org.sonarqube.ws.client.permissions.AddUserRequest().setLogin(user.getLogin()).setPermission("admin"));
session.wsClient().userGroups().addUser(new AddUserRequest().setLogin(user.getLogin()).setName("sonar-administrators"));
}
@SafeVarargs
- public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+ public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest>... populators) {
String organizationKey = organization.getKey();
User user = generate(populators);
session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(organizationKey).setLogin(user.getLogin()));
}
@SafeVarargs
- public final User generateAdministratorOnDefaultOrganization(Consumer<CreateRequest.Builder>... populators) {
+ public final User generateAdministratorOnDefaultOrganization(Consumer<CreateRequest>... populators) {
User user = generate(populators);
session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(DEFAULT_ORGANIZATION_KEY).setLogin(user.getLogin()));
session.wsClient().userGroups().addUser(new AddUserRequest()
}
@SafeVarargs
- public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+ public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest>... populators) {
User user = generate(populators);
session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin()));
return user;
}
@SafeVarargs
- public final User generateMemberOfDefaultOrganization(Consumer<CreateRequest.Builder>... populators) {
+ public final User generateMemberOfDefaultOrganization(Consumer<CreateRequest>... populators) {
User user = generate(populators);
session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(DEFAULT_ORGANIZATION_KEY).setLogin(user.getLogin()));
return user;
}
public Optional<Users.SearchWsResponse.User> getByLogin(String login) {
- List<Users.SearchWsResponse.User> users = session.wsClient().users().search(SearchRequest.builder().setQuery(login).build()).getUsersList();
+ List<Users.SearchWsResponse.User> users = session.wsClient().users().search(new SearchRequest().setQ(login)).getUsersList();
if (users.size() == 1) {
return Optional.of(users.get(0));
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static java.util.Collections.emptyList;
-
-@Immutable
-public class CreateRequest {
-
- private final String login;
- private final String password;
- private final String name;
- private final String email;
- private final List<String> scmAccounts;
- private final boolean local;
-
- private CreateRequest(Builder builder) {
- this.login = builder.login;
- this.password = builder.password;
- this.name = builder.name;
- this.email = builder.email;
- this.scmAccounts = builder.scmAccounts;
- this.local = builder.local;
- }
-
- public String getLogin() {
- return login;
- }
-
- @CheckForNull
- public String getPassword() {
- return password;
- }
-
- public String getName() {
- return name;
- }
-
- @CheckForNull
- public String getEmail() {
- return email;
- }
-
- public List<String> getScmAccounts() {
- return scmAccounts;
- }
-
- public boolean isLocal() {
- return local;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String login;
- private String password;
- private String name;
- private String email;
- private List<String> scmAccounts = emptyList();
- private boolean local = true;
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setLogin(String login) {
- this.login = login;
- return this;
- }
-
- public Builder setPassword(@Nullable String password) {
- this.password = password;
- return this;
- }
-
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- public Builder setEmail(@Nullable String email) {
- this.email = email;
- return this;
- }
-
- public Builder setScmAccounts(List<String> scmAccounts) {
- this.scmAccounts = scmAccounts;
- return this;
- }
-
- public Builder setLocal(boolean local) {
- this.local = local;
- return this;
- }
-
- public CreateRequest build() {
- checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
- checkArgument(!isNullOrEmpty(name), "Name is mandatory and must not be empty");
- checkArgument(!local || !isNullOrEmpty(password), "Password is mandatory and must not be empty");
- checkArgument(local || isNullOrEmpty(password), "Password should only be set on local user");
- return new CreateRequest(this);
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-@Immutable
-public class GroupsRequest {
-
- private final String login;
- private final String organization;
- private final String query;
- private final String selected;
- private final Integer page;
- private final Integer pageSize;
-
- private GroupsRequest(Builder builder) {
- this.login = builder.login;
- this.organization = builder.organization;
- this.query = builder.query;
- this.selected = builder.selected;
- this.page = builder.page;
- this.pageSize = builder.pageSize;
- }
-
- public String getLogin() {
- return login;
- }
-
- @CheckForNull
- public String getOrganization() {
- return organization;
- }
-
- @CheckForNull
- public String getQuery() {
- return query;
- }
-
- @CheckForNull
- public String getSelected() {
- return selected;
- }
-
- @CheckForNull
- public Integer getPage() {
- return page;
- }
-
- @CheckForNull
- public Integer getPageSize() {
- return pageSize;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String login;
- private String organization;
- private String query;
- private String selected;
- private Integer page;
- private Integer pageSize;
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setLogin(String login) {
- this.login = login;
- return this;
- }
-
- public Builder setOrganization(@Nullable String organization) {
- this.organization = organization;
- return this;
- }
-
- public Builder setQuery(@Nullable String query) {
- this.query = query;
- return this;
- }
-
- public Builder setSelected(@Nullable String selected) {
- this.selected = selected;
- return this;
- }
-
- public Builder setPage(@Nullable Integer page) {
- this.page = page;
- return this;
- }
-
- public Builder setPageSize(@Nullable Integer pageSize) {
- this.pageSize = pageSize;
- return this;
- }
-
- public GroupsRequest build() {
- checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
- return new GroupsRequest(this);
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class SearchRequest {
-
- private final Integer page;
- private final Integer pageSize;
- private final String query;
- private final List<String> possibleFields;
-
- private SearchRequest(Builder builder) {
- this.page = builder.page;
- this.pageSize = builder.pageSize;
- this.query = builder.query;
- this.possibleFields = builder.additionalFields;
- }
-
- @CheckForNull
- public Integer getPage() {
- return page;
- }
-
- @CheckForNull
- public Integer getPageSize() {
- return pageSize;
- }
-
- @CheckForNull
- public String getQuery() {
- return query;
- }
-
- public List<String> getPossibleFields() {
- return possibleFields;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private Integer page;
- private Integer pageSize;
- private String query;
- private List<String> additionalFields = new ArrayList<>();
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setPage(@Nullable Integer page) {
- this.page = page;
- return this;
- }
-
- public Builder setPageSize(@Nullable Integer pageSize) {
- this.pageSize = pageSize;
- return this;
- }
-
- public Builder setQuery(@Nullable String query) {
- this.query = query;
- return this;
- }
-
- public Builder setPossibleFields(List<String> possibleFields) {
- this.additionalFields = possibleFields;
- return this;
- }
-
- public SearchRequest build() {
- return new SearchRequest(this);
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static java.util.Collections.emptyList;
-
-public class UpdateRequest {
-
- private final String login;
- private final String name;
- private final String email;
- private final List<String> scmAccounts;
-
- private UpdateRequest(Builder builder) {
- this.login = builder.login;
- this.name = builder.name;
- this.email = builder.email;
- this.scmAccounts = builder.scmAccounts;
- }
-
- public String getLogin() {
- return login;
- }
-
- @CheckForNull
- public String getName() {
- return name;
- }
-
- @CheckForNull
- public String getEmail() {
- return email;
- }
-
- public List<String> getScmAccounts() {
- return scmAccounts;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String login;
- private String name;
- private String email;
- private List<String> scmAccounts = emptyList();
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setLogin(String login) {
- this.login = login;
- return this;
- }
-
- public Builder setName(@Nullable String name) {
- this.name = name;
- return this;
- }
-
- public Builder setEmail(@Nullable String email) {
- this.email = email;
- return this;
- }
-
- public Builder setScmAccounts(List<String> scmAccounts) {
- this.scmAccounts = scmAccounts;
- return this;
- }
-
- public UpdateRequest build() {
- checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
- return new UpdateRequest(this);
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.List;
-import org.sonarqube.ws.Users.CreateWsResponse;
-import org.sonarqube.ws.Users.CurrentWsResponse;
-import org.sonarqube.ws.Users.GroupsWsResponse;
-import org.sonarqube.ws.Users.SearchWsResponse;
-import org.sonarqube.ws.client.BaseService;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsConnector;
-import org.sonarqube.ws.client.WsResponse;
-
-import static org.sonar.api.server.ws.WebService.Param.FIELDS;
-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;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_CREATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_CURRENT;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_DEACTIVATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_GROUPS;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SEARCH;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SKIP_ONBOARDING_TUTORIAL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_UPDATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.CONTROLLER_USERS;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_EMAIL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOCAL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOGIN;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_NAME;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_PASSWORD;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SCM_ACCOUNT;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SELECTED;
-
-public class UsersService extends BaseService {
-
- public UsersService(WsConnector wsConnector) {
- super(wsConnector, CONTROLLER_USERS);
- }
-
- public SearchWsResponse search(SearchRequest request) {
- List<String> additionalFields = request.getPossibleFields();
- return call(new GetRequest(path(ACTION_SEARCH))
- .setParam(PAGE, request.getPage())
- .setParam(PAGE_SIZE, request.getPageSize())
- .setParam(TEXT_QUERY, request.getQuery())
- .setParam(FIELDS, !additionalFields.isEmpty() ? inlineMultipleParamValue(additionalFields) : null),
- SearchWsResponse.parser());
- }
-
- public CreateWsResponse create(CreateRequest request) {
- return call(new PostRequest(path(ACTION_CREATE))
- .setParam(PARAM_LOGIN, request.getLogin())
- .setParam(PARAM_PASSWORD, request.getPassword())
- .setParam(PARAM_NAME, request.getName())
- .setParam(PARAM_EMAIL, request.getEmail())
- .setParam(PARAM_SCM_ACCOUNT, request.getScmAccounts())
- .setParam(PARAM_LOCAL, request.isLocal()),
- CreateWsResponse.parser());
- }
-
- public void update(UpdateRequest request) {
- call(new PostRequest(path(ACTION_UPDATE))
- .setParam(PARAM_LOGIN, request.getLogin())
- .setParam(PARAM_NAME, request.getName())
- .setParam(PARAM_EMAIL, request.getEmail())
- .setParam(PARAM_SCM_ACCOUNT, request.getScmAccounts()));
- }
-
- public GroupsWsResponse groups(GroupsRequest request) {
- return call(new GetRequest(path(ACTION_GROUPS))
- .setParam(PARAM_LOGIN, request.getLogin())
- .setParam(PARAM_ORGANIZATION, request.getOrganization())
- .setParam(PARAM_SELECTED, request.getSelected())
- .setParam(TEXT_QUERY, request.getQuery())
- .setParam(PAGE, request.getPage())
- .setParam(PAGE_SIZE, request.getPageSize()),
- GroupsWsResponse.parser());
- }
-
- public CurrentWsResponse current() {
- return call(new GetRequest(path(ACTION_CURRENT)), CurrentWsResponse.parser());
- }
-
- public WsResponse skipOnboardingTutorial() {
- return call(new PostRequest(path(ACTION_SKIP_ONBOARDING_TUTORIAL)));
- }
-
- public void deactivate(String login) {
- call(new PostRequest(path(ACTION_DEACTIVATE))
- .setParam(PARAM_LOGIN, login));
- }
-
-}
private String login;
private String name;
private String password;
- private String scmAccount;
- private String scmAccounts;
+ private List<String> scmAccount;
+ private List<String> scmAccounts;
/**
* Example value: "myname@email.com"
/**
* Example value: "scmAccount=firstValue&scmAccount=secondValue&scmAccount=thirdValue"
*/
- public CreateRequest setScmAccount(String scmAccount) {
+ public CreateRequest setScmAccount(List<String> scmAccount) {
this.scmAccount = scmAccount;
return this;
}
- public String getScmAccount() {
+ public List<String> getScmAccount() {
return scmAccount;
}
* @deprecated since 6.1
*/
@Deprecated
- public CreateRequest setScmAccounts(String scmAccounts) {
+ public CreateRequest setScmAccounts(List<String> scmAccounts) {
this.scmAccounts = scmAccounts;
return this;
}
- public String getScmAccounts() {
+ public List<String> getScmAccounts() {
return scmAccounts;
}
}
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
* @since 3.7
*/
- public void create(CreateRequest request) {
- call(
+ public CreateWsResponse create(CreateRequest request) {
+ return call(
new PostRequest(path("create"))
.setParam("email", request.getEmail())
.setParam("local", request.getLocal())
.setParam("name", request.getName())
.setParam("password", request.getPassword())
.setParam("scmAccount", request.getScmAccount())
- .setParam("scmAccounts", request.getScmAccounts()),
+ .setParam("scmAccounts", request.getScmAccounts() == null ? null : request.getScmAccounts().stream().collect(Collectors.joining(","))),
CreateWsResponse.parser());
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CreateRequestTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- CreateRequest.Builder underTest = CreateRequest.builder();
-
- @Test
- public void create_request() {
- CreateRequest result = underTest
- .setLogin("john")
- .setPassword("123456")
- .setName("John")
- .setEmail("john@doo.com")
- .setScmAccounts(asList("jo", "hn"))
- .build();
-
- assertThat(result.getLogin()).isEqualTo("john");
- assertThat(result.getPassword()).isEqualTo("123456");
- assertThat(result.getName()).isEqualTo("John");
- assertThat(result.getEmail()).isEqualTo("john@doo.com");
- assertThat(result.getScmAccounts()).containsOnly("jo", "hn");
- assertThat(result.isLocal()).isTrue();
- }
-
- @Test
- public void create_request_for_local_user() {
- CreateRequest result = underTest
- .setLogin("john")
- .setPassword("123456")
- .setName("John")
- .setLocal(true)
- .build();
-
- assertThat(result.isLocal()).isTrue();
- }
-
- @Test
- public void create_request_for_none_local_user() {
- CreateRequest result = underTest
- .setLogin("john")
- .setName("John")
- .setLocal(false)
- .build();
-
- assertThat(result.isLocal()).isFalse();
- }
-
- @Test
- public void scm_accounts_is_empty_by_default() throws Exception {
- CreateRequest result = underTest
- .setLogin("john")
- .setPassword("123456")
- .setName("John")
- .setEmail("john@doo.com")
- .build();
-
- assertThat(result.getScmAccounts()).isEmpty();
- }
-
- @Test
- public void fail_when_empty_login() {
- expectedException.expect(IllegalArgumentException.class);
- underTest
- .setLogin("")
- .setPassword("123456")
- .setName("John")
- .build();
- }
-
- @Test
- public void fail_when_empty_password_on_local_user() {
- expectedException.expect(IllegalArgumentException.class);
- underTest
- .setLogin("john")
- .setPassword("")
- .setName("John")
- .build();
- }
-
- @Test
- public void fail_when_empty_name() {
- expectedException.expect(IllegalArgumentException.class);
- underTest
- .setLogin("john")
- .setPassword("12345")
- .setName("")
- .build();
- }
-
- @Test
- public void fail_when_password_is_set_on_none_local_user() {
- expectedException.expect(IllegalArgumentException.class);
- underTest
- .setLogin("john")
- .setPassword("12345")
- .setName("12345")
- .setLocal(false)
- .build();
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonarqube.ws.client.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GroupsRequestTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- GroupsRequest.Builder underTest = GroupsRequest.builder();
-
- @Test
- public void create_request() {
- GroupsRequest result = underTest
- .setLogin("john")
- .setOrganization("orga-uuid")
- .setSelected("all")
- .setQuery("sonar-users")
- .setPage(10)
- .setPageSize(50)
- .build();
-
- assertThat(result.getLogin()).isEqualTo("john");
- assertThat(result.getOrganization()).isEqualTo("orga-uuid");
- assertThat(result.getSelected()).isEqualTo("all");
- assertThat(result.getQuery()).isEqualTo("sonar-users");
- assertThat(result.getPage()).isEqualTo(10);
- assertThat(result.getPageSize()).isEqualTo(50);
- }
-
- @Test
- public void create_request_wih_minimal_fields() {
- GroupsRequest result = underTest
- .setLogin("john")
- .build();
-
- assertThat(result.getLogin()).isEqualTo("john");
- assertThat(result.getOrganization()).isNull();
- assertThat(result.getSelected()).isNull();
- assertThat(result.getQuery()).isNull();
- assertThat(result.getPage()).isNull();
- assertThat(result.getPageSize()).isNull();
- }
-
- @Test
- public void fail_when_empty_login() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Login is mandatory and must not be empty");
-
- underTest.setLogin("").build();
- }
-
- @Test
- public void fail_when_null_login() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Login is mandatory and must not be empty");
-
- underTest.build();
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class UpdateRequestTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- UpdateRequest.Builder underTest = UpdateRequest.builder();
-
- @Test
- public void create_request() {
- UpdateRequest result = underTest
- .setLogin("john")
- .setName("John")
- .setEmail("john@doo.com")
- .setScmAccounts(asList("jo", "hn"))
- .build();
-
- assertThat(result.getLogin()).isEqualTo("john");
- assertThat(result.getName()).isEqualTo("John");
- assertThat(result.getEmail()).isEqualTo("john@doo.com");
- assertThat(result.getScmAccounts()).containsOnly("jo", "hn");
- }
-
- @Test
- public void scm_accounts_is_empty_by_default() throws Exception {
- UpdateRequest result = underTest
- .setLogin("john")
- .setName("John")
- .setEmail("john@doo.com")
- .build();
-
- assertThat(result.getScmAccounts()).isEmpty();
- }
-
- @Test
- public void fail_when_empty_login() {
- expectedException.expect(IllegalArgumentException.class);
- underTest
- .setLogin("")
- .setName("John")
- .build();
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.ws.Users;
-import org.sonarqube.ws.Users.CreateWsResponse;
-import org.sonarqube.ws.Users.GroupsWsResponse;
-import org.sonarqube.ws.client.ServiceTester;
-import org.sonarqube.ws.client.WsConnector;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.sonar.api.server.ws.WebService.Param.FIELDS;
-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;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_EMAIL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOCAL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOGIN;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_NAME;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_PASSWORD;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SCM_ACCOUNT;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SELECTED;
-
-public class UsersServiceTest {
-
- @Rule
- public ServiceTester<UsersService> serviceTester = new ServiceTester<>(new UsersService(mock(WsConnector.class)));
-
- private UsersService underTest = serviceTester.getInstanceUnderTest();
-
- @Test
- public void search() {
- underTest.search(SearchRequest.builder()
- .setQuery("john")
- .setPage(10)
- .setPageSize(50)
- .setPossibleFields(asList("email", "name"))
- .build());
-
- assertThat(serviceTester.getGetParser()).isSameAs(Users.SearchWsResponse.parser());
- serviceTester.assertThat(serviceTester.getGetRequest())
- .hasParam(TEXT_QUERY, "john")
- .hasParam(PAGE, 10)
- .hasParam(PAGE_SIZE, 50)
- .hasParam(FIELDS, "email,name")
- .andNoOtherParam();
- }
-
- @Test
- public void create() {
- underTest.create(CreateRequest.builder()
- .setLogin("john")
- .setPassword("123456")
- .setName("John")
- .setEmail("john@doo.com")
- .setScmAccounts(asList("jo", "hn"))
- .setLocal(true)
- .build());
-
- assertThat(serviceTester.getPostParser()).isSameAs(CreateWsResponse.parser());
- serviceTester.assertThat(serviceTester.getPostRequest())
- .hasParam(PARAM_LOGIN, "john")
- .hasParam(PARAM_PASSWORD, "123456")
- .hasParam(PARAM_NAME, "John")
- .hasParam(PARAM_EMAIL, "john@doo.com")
- .hasParam(PARAM_SCM_ACCOUNT, asList("jo", "hn"))
- .hasParam(PARAM_LOCAL, "true")
- .andNoOtherParam();
- }
-
- @Test
- public void update() {
- underTest.update(UpdateRequest.builder()
- .setLogin("john")
- .setName("John")
- .setEmail("john@doo.com")
- .setScmAccounts(asList("jo", "hn"))
- .build());
-
- serviceTester.assertThat(serviceTester.getPostRequest())
- .hasParam(PARAM_LOGIN, "john")
- .hasParam(PARAM_NAME, "John")
- .hasParam(PARAM_EMAIL, "john@doo.com")
- .hasParam(PARAM_SCM_ACCOUNT, asList("jo", "hn"))
- .andNoOtherParam();
- }
-
- @Test
- public void groups() {
- underTest.groups(GroupsRequest.builder()
- .setLogin("john")
- .setOrganization("orga-uuid")
- .setSelected("all")
- .setQuery("sonar-users")
- .setPage(10)
- .setPageSize(50)
- .build());
-
- assertThat(serviceTester.getGetParser()).isSameAs(GroupsWsResponse.parser());
- serviceTester.assertThat(serviceTester.getGetRequest())
- .hasParam(PARAM_LOGIN, "john")
- .hasParam(PARAM_ORGANIZATION, "orga-uuid")
- .hasParam(PARAM_SELECTED, "all")
- .hasParam(TEXT_QUERY, "sonar-users")
- .hasParam(PAGE, 10)
- .hasParam(PAGE_SIZE, 50)
- .andNoOtherParam();
- }
-
- @Test
- public void current() {
- underTest.current();
-
- assertThat(serviceTester.getGetParser()).isSameAs(Users.CurrentWsResponse.parser());
- }
-}
*/
package org.sonarqube.tests.issue;
-import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.sonarqube.ws.Users;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.user.CreateRequest;
-import org.sonarqube.ws.client.user.SearchRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
import util.ProjectAnalysis;
import util.ProjectAnalysisRule;
+import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;
import static util.ItUtils.newAdminWsClient;
private static void createUser(String login, String name, String email, String... scmAccounts) {
newAdminWsClient(ORCHESTRATOR).users().create(
- CreateRequest.builder()
+ new CreateRequest()
.setLogin(login)
.setName(name)
.setEmail(email)
.setPassword("xxxxxxx")
- .setScmAccounts(Arrays.asList(scmAccounts))
- .build());
+ .setScmAccounts(asList(scmAccounts)));
}
private static void deleteAllUsers() {
WsClient wsClient = newAdminWsClient(ORCHESTRATOR);
- Users.SearchWsResponse searchResponse = wsClient.users().search(SearchRequest.builder().build());
+ Users.SearchWsResponse searchResponse = wsClient.users().search(new SearchRequest());
searchResponse.getUsersList().forEach(user -> {
wsClient.wsConnector().call(new PostRequest("api/users/deactivate").setParam("login", user.getLogin()));
});
import org.sonarqube.ws.client.HttpException;
import org.sonarqube.ws.client.organizations.RemoveMemberRequest;
import org.sonarqube.ws.client.permissions.AddUserRequest;
+import org.sonarqube.ws.client.users.DeactivateRequest;
public class OrganizationMembershipTest {
User user = tester.users().generate();
addMembership(organization, user);
- tester.users().service().deactivate(user.getLogin());
+ tester.users().service().deactivate(new DeactivateRequest().setLogin(user.getLogin()));
tester.organizations().assertThatNotMemberOf(organization, user);
}
import org.sonarqube.qa.util.LogsTailer;
import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Users;
-import org.sonarqube.ws.client.user.SearchRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.pluginArtifact;
LogsTailer.Watch sonarQubeIsUpWatcher = sonarQube.logsTailer.watch("SonarQube is up")) {
sonarQube.resume();
sonarQubeIsUpWatcher.waitForLog(20, TimeUnit.SECONDS);
- SearchRequest searchRequest = SearchRequest.builder().setQuery("admin").build();
+ SearchRequest searchRequest = new SearchRequest().setQ("admin");
Users.SearchWsResponse searchWsResponse = sonarQube.tester.wsClient().users().search(searchRequest);
assertThat(searchWsResponse.getUsersCount()).isEqualTo(1);
assertThat(searchWsResponse.getUsers(0).getName()).isEqualTo("Administrator");
import org.sonarqube.tests.Category4Suite;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
import util.user.UserRule;
import util.user.Users;
setUserCreatedByAuthPlugin(USER_LOGIN, USER_PROVIDER_ID, USER_NAME, USER_EMAIL);
// Provision none local user in database
- newAdminWsClient(ORCHESTRATOR).users().create(CreateRequest.builder()
+ newAdminWsClient(ORCHESTRATOR).users().create(new CreateRequest()
.setLogin(USER_LOGIN)
.setName(USER_NAME)
.setEmail(USER_EMAIL)
- .setLocal(false)
- .build());
+ .setLocal("false"));
assertThat(userRule.getUserByLogin(USER_LOGIN).get())
.extracting(Users.User::isLocal, Users.User::getExternalIdentity, Users.User::getExternalProvider)
.containsOnly(false, USER_LOGIN, "sonarqube");
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
import org.sonarqube.ws.client.WsResponse;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.DeactivateRequest;
import org.sonarqube.ws.client.usertokens.GenerateRequest;
import org.sonarqube.ws.client.usertokens.RevokeRequest;
import org.sonarqube.ws.client.usertokens.SearchRequest;
@Test
public void authenticate_on_user_that_was_disabled() {
User user = tester.users().generate(u -> u.setLogin("test").setPassword("password"));
- tester.users().service().deactivate(user.getLogin());
+ tester.users().service().deactivate(new DeactivateRequest().setLogin(user.getLogin()));
- tester.users().service().create(CreateRequest.builder()
+ tester.users().service().create(new CreateRequest()
.setLogin("test")
.setName("Test")
.setEmail("test@email.com")
.setScmAccounts(asList("test1", "test2"))
- .setPassword("password")
- .build());
+ .setPassword("password"));
assertThat(checkAuthenticationWithAuthenticateWebService("test", "password")).isTrue();
assertThat(tester.users().getByLogin("test").get())
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.permissions.AddUserRequest;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
import util.selenium.Selenese;
import static com.codeborne.selenide.Condition.visible;
enablePlugin();
// Provision none local user in database
- tester.wsClient().users().create(CreateRequest.builder()
+ tester.wsClient().users().create(new CreateRequest()
.setLogin(USER_LOGIN)
.setName(USER_NAME)
.setEmail(USER_EMAIL)
- .setLocal(false)
- .build());
+ .setLocal("false"));
User user = tester.users().getByLogin(USER_LOGIN).get();
assertThat(user.getLocal()).isFalse();
assertThat(user.getExternalIdentity()).isEqualTo(USER_LOGIN);
import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.users.DeactivateRequest;
import util.ItUtils;
import static org.assertj.core.api.Assertions.assertThat;
tester.as(user.getLogin()).wsClient().users().skipOnboardingTutorial();
verifyTutorial(user, false);
- tester.wsClient().users().deactivate(user.getLogin());
+ tester.wsClient().users().deactivate(new DeactivateRequest().setLogin(user.getLogin()));
User reactivatedUser = tester.users().generate(u -> u.setLogin(user.getLogin()).setName(user.getName()).setPassword(user.getLogin()));
verifyTutorial(reactivatedUser, true);
import org.sonarqube.qa.util.pageobjects.UsersManagementPage;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsResponse;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
import util.user.UserRule;
import util.user.Users;
@Test
public void provision_user_before_authentication() {
- tester.wsClient().users().create(CreateRequest.builder()
+ tester.wsClient().users().create(new CreateRequest()
.setLogin(USER_LOGIN)
.setName("Tester Testerovich")
.setEmail("tester@example.org")
- .setLocal(false)
- .build());
+ .setLocal("false"));
// The user is created in SonarQube but doesn't exist yet in external authentication system
verifyAuthenticationIsNotOk(USER_LOGIN, "123");
import org.junit.rules.DisableOnDebug;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
-import org.sonarqube.tests.Byteman;
import org.sonarqube.qa.util.Tester;
+import org.sonarqube.tests.Byteman;
import org.sonarqube.ws.Users.CreateWsResponse.User;
-import org.sonarqube.ws.client.user.SearchRequest;
-import org.sonarqube.ws.client.user.UpdateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
+import org.sonarqube.ws.client.users.UpdateRequest;
import util.ItUtils;
import static org.assertj.core.api.Assertions.assertThat;
// Renaming is not propagated to index as long as recovery does not
// run.
String newName = "renamed";
- tester.users().service().update(UpdateRequest.builder().setLogin(login).setName(newName).build());
+ tester.users().service().update(new UpdateRequest().setLogin(login).setName(newName));
assertThat(isReturnedInSearch(newName)).isFalse();
while (!isReturnedInSearch(newName)) {
// Renaming is not propagated to index as long as recovery does not
// run.
String newName = "renamed";
- expectHttpError(500, () -> tester.users().service().update(UpdateRequest.builder().setLogin(login).setName(newName).build()));
+ expectHttpError(500, () -> tester.users().service().update(new UpdateRequest().setLogin(login).setName(newName)));
assertThat(isReturnedInSearch(newName)).isFalse();
while (!isReturnedInSearch(newName)) {
}
private boolean isReturnedInSearch(String name) {
- return tester.users().service().search(SearchRequest.builder().setQuery(name).build()).getUsersCount() == 1L;
+ return tester.users().service().search(new SearchRequest().setQ(name)).getUsersCount() == 1L;
}
}
package org.sonarqube.tests.user;
import com.sonar.orchestrator.Orchestrator;
-import org.junit.After;
-import org.sonarqube.ws.Users.CreateWsResponse.User;
-import org.sonarqube.qa.util.Tester;
-import org.sonarqube.qa.util.pageobjects.UsersManagementPage;
-import org.sonarqube.tests.Category1Suite;
import java.util.List;
+import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.pageobjects.UsersManagementPage;
+import org.sonarqube.tests.Category1Suite;
import org.sonarqube.ws.Users;
-import org.sonarqube.ws.client.user.GroupsRequest;
+import org.sonarqube.ws.Users.CreateWsResponse.User;
+import org.sonarqube.ws.client.users.GroupsRequest;
import util.user.UserRule;
-
import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.assertj.core.api.Assertions.assertThat;
tester.groups().generate(null, g -> g.setName(group));
tester.groups().addMemberToGroups(tester.organizations().getDefaultOrganization(), login, group);
- List<Users.GroupsWsResponse.Group> result = tester.as(adminUser.getLogin()).wsClient().users().groups(GroupsRequest.builder().setLogin(login).build()).getGroupsList();
+ List<Users.GroupsWsResponse.Group> result = tester.as(adminUser.getLogin()).wsClient().users().groups(new GroupsRequest().setLogin(login)).getGroupsList();
assertThat(result).extracting(Users.GroupsWsResponse.Group::getName).contains(group);
}
}
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.permissions.AddUserRequest;
import org.sonarqube.ws.client.roots.SetRootRequest;
-import org.sonarqube.ws.client.user.CreateRequest;
-import org.sonarqube.ws.client.user.SearchRequest;
-import org.sonarqube.ws.client.user.UsersService;
+import org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
+import org.sonarqube.ws.client.users.UsersService;
import util.selenium.Consumer;
import static java.util.Arrays.asList;
}
public Users.CreateWsResponse.User createUser(String login, String name, @Nullable String email, String password) {
- CreateRequest.Builder request = CreateRequest.builder()
+ CreateRequest request = new CreateRequest()
.setLogin(login)
.setName(name)
.setEmail(email)
.setPassword(password);
- return adminWsClient().users().create(request.build()).getUser();
+ return adminWsClient().users().create(request).getUser();
}
/**
* Create user with randomly generated values. By default password is the login.
*/
@SafeVarargs
- public final org.sonarqube.ws.Users.CreateWsResponse.User generate(Consumer<CreateRequest.Builder>... populators) {
+ public final org.sonarqube.ws.Users.CreateWsResponse.User generate(Consumer<CreateRequest>... populators) {
int id = ID_GENERATOR.getAndIncrement();
String login = "login" + id;
- CreateRequest.Builder request = CreateRequest.builder()
+ CreateRequest request = new CreateRequest()
.setLogin(login)
.setName("name" + id)
.setEmail(id + "@test.com")
.setPassword(login);
stream(populators).forEach(p -> p.accept(request));
- return adminWsClient().users().create(request.build()).getUser();
+ return adminWsClient().users().create(request).getUser();
}
public void createUser(String login, String password) {
public void deactivateAllUsers() {
UsersService service = newAdminWsClient(orchestrator).users();
- List<String> logins = service.search(SearchRequest.builder().build()).getUsersList()
+ List<String> logins = service.search(new SearchRequest()).getUsersList()
.stream()
.filter(u -> !u.getLogin().equals("admin"))
.map(u -> u.getLogin())