private ComponentDto newProject() { return ComponentTesting.newProjectDto() .setId(1L) .setName("SonarQube") .setUuid(PROJECT_UUID) .setLongName("SonarQube") .setKey("org.codehaus.sonar:sonar"); }
@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"); }
@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(); }
@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"); }