Search in sources :

Example 1 with SearchGroupsResponse

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

the class SearchGroupsActionTest method group_without_description.

@Test
public void group_without_description() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
    GroupDto group = db.users().insertGroup(newGroupDto().setDescription(null));
    db.qualityProfiles().addGroupPermission(profile, group);
    userSession.logIn().addPermission(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, SearchGroupsResponse.Group::hasDescription).containsExactlyInAnyOrder(tuple(group.getName(), false));
}
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 2 with SearchGroupsResponse

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

the class SearchGroupsActionTest method qp_editors_can_search_groups.

@Test
public void qp_editors_can_search_groups() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
    GroupDto group = db.users().insertGroup();
    db.qualityProfiles().addGroupPermission(profile, group);
    UserDto userAllowedToEditProfile = db.users().insertUser();
    db.qualityProfiles().addUserPermission(profile, userAllowedToEditProfile);
    userSession.logIn(userAllowedToEditProfile);
    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) UserDto(org.sonar.db.user.UserDto) 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 3 with SearchGroupsResponse

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

the class SearchGroupsActionTest method search_all_groups.

@Test
public void search_all_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, "all").executeProtobuf(SearchGroupsResponse.class);
    assertThat(response.getGroupsList()).extracting(SearchGroupsResponse.Group::getName, SearchGroupsResponse.Group::getDescription, SearchGroupsResponse.Group::getSelected).containsExactlyInAnyOrder(tuple(group1.getName(), group1.getDescription(), true), tuple(group2.getName(), group2.getDescription(), false));
}
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 4 with SearchGroupsResponse

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

the class SearchGroupsActionTest method search_deselected_groups.

@Test
public void search_deselected_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, "deselected").executeProtobuf(SearchGroupsResponse.class);
    assertThat(response.getGroupsList()).extracting(SearchGroupsResponse.Group::getName, SearchGroupsResponse.Group::getDescription, SearchGroupsResponse.Group::getSelected).containsExactlyInAnyOrder(tuple(group2.getName(), group2.getDescription(), false));
}
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 5 with SearchGroupsResponse

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

the class SearchGroupsActionTest method uses_global_permission.

@Test
public void uses_global_permission() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
    GroupDto group = db.users().insertGroup();
    db.qualityProfiles().addGroupPermission(profile, group);
    userSession.logIn().addPermission(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)

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