Search in sources :

Example 1 with SearchUsersResponse

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());
}
Also used : UserDto(org.sonar.db.user.UserDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) SearchUsersResponse(org.sonarqube.ws.Qualitygates.SearchUsersResponse) Test(org.junit.Test)

Example 2 with SearchUsersResponse

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());
}
Also used : UserDto(org.sonar.db.user.UserDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) SearchUsersResponse(org.sonarqube.ws.Qualitygates.SearchUsersResponse) Test(org.junit.Test)

Example 3 with SearchUsersResponse

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));
}
Also used : UserDto(org.sonar.db.user.UserDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) SearchUsersResponse(org.sonarqube.ws.Qualitygates.SearchUsersResponse) Test(org.junit.Test)

Example 4 with SearchUsersResponse

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());
}
Also used : UserDto(org.sonar.db.user.UserDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) SearchUsersResponse(org.sonarqube.ws.Qualitygates.SearchUsersResponse) Test(org.junit.Test)

Example 5 with SearchUsersResponse

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));
}
Also used : UserDto(org.sonar.db.user.UserDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) SearchUsersResponse(org.sonarqube.ws.Qualitygates.SearchUsersResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)9 UserDto (org.sonar.db.user.UserDto)9 SearchUsersResponse (org.sonarqube.ws.Qualitygates.SearchUsersResponse)9