use of org.sonarqube.ws.Qualityprofiles.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method uses_global_permission.
@Test
public void uses_global_permission() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
UserDto user1 = db.users().insertUser();
db.qualityProfiles().addUserPermission(profile, user1);
userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user1.getLogin());
}
use of org.sonarqube.ws.Qualityprofiles.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method search_all_users.
@Test
public void search_all_users() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
UserDto user1 = db.users().insertUser(u -> u.setEmail("user1@email.com"));
UserDto user2 = db.users().insertUser(u -> u.setEmail("user2@email.com"));
db.qualityProfiles().addUserPermission(profile, user1);
userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).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.Qualityprofiles.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method search_by_login.
@Test
public void search_by_login() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
db.qualityProfiles().addUserPermission(profile, user1);
userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).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.Qualityprofiles.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method qp_administers_can_search_users.
@Test
public void qp_administers_can_search_users() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
UserDto user = db.users().insertUser();
userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user.getLogin());
}
use of org.sonarqube.ws.Qualityprofiles.SearchUsersResponse in project sonarqube by SonarSource.
the class SearchUsersActionTest method qp_editors_can_search_users.
@Test
public void qp_editors_can_search_users() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
UserDto user = db.users().insertUser();
UserDto userAllowedToEditProfile = db.users().insertUser();
db.qualityProfiles().addUserPermission(profile, userAllowedToEditProfile);
userSession.logIn(userAllowedToEditProfile);
SearchUsersResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user.getLogin(), userAllowedToEditProfile.getLogin());
}
Aggregations