Search in sources :

Example 6 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_load_project_props.

@Test
public void should_load_project_props() {
    project.setProperty("project.prop", "project");
    projectRef = new ProjectRepositories(emptySettings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("project.prop")).isEqualTo("project");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Example 7 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_fail_when_accessing_secured_properties_in_issues_mode.

@Test
public void should_fail_when_accessing_secured_properties_in_issues_mode() {
    Table<String, String, String> settings = HashBasedTable.create();
    settings.put("struts", "sonar.foo.secured", "bar");
    settings.put("struts", "sonar.foo.license.secured", "bar2");
    when(mode.isIssues()).thenReturn(true);
    projectRef = new ProjectRepositories(settings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
    thrown.expect(MessageException.class);
    thrown.expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
    batchSettings.getString("sonar.foo.secured");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Example 8 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ModuleSettingsTest method should_fail_when_accessing_secured_properties_in_issues.

@Test
public void should_fail_when_accessing_secured_properties_in_issues() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("sonar.foo.secured", "bar"));
    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
    when(mode.isIssues()).thenReturn(true);
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projSettingsRepo, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
    thrown.expect(MessageException.class);
    thrown.expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
    moduleSettings.getString("sonar.foo.secured");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 9 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ModuleSettingsTest method test_loading_of_module_settings.

@Test
public void test_loading_of_module_settings() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("overridding", "batch", "on-batch", "true"));
    ProjectRepositories projRepos = createSettings("struts-core", ImmutableMap.of("on-module", "true", "overridding", "module"));
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projRepos, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 10 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ModuleSettingsTest method should_not_fail_when_accessing_secured_properties.

@Test
public void should_not_fail_when_accessing_secured_properties() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("sonar.foo.secured", "bar"));
    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projSettingsRepo, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
    assertThat(moduleSettings.getString("sonar.foo.secured")).isEqualTo("bar");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Aggregations

ProjectRepositories (org.sonar.scanner.repository.ProjectRepositories)12 Test (org.junit.Test)11 ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)5 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)4 GlobalSettings (org.sonar.scanner.bootstrap.GlobalSettings)4 AnalysisContextReportPublisher (org.sonar.scanner.report.AnalysisContextReportPublisher)4 Date (java.util.Date)1 Before (org.junit.Before)1 FileData (org.sonar.scanner.repository.FileData)1 ProjectRepositoriesProvider (org.sonar.scanner.repository.ProjectRepositoriesProvider)1 StatusDetection (org.sonar.scanner.scan.filesystem.StatusDetection)1