use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method search_by_login.
@Test
public void search_by_login() {
QualityGateDto gate = db.qualityGates().insertQualityGate();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
db.qualityGates().addUserPermission(gate, user1);
userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_GATE_NAME, gate.getName()).setParam(TEXT_QUERY, user1.getLogin()).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user1.getLogin());
}
use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method qp_administers_can_search_users.
@Test
public void qp_administers_can_search_users() {
QualityGateDto gate = db.qualityGates().insertQualityGate();
UserDto user = db.users().insertUser();
userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_GATE_NAME, gate.getName()).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user.getLogin());
}
use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method search_all_users.
@Test
public void search_all_users() {
QualityGateDto gate = db.qualityGates().insertQualityGate();
UserDto user1 = db.users().insertUser(u -> u.setEmail("user1@email.com"));
UserDto user2 = db.users().insertUser(u -> u.setEmail("user2@email.com"));
db.qualityGates().addUserPermission(gate, user1);
userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_GATE_NAME, gate.getName()).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin, SearchUsersResponse.User::getName, SearchUsersResponse.User::getAvatar, SearchUsersResponse.User::getSelected).containsExactlyInAnyOrder(tuple(user1.getLogin(), user1.getName(), "user1@email.com_avatar", true), tuple(user2.getLogin(), user2.getName(), "user2@email.com_avatar", false));
}
use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method qp_editors_can_search_users.
@Test
public void qp_editors_can_search_users() {
QualityGateDto gate = db.qualityGates().insertQualityGate();
UserDto user = db.users().insertUser();
UserDto userAllowedToEditProfile = db.users().insertUser();
db.qualityGates().addUserPermission(gate, userAllowedToEditProfile);
userSession.logIn(userAllowedToEditProfile);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_GATE_NAME, gate.getName()).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user.getLogin(), userAllowedToEditProfile.getLogin());
}
use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method user_without_email.
@Test
public void user_without_email() {
QualityGateDto gate = db.qualityGates().insertQualityGate();
UserDto user = db.users().insertUser(u -> u.setEmail(null));
db.qualityGates().addUserPermission(gate, user);
userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_GATE_NAME, gate.getName()).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin, SearchUsersResponse.User::hasAvatar).containsExactlyInAnyOrder(tuple(user.getLogin(), false));
}
Aggregations