Search in sources :

Example 6 with SearchGroupsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse in project sonarqube by SonarSource.

the class SearchGroupsActionTest method qp_administers_can_search_groups.

@Test
public void qp_administers_can_search_groups() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
    GroupDto group = db.users().insertGroup();
    db.qualityProfiles().addGroupPermission(profile, group);
    userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
    SearchGroupsResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(SELECTED, "all").executeProtobuf(SearchGroupsResponse.class);
    assertThat(response.getGroupsList()).extracting(SearchGroupsResponse.Group::getName).containsExactlyInAnyOrder(group.getName());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) GroupDto(org.sonar.db.user.GroupDto) GroupTesting.newGroupDto(org.sonar.db.user.GroupTesting.newGroupDto) SearchGroupsResponse(org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse) Test(org.junit.Test)

Example 7 with SearchGroupsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse in project sonarqube by SonarSource.

the class SearchGroupsActionTest method search_by_name.

@Test
public void search_by_name() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
    GroupDto group1 = db.users().insertGroup("sonar-users-project");
    GroupDto group2 = db.users().insertGroup("sonar-users-qprofile");
    GroupDto group3 = db.users().insertGroup("sonar-admin");
    db.qualityProfiles().addGroupPermission(profile, group1);
    db.qualityProfiles().addGroupPermission(profile, group2);
    db.qualityProfiles().addGroupPermission(profile, group3);
    userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES);
    SearchGroupsResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(TEXT_QUERY, "UsErS").setParam(SELECTED, "all").executeProtobuf(SearchGroupsResponse.class);
    assertThat(response.getGroupsList()).extracting(SearchGroupsResponse.Group::getName).containsExactlyInAnyOrder(group1.getName(), group2.getName());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) GroupDto(org.sonar.db.user.GroupDto) GroupTesting.newGroupDto(org.sonar.db.user.GroupTesting.newGroupDto) SearchGroupsResponse(org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse) Test(org.junit.Test)

Example 8 with SearchGroupsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse in project sonarqube by SonarSource.

the class SearchGroupsActionTest method search_selected_groups.

@Test
public void search_selected_groups() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
    GroupDto group1 = db.users().insertGroup();
    GroupDto group2 = db.users().insertGroup();
    db.qualityProfiles().addGroupPermission(profile, group1);
    userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES);
    SearchGroupsResponse response = ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(SELECTED, "selected").executeProtobuf(SearchGroupsResponse.class);
    assertThat(response.getGroupsList()).extracting(SearchGroupsResponse.Group::getName, SearchGroupsResponse.Group::getDescription, SearchGroupsResponse.Group::getSelected).containsExactlyInAnyOrder(tuple(group1.getName(), group1.getDescription(), true));
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) GroupDto(org.sonar.db.user.GroupDto) GroupTesting.newGroupDto(org.sonar.db.user.GroupTesting.newGroupDto) SearchGroupsResponse(org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)8 GroupDto (org.sonar.db.user.GroupDto)8 GroupTesting.newGroupDto (org.sonar.db.user.GroupTesting.newGroupDto)8 SearchGroupsResponse (org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse)8 UserDto (org.sonar.db.user.UserDto)1