コード例 #1
0
  @Test(expected = ForbiddenException.class)
  public void check_component_uuid_permission_ko() {
    UserSession session = newServerUserSession().setLogin("marius").setUserId(1);

    ComponentDto project = ComponentTesting.newProjectDto();
    ComponentDto file = ComponentTesting.newFileDto(project, "file-uuid");
    when(resourceDao.selectResource("file-uuid"))
        .thenReturn(new ResourceDto().setProjectUuid(project.uuid()));
    when(authorizationDao.selectAuthorizedRootProjectsUuids(1, UserRole.USER))
        .thenReturn(newArrayList(project.uuid()));

    session.checkComponentUuidPermission(UserRole.USER, "another-uuid");
  }
コード例 #2
0
ファイル: AppActionTest.java プロジェクト: hutea/sonarqube
  @Test
  public void app() throws Exception {
    userSessionRule
        .login("john")
        .addComponentPermission(UserRole.USER, SUB_PROJECT_KEY, COMPONENT_KEY);
    ComponentDto project = newProject();

    ComponentDto file =
        ComponentTesting.newFileDto(project)
            .setId(10L)
            .setKey(COMPONENT_KEY)
            .setUuid(COMPONENT_UUID)
            .setName("Plugin.java")
            .setProjectUuid("THE_PROJECT")
            .setLongName("src/main/java/org/sonar/api/Plugin.java")
            .setPath("src/main/java/org/sonar/api/Plugin.java")
            .setParentProjectId(5L);
    when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file));
    when(componentDao.selectOrFailById(session, 5L))
        .thenReturn(
            new ComponentDto()
                .setId(5L)
                .setLongName("SonarQube :: Plugin API")
                .setKey(SUB_PROJECT_KEY));
    when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project);
    when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session)))
        .thenReturn(newArrayList(new PropertyDto()));

    WsTester.TestRequest request =
        tester.newGetRequest("api/components", "app").setParam("uuid", COMPONENT_UUID);
    request.execute().assertJson(getClass(), "app.json");
  }
コード例 #3
0
ファイル: AppActionTest.java プロジェクト: hutea/sonarqube
 private ComponentDto newProject() {
   return ComponentTesting.newProjectDto()
       .setId(1L)
       .setName("SonarQube")
       .setUuid(PROJECT_UUID)
       .setLongName("SonarQube")
       .setKey("org.codehaus.sonar:sonar");
 }
コード例 #4
0
  @Test(expected = ForbiddenException.class)
  public void check_component_dto_permission_ko() {
    UserSession session = newServerUserSession().setLogin("marius").setUserId(1);

    ComponentDto project = ComponentTesting.newProjectDto();
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER))
        .thenReturn(newArrayList(project.uuid()));

    session.checkComponentPermission(UserRole.USER, "another");
  }
コード例 #5
0
  @Test
  public void check_project_uuid_permission_ok() {
    UserSession session = newServerUserSession().setLogin("marius").setUserId(1);

    ComponentDto project = ComponentTesting.newProjectDto();
    when(authorizationDao.selectAuthorizedRootProjectsUuids(1, UserRole.USER))
        .thenReturn(newArrayList(project.uuid()));

    session.checkProjectUuidPermission(UserRole.USER, project.uuid());
  }
  @Test
  public void compute_no_symbol() throws Exception {
    initReport();

    step.execute(
        new ComputationContext(
            new BatchReportReader(reportDir), ComponentTesting.newProjectDto("PROJECT_A")));

    assertThat(step.getSyntaxHighlightingByLine()).isEmpty();
  }
コード例 #7
0
ファイル: AppActionTest.java プロジェクト: hutea/sonarqube
 private ComponentDto newComponent(ComponentDto project) {
   ComponentDto file =
       ComponentTesting.newFileDto(project)
           .setId(10L)
           .setQualifier("FIL")
           .setKey(COMPONENT_KEY)
           .setUuid(COMPONENT_UUID)
           .setProjectUuid(PROJECT_UUID)
           .setName("Plugin.java")
           .setLongName("src/main/java/org/sonar/api/Plugin.java")
           .setPath("src/main/java/org/sonar/api/Plugin.java")
           .setParentProjectId(5L);
   when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file));
   when(componentDao.selectOrFailById(session, 5L))
       .thenReturn(
           new ComponentDto()
               .setId(5L)
               .setLongName("SonarQube :: Plugin API")
               .setKey(SUB_PROJECT_KEY));
   when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project);
   return file;
 }