Search in sources :

Example 6 with SearchWsResponse

use of org.sonarqube.ws.WsComponents.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method return_only_components_from_projects_on_which_user_has_browse_permission.

@Test
public void return_only_components_from_projects_on_which_user_has_browse_permission() throws IOException {
    ComponentDto project1 = newProjectDto(db.getDefaultOrganization());
    ComponentDto file1 = newFileDto(project1).setKey("file1");
    ComponentDto file2 = newFileDto(project1).setKey("file2");
    ComponentDto project2 = newProjectDto(db.getDefaultOrganization());
    ComponentDto file3 = newFileDto(project2).setKey("file3");
    db.components().insertComponents(project1, file1, file2, project2, file3);
    setBrowsePermissionOnUser(project1);
    SearchWsResponse response = call(new SearchWsRequest().setQualifiers(singletonList(FILE)));
    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey(), file2.getKey());
}
Also used : SearchWsRequest(org.sonarqube.ws.client.component.SearchWsRequest) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.WsComponents.SearchWsResponse) Test(org.junit.Test)

Aggregations

SearchWsResponse (org.sonarqube.ws.WsComponents.SearchWsResponse)6 Test (org.junit.Test)5 SearchWsRequest (org.sonarqube.ws.client.component.SearchWsRequest)5 ComponentDto (org.sonar.db.component.ComponentDto)3 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 ArrayList (java.util.ArrayList)1