Search in sources :

Example 1 with SearchMyProjectsWsResponse

use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.

the class SearchMyProjectsActionTest method do_not_return_views_or_developers.

@Test
public void do_not_return_views_or_developers() {
    OrganizationDto organizationDto = db.organizations().insert();
    ComponentDto jdk7 = insertJdk7(organizationDto);
    ComponentDto dev = insertDeveloper(organizationDto);
    ComponentDto view = insertView(organizationDto);
    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, dev);
    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, view);
    SearchMyProjectsWsResponse result = call_ws();
    assertThat(result.getProjectsCount()).isEqualTo(1);
    assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 2 with SearchMyProjectsWsResponse

use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.

the class SearchMyProjectsActionTest method return_only_projects_when_user_is_admin.

@Test
public void return_only_projects_when_user_is_admin() {
    OrganizationDto organizationDto = db.organizations().insert();
    ComponentDto jdk7 = insertJdk7(organizationDto);
    ComponentDto clang = insertClang(organizationDto);
    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
    db.users().insertProjectPermissionOnUser(user, UserRole.ISSUE_ADMIN, clang);
    SearchMyProjectsWsResponse result = call_ws();
    assertThat(result.getProjectsCount()).isEqualTo(1);
    assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 3 with SearchMyProjectsWsResponse

use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.

the class SearchMyProjectsActionTest method admin_via_groups.

@Test
public void admin_via_groups() {
    OrganizationDto org = db.organizations().insert();
    ComponentDto jdk7 = insertJdk7(org);
    ComponentDto cLang = insertClang(org);
    GroupDto group = db.users().insertGroup(org);
    db.users().insertMember(group, user);
    db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, jdk7);
    db.users().insertProjectPermissionOnGroup(group, UserRole.USER, cLang);
    SearchMyProjectsWsResponse result = call_ws();
    assertThat(result.getProjectsCount()).isEqualTo(1);
    assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GroupDto(org.sonar.db.user.GroupDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 4 with SearchMyProjectsWsResponse

use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.

the class SearchMyProjectsAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    SearchMyProjectsWsResponse searchMyProjectsWsResponse = doHandle(toRequest(request));
    writeProtobuf(searchMyProjectsWsResponse, request, response);
}
Also used : SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse)

Example 5 with SearchMyProjectsWsResponse

use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.

the class SearchMyProjectsActionTest method return_only_current_user_projects.

@Test
public void return_only_current_user_projects() {
    OrganizationDto organizationDto = db.organizations().insert();
    ComponentDto jdk7 = insertJdk7(organizationDto);
    ComponentDto cLang = insertClang(organizationDto);
    UserDto anotherUser = db.users().insertUser(newUserDto());
    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
    db.users().insertProjectPermissionOnUser(anotherUser, UserRole.ADMIN, cLang);
    SearchMyProjectsWsResponse result = call_ws();
    assertThat(result.getProjectsCount()).isEqualTo(1);
    assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
}
Also used : UserDto(org.sonar.db.user.UserDto) UserTesting.newUserDto(org.sonar.db.user.UserTesting.newUserDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

SearchMyProjectsWsResponse (org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse)8 Test (org.junit.Test)7 ComponentDto (org.sonar.db.component.ComponentDto)7 OrganizationDto (org.sonar.db.organization.OrganizationDto)7 GroupDto (org.sonar.db.user.GroupDto)2 UserDto (org.sonar.db.user.UserDto)1 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)1