Exemplo n.º 1
0
  @Test
  public void admin_via_groups() {
    ComponentDto jdk7 = insertJdk7();
    ComponentDto cLang = insertClang();

    GroupDto group = groupDb.insertGroup(newGroupDto());
    groupDb.addUserToGroup(user.getId(), group.getId());

    insertGroupPermission(UserRole.ADMIN, group.getId(), jdk7.getId());
    insertGroupPermission(UserRole.USER, group.getId(), cLang.getId());

    SearchMyProjectsWsResponse result = call_ws();

    assertThat(result.getProjectsCount()).isEqualTo(1);
    assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
  }
Exemplo n.º 2
0
  @Test
  public void admin_via_groups_and_users() {
    ComponentDto jdk7 = insertJdk7();
    ComponentDto cLang = insertClang();
    ComponentDto sonarqube = componentDb.insertComponent(newProjectDto());

    GroupDto group = groupDb.insertGroup(newGroupDto());
    groupDb.addUserToGroup(user.getId(), group.getId());

    insertUserPermission(UserRole.ADMIN, user.getId(), jdk7.getId());
    insertGroupPermission(UserRole.ADMIN, group.getId(), cLang.getId());
    // admin via group and user
    insertUserPermission(UserRole.ADMIN, user.getId(), sonarqube.getId());
    insertGroupPermission(UserRole.ADMIN, group.getId(), sonarqube.getId());

    SearchMyProjectsWsResponse result = call_ws();

    assertThat(result.getProjectsCount()).isEqualTo(3);
    assertThat(result.getProjectsList())
        .extracting(Project::getId)
        .containsOnly(jdk7.uuid(), cLang.uuid(), sonarqube.uuid());
  }