Search in sources :

Example 6 with SearchUsersResponse

use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.

the class SearchUsersActionTest method search_deselected_users.

@Test
public void search_deselected_users() {
    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(SELECTED, "deselected").executeProtobuf(SearchUsersResponse.class);
    assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin, SearchUsersResponse.User::getName, SearchUsersResponse.User::getSelected).containsExactlyInAnyOrder(tuple(user2.getLogin(), user2.getName(), 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 7 with SearchUsersResponse

use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.

the class SearchUsersActionTest method uses_global_permission.

@Test
public void uses_global_permission() {
    QualityGateDto gate = db.qualityGates().insertQualityGate();
    UserDto user1 = 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(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 8 with SearchUsersResponse

use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.

the class SearchUsersActionTest method search_by_name.

@Test
public void search_by_name() {
    QualityGateDto gate = db.qualityGates().insertQualityGate();
    UserDto user1 = db.users().insertUser(u -> u.setName("John Doe"));
    UserDto user2 = db.users().insertUser(u -> u.setName("Jane Doe"));
    UserDto user3 = db.users().insertUser(u -> u.setName("John Smith"));
    db.qualityGates().addUserPermission(gate, user1);
    userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES);
    SearchUsersResponse response = ws.newRequest().setParam(PARAM_GATE_NAME, gate.getName()).setParam(TEXT_QUERY, "ohn").setParam(SELECTED, "all").executeProtobuf(SearchUsersResponse.class);
    assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin).containsExactlyInAnyOrder(user1.getLogin(), user3.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 9 with SearchUsersResponse

use of org.sonarqube.ws.Qualitygates.SearchUsersResponse in project sonarqube by SonarSource.

the class SearchUsersActionTest method search_selected_users.

@Test
public void search_selected_users() {
    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(SELECTED, "selected").executeProtobuf(SearchUsersResponse.class);
    assertThat(response.getUsersList()).extracting(SearchUsersResponse.User::getLogin, SearchUsersResponse.User::getName, SearchUsersResponse.User::getSelected).containsExactlyInAnyOrder(tuple(user1.getLogin(), user1.getName(), true));
}
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