aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2020-12-18 10:27:51 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:38 +0000
commit0f1972c71fd80e613457995ec494bbbc3f57f8a7 (patch)
tree8f07d31026d7f1e4839bc265d913db6407e1cdf2
parentcc838211b1c811ff86156d481b9e7f7fba9c632c (diff)
downloadsonarqube-0f1972c71fd80e613457995ec494bbbc3f57f8a7.tar.gz
sonarqube-0f1972c71fd80e613457995ec494bbbc3f57f8a7.zip
SONAR-13312 drop 'sonar.organization' scanner parameter
- drop unused bitbucket pipelines references
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java7
-rw-r--r--sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalTempFolderProvider.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ProcessedScannerProperties.java60
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java (renamed from sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java)14
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java7
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfilesProvider.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoader.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/EmptyExternalProjectKeyAndOrganization.java38
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganization.java30
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationLoader.java28
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProvider.java53
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranchesProvider.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmRevisionImpl.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java10
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ProcessedScannerPropertiesTest.java45
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java65
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerWsClientProviderTest.java14
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java20
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java29
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesSupplierTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoaderTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProviderTest.java93
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java17
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java15
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesProviderTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProviderTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmRevisionImplTest.java6
44 files changed, 155 insertions, 511 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java b/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
index 3432080c906..a2bd839cc25 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
@@ -31,8 +31,6 @@ public class ScannerProperties {
public static final String BRANCHES_DOC_LINK = "https://redirect.sonarsource.com/doc/branches.html";
- public static final String ORGANIZATION = "sonar.organization";
-
public static final String BRANCH_NAME = "sonar.branch.name";
@Deprecated
public static final String BRANCH_TARGET = "sonar.branch.target";
@@ -64,11 +62,6 @@ public class ScannerProperties {
.category(CoreProperties.CATEGORY_SCM)
.onlyOnQualifiers(Qualifiers.PROJECT)
.build(),
- PropertyDefinition.builder(ORGANIZATION)
- .name("Organization key")
- .description("Key of the organization that contains the project being analyzed. If unset, then the organization marked as default is used.")
- .hidden()
- .build(),
PropertyDefinition.builder(BRANCH_NAME)
.name("Optional name of SonarQube/SCM branch")
.description("Provide a name for the branch being analyzed. It might match an existing branch of the project, otherwise a new branch will be created.")
diff --git a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
index 9140420216a..d1d297c6a27 100644
--- a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
@@ -30,7 +30,7 @@ public class CorePropertyDefinitionsTest {
@Test
public void all() {
List<PropertyDefinition> defs = CorePropertyDefinitions.all();
- assertThat(defs).hasSize(55);
+ assertThat(defs).hasSize(54);
}
@Test
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
index 9eb93129377..c4468eb90e4 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
@@ -30,7 +30,7 @@ public class GlobalAnalysisMode {
protected boolean mediumTestMode;
- public GlobalAnalysisMode(RawScannerProperties props) {
+ public GlobalAnalysisMode(ScannerProperties props) {
mediumTestMode = "true".equals(props.property(MEDIUM_TEST_ENABLED));
if (mediumTestMode) {
LOG.info("Medium test mode");
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java
index c72f7ef089b..efc9db8abe7 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java
@@ -28,7 +28,7 @@ public class GlobalConfigurationProvider extends ProviderAdapter {
private GlobalConfiguration globalConfig;
- public GlobalConfiguration provide(GlobalServerSettings globalServerSettings, RawScannerProperties scannerProps,
+ public GlobalConfiguration provide(GlobalServerSettings globalServerSettings, ScannerProperties scannerProps,
PropertyDefinitions propertyDefinitions) {
if (globalConfig == null) {
Map<String, String> mergedSettings = new LinkedHashMap<>();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
index 9dfd4d3367d..42aa1bb7064 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
@@ -74,7 +74,7 @@ public class GlobalContainer extends ComponentContainer {
@Override
protected void doBeforeStart() {
- RawScannerProperties rawScannerProperties = new RawScannerProperties(scannerProperties);
+ ScannerProperties rawScannerProperties = new ScannerProperties(scannerProperties);
GlobalAnalysisMode globalMode = new GlobalAnalysisMode(rawScannerProperties);
add(rawScannerProperties);
add(globalMode);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalTempFolderProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalTempFolderProvider.java
index 913fa7866b8..7456a587749 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalTempFolderProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalTempFolderProvider.java
@@ -56,7 +56,7 @@ public class GlobalTempFolderProvider extends ProviderAdapter implements Compone
this.system = system;
}
- public TempFolder provide(RawScannerProperties scannerProps) {
+ public TempFolder provide(ScannerProperties scannerProps) {
if (tempFolder == null) {
String workingPathName = StringUtils.defaultIfBlank(scannerProps.property(CoreProperties.GLOBAL_WORKING_DIRECTORY), CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE);
@@ -95,7 +95,7 @@ public class GlobalTempFolderProvider extends ProviderAdapter implements Compone
}
}
- private Path findSonarHome(RawScannerProperties props) {
+ private Path findSonarHome(ScannerProperties props) {
String home = props.property("sonar.userHome");
if (home != null) {
return Paths.get(home).toAbsolutePath();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ProcessedScannerProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ProcessedScannerProperties.java
deleted file mode 100644
index a8ca80adc2f..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ProcessedScannerProperties.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.bootstrap;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import javax.annotation.concurrent.Immutable;
-import org.sonar.scanner.scan.ExternalProjectKeyAndOrganization;
-
-import static org.sonar.api.CoreProperties.PROJECT_KEY_PROPERTY;
-
-/**
- * Properties that are coming from scanner.
- */
-@Immutable
-public class ProcessedScannerProperties {
-
- private final Map<String, String> properties;
-
- public ProcessedScannerProperties(RawScannerProperties rawScannerProperties,
- ExternalProjectKeyAndOrganization externalProjectKeyAndOrganization) {
- this.properties = new HashMap<>();
- this.properties.putAll(rawScannerProperties.properties());
-
- externalProjectKeyAndOrganization.getProjectKey()
- .ifPresent(projectKey -> properties.put(PROJECT_KEY_PROPERTY, projectKey));
- externalProjectKeyAndOrganization.getOrganization()
- .ifPresent(organization -> properties.put(org.sonar.core.config.ScannerProperties.ORGANIZATION, organization));
- }
-
- public Map<String, String> properties() {
- return Collections.unmodifiableMap(new HashMap<>(properties));
- }
-
- public String property(String key) {
- return properties.get(key);
- }
-
- public String getProjectKey() {
- return this.properties.get(PROJECT_KEY_PROPERTY);
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java
index 8d468a0cbeb..1316642836b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java
@@ -23,20 +23,22 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.concurrent.Immutable;
-import org.sonar.api.CoreProperties;
import org.sonar.api.config.internal.Encryption;
+import static org.sonar.api.CoreProperties.ENCRYPTION_SECRET_KEY_PATH;
+import static org.sonar.api.CoreProperties.PROJECT_KEY_PROPERTY;
+
/**
* Properties that are coming from scanner.
*/
@Immutable
-public class RawScannerProperties {
+public class ScannerProperties {
private final Map<String, String> properties;
private final Encryption encryption;
- public RawScannerProperties(Map<String, String> properties) {
- encryption = new Encryption(properties.get(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
+ public ScannerProperties(Map<String, String> properties) {
+ encryption = new Encryption(properties.get(ENCRYPTION_SECRET_KEY_PATH));
Map<String, String> decryptedProps = new HashMap<>(properties.size());
for (Map.Entry<String, String> entry : properties.entrySet()) {
String value = entry.getValue();
@@ -63,4 +65,8 @@ public class RawScannerProperties {
public String property(String key) {
return properties.get(key);
}
+
+ public String getProjectKey() {
+ return properties.get(PROJECT_KEY_PROPERTY);
+ }
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java
index 6c3bfd7718b..ea5cf27ee38 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java
@@ -38,7 +38,7 @@ public class ScannerWsClientProvider extends ProviderAdapter {
private DefaultScannerWsClient wsClient;
- public synchronized DefaultScannerWsClient provide(final RawScannerProperties scannerProps,
+ public synchronized DefaultScannerWsClient provide(final ScannerProperties scannerProps,
final EnvironmentInformation env, GlobalAnalysisMode globalMode, System2 system) {
if (wsClient == null) {
String url = defaultIfBlank(scannerProps.property("sonar.host.url"), "http://localhost:9000");
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
index f1513799d45..70e53add993 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
@@ -41,7 +41,6 @@ import org.sonar.scanner.protocol.output.ScannerReportWriter;
import org.sonar.scanner.repository.ForkDateSupplier;
import org.sonar.scanner.rule.QProfile;
import org.sonar.scanner.rule.QualityProfiles;
-import org.sonar.scanner.scan.ScanProperties;
import org.sonar.scanner.scan.branch.BranchConfiguration;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
import org.sonar.scanner.scm.ScmConfiguration;
@@ -51,7 +50,6 @@ public class MetadataPublisher implements ReportPublisherStep {
private static final Logger LOG = Loggers.get(MetadataPublisher.class);
- private final ScanProperties properties;
private final QualityProfiles qProfiles;
private final ProjectInfo projectInfo;
private final InputModuleHierarchy moduleHierarchy;
@@ -63,12 +61,11 @@ public class MetadataPublisher implements ReportPublisherStep {
private final InputComponentStore componentStore;
private final ScmConfiguration scmConfiguration;
- public MetadataPublisher(ProjectInfo projectInfo, InputModuleHierarchy moduleHierarchy, ScanProperties properties,
- QualityProfiles qProfiles, CpdSettings cpdSettings, ScannerPluginRepository pluginRepository, BranchConfiguration branchConfiguration,
+ public MetadataPublisher(ProjectInfo projectInfo, InputModuleHierarchy moduleHierarchy, QualityProfiles qProfiles,
+ CpdSettings cpdSettings, ScannerPluginRepository pluginRepository, BranchConfiguration branchConfiguration,
ScmRevision scmRevision, ForkDateSupplier forkDateSupplier, InputComponentStore componentStore, ScmConfiguration scmConfiguration) {
this.projectInfo = projectInfo;
this.moduleHierarchy = moduleHierarchy;
- this.properties = properties;
this.qProfiles = qProfiles;
this.cpdSettings = cpdSettings;
this.pluginRepository = pluginRepository;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
index 323f76096be..4e20af54b31 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
@@ -184,7 +184,6 @@ public class ReportPublisher implements Startable {
PostRequest.Part filePart = new PostRequest.Part(MediaTypes.ZIP, report);
PostRequest post = new PostRequest("api/ce/submit")
.setMediaType(MediaTypes.PROTOBUF)
- .setParam("organization", properties.organizationKey().orElse(null))
.setParam("projectKey", moduleHierarchy.root().key())
.setParam("projectName", moduleHierarchy.root().getOriginalName())
.setPart("report", filePart);
@@ -219,7 +218,6 @@ public class ReportPublisher implements Startable {
void prepareAndDumpMetadata(String taskId) {
Map<String, String> metadata = new LinkedHashMap<>();
- properties.organizationKey().ifPresent(org -> metadata.put("organization", org));
metadata.put("projectKey", moduleHierarchy.root().key());
metadata.put("serverUrl", server.getPublicRootUrl());
metadata.put("serverVersion", server.getVersion());
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java
index 6958bbbcc64..4080fe9cba2 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java
@@ -29,7 +29,6 @@ import java.util.function.BinaryOperator;
import java.util.function.Supplier;
import org.sonar.api.utils.MessageException;
import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
-import org.sonar.scanner.scan.ScanProperties;
import org.sonarqube.ws.Qualityprofiles.SearchWsResponse;
import org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile;
import org.sonarqube.ws.client.GetRequest;
@@ -43,10 +42,8 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader {
private static final String WS_URL = "/api/qualityprofiles/search.protobuf";
private final DefaultScannerWsClient wsClient;
- private final ScanProperties properties;
- public DefaultQualityProfileLoader(ScanProperties properties, DefaultScannerWsClient wsClient) {
- this.properties = properties;
+ public DefaultQualityProfileLoader(DefaultScannerWsClient wsClient) {
this.wsClient = wsClient;
}
@@ -81,7 +78,6 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader {
}
private List<QualityProfile> doLoad(StringBuilder url) throws IOException {
- properties.organizationKey().ifPresent(k -> url.append("&organization=").append(encodeForUrl(k)));
Map<String, QualityProfile> result = call(url.toString());
if (result.isEmpty()) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
index 95edbdfc06d..be762b01915 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
@@ -23,19 +23,19 @@ import java.util.function.Supplier;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.scan.branch.BranchConfiguration;
public class ProjectRepositoriesSupplier implements Supplier<ProjectRepositories> {
private static final Logger LOG = Loggers.get(ProjectRepositoriesSupplier.class);
private static final String LOG_MSG = "Load project repositories";
private final ProjectRepositoriesLoader loader;
- private final ProcessedScannerProperties scannerProperties;
+ private final ScannerProperties scannerProperties;
private final BranchConfiguration branchConfig;
private ProjectRepositories project = null;
- public ProjectRepositoriesSupplier(ProjectRepositoriesLoader loader, ProcessedScannerProperties scannerProperties, BranchConfiguration branchConfig) {
+ public ProjectRepositoriesSupplier(ProjectRepositoriesLoader loader, ScannerProperties scannerProperties, BranchConfiguration branchConfig) {
this.loader = loader;
this.scannerProperties = scannerProperties;
this.branchConfig = branchConfig;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfilesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfilesProvider.java
index 51b520d33b3..da570ee9968 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfilesProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfilesProvider.java
@@ -23,7 +23,7 @@ import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.rule.QualityProfiles;
public class QualityProfilesProvider extends ProviderAdapter {
@@ -31,7 +31,7 @@ public class QualityProfilesProvider extends ProviderAdapter {
private static final String LOG_MSG = "Load quality profiles";
private QualityProfiles profiles = null;
- public QualityProfiles provide(QualityProfileLoader loader, ProcessedScannerProperties props) {
+ public QualityProfiles provide(QualityProfileLoader loader, ScannerProperties props) {
if (this.profiles == null) {
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
profiles = new QualityProfiles(loader.load(props.getProjectKey()));
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoader.java
index cd54bd3daf4..91aa811db49 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoader.java
@@ -20,13 +20,13 @@
package org.sonar.scanner.repository.settings;
import java.util.Map;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
+import org.sonar.scanner.bootstrap.ScannerProperties;
public class DefaultProjectSettingsLoader extends AbstractSettingsLoader implements ProjectSettingsLoader {
- private final ProcessedScannerProperties scannerProperties;
+ private final ScannerProperties scannerProperties;
- public DefaultProjectSettingsLoader(final DefaultScannerWsClient wsClient, final ProcessedScannerProperties scannerProperties) {
+ public DefaultProjectSettingsLoader(final DefaultScannerWsClient wsClient, final ScannerProperties scannerProperties) {
super(wsClient);
this.scannerProperties = scannerProperties;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/EmptyExternalProjectKeyAndOrganization.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/EmptyExternalProjectKeyAndOrganization.java
deleted file mode 100644
index ebdcf31086c..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/EmptyExternalProjectKeyAndOrganization.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import java.util.Optional;
-import javax.annotation.concurrent.Immutable;
-
-import static java.util.Optional.empty;
-
-@Immutable
-public class EmptyExternalProjectKeyAndOrganization implements ExternalProjectKeyAndOrganization {
- @Override
- public Optional<String> getProjectKey() {
- return empty();
- }
-
- @Override
- public Optional<String> getOrganization() {
- return empty();
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganization.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganization.java
deleted file mode 100644
index e0f45e16d63..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganization.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import java.util.Optional;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public interface ExternalProjectKeyAndOrganization {
- Optional<String> getProjectKey();
-
- Optional<String> getOrganization();
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationLoader.java
deleted file mode 100644
index ac8ac890ae6..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationLoader.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import java.util.Optional;
-import org.sonar.api.scanner.ScannerSide;
-
-@ScannerSide
-public interface ExternalProjectKeyAndOrganizationLoader {
- Optional<ExternalProjectKeyAndOrganization> load();
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProvider.java
deleted file mode 100644
index 243067bcfe5..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProvider.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import org.picocontainer.annotations.Nullable;
-import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.scanner.bootstrap.RawScannerProperties;
-
-import static org.apache.commons.lang.StringUtils.equalsIgnoreCase;
-import static org.sonar.core.config.ScannerProperties.DISABLE_PROJECT_AND_ORG_AUTODETECTION;
-
-public class ExternalProjectKeyAndOrganizationProvider extends ProviderAdapter {
- private static final Logger LOG = Loggers.get(ExternalProjectKeyAndOrganizationProvider.class);
- private ExternalProjectKeyAndOrganization properties = null;
-
- public ExternalProjectKeyAndOrganization provide(RawScannerProperties rawScannerProperties,
- @Nullable @javax.annotation.Nullable ExternalProjectKeyAndOrganizationLoader loader) {
- if (properties == null) {
- boolean disableProjectKeyAndOrgAutodetection = equalsIgnoreCase(
- rawScannerProperties.property(DISABLE_PROJECT_AND_ORG_AUTODETECTION), "true");
- if (disableProjectKeyAndOrgAutodetection) {
- LOG.info("Skipping project and organization key auto-detection.");
- }
-
- if (loader != null && !disableProjectKeyAndOrgAutodetection) {
- properties = loader.load().orElse(new EmptyExternalProjectKeyAndOrganization());
- } else {
- properties = new EmptyExternalProjectKeyAndOrganization();
- }
- }
-
- return properties;
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
index e4134169b41..74c098e8b00 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
@@ -45,7 +45,7 @@ import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
import org.sonar.core.config.IssueExclusionProperties;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer;
@@ -104,12 +104,12 @@ public class ProjectReactorBuilder {
private static final List<String> NON_HERITED_PROPERTIES_FOR_CHILD = Stream.concat(Stream.of(PROPERTY_PROJECT_BASEDIR, CoreProperties.WORKING_DIRECTORY, PROPERTY_MODULES,
CoreProperties.PROJECT_DESCRIPTION_PROPERTY), UNSUPPORTED_PROPS_FOR_MODULES.stream()).collect(toList());
- private final ProcessedScannerProperties scannerProps;
+ private final ScannerProperties scannerProps;
private final AnalysisWarnings analysisWarnings;
private File rootProjectWorkDir;
private boolean warnExclusionsAlreadyLogged;
- public ProjectReactorBuilder(ProcessedScannerProperties props, AnalysisWarnings analysisWarnings) {
+ public ProjectReactorBuilder(ScannerProperties props, AnalysisWarnings analysisWarnings) {
this.scannerProps = props;
this.analysisWarnings = analysisWarnings;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index 30aac02d9f1..cff29808988 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -44,7 +44,6 @@ import org.sonar.scanner.bootstrap.ExtensionMatcher;
import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
import org.sonar.scanner.bootstrap.MetricProvider;
import org.sonar.scanner.bootstrap.PostJobExtensionDictionnary;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
import org.sonar.scanner.ci.CiConfigurationProvider;
import org.sonar.scanner.ci.vendors.AppVeyor;
import org.sonar.scanner.ci.vendors.AzureDevops;
@@ -159,8 +158,6 @@ public class ProjectScanContainer extends ComponentContainer {
private void addScannerComponents() {
add(
- new ExternalProjectKeyAndOrganizationProvider(),
- ProcessedScannerProperties.class,
ScanProperties.class,
ProjectReactorBuilder.class,
WorkDirectoriesInitializer.class,
@@ -336,7 +333,6 @@ public class ProjectScanContainer extends ComponentContainer {
ScanProperties properties = getComponentByType(ScanProperties.class);
properties.validate();
- properties.organizationKey().ifPresent(k -> LOG.info("Organization key: {}", k));
properties.get("sonar.branch").ifPresent(deprecatedBranch -> {
throw MessageException.of("The 'sonar.branch' parameter is no longer supported. You should stop using it. " +
"Branch analysis is available in Developer Edition and above. See https://redirect.sonarsource.com/editions/developer.html for more information.");
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
index 133f014e263..0c600182016 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
@@ -27,7 +27,6 @@ import org.sonar.api.config.Configuration;
import org.sonar.api.utils.MessageException;
import static org.sonar.core.config.ScannerProperties.BRANCH_NAME;
-import static org.sonar.core.config.ScannerProperties.ORGANIZATION;
/**
* Properties that can be passed to the scanners and are not exposed in SonarQube.
@@ -60,10 +59,6 @@ public class ScanProperties {
return configuration.getBoolean(PRELOAD_FILE_METADATA_KEY).orElse(false);
}
- public Optional<String> organizationKey() {
- return configuration.get(ORGANIZATION);
- }
-
public Optional<String> branch() {
return configuration.get(BRANCH_NAME);
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranchesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranchesProvider.java
index 0e4cc266258..e7cc510c5e8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranchesProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranchesProvider.java
@@ -25,7 +25,7 @@ import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
public class ProjectBranchesProvider extends ProviderAdapter {
@@ -34,7 +34,7 @@ public class ProjectBranchesProvider extends ProviderAdapter {
private ProjectBranches branches = null;
- public ProjectBranches provide(@Nullable ProjectBranchesLoader loader, ProcessedScannerProperties scannerProperties) {
+ public ProjectBranches provide(@Nullable ProjectBranchesLoader loader, ScannerProperties scannerProperties) {
if (this.branches != null) {
return this.branches;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java
index 35012cc3ec2..f0d6582174f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java
@@ -24,7 +24,7 @@ import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
public class ProjectPullRequestsProvider extends ProviderAdapter {
@@ -33,7 +33,7 @@ public class ProjectPullRequestsProvider extends ProviderAdapter {
private ProjectPullRequests pullRequests = null;
- public ProjectPullRequests provide(@org.picocontainer.annotations.Nullable ProjectPullRequestsLoader loader, ProcessedScannerProperties scannerProperties) {
+ public ProjectPullRequests provide(@org.picocontainer.annotations.Nullable ProjectPullRequestsLoader loader, ScannerProperties scannerProperties) {
if (pullRequests != null) {
return pullRequests;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmRevisionImpl.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmRevisionImpl.java
index f4c1fad464d..c9fd38d2517 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmRevisionImpl.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmRevisionImpl.java
@@ -23,7 +23,7 @@ import java.util.Optional;
import org.sonar.api.batch.scm.ScmProvider;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.scanner.bootstrap.RawScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.ci.CiConfiguration;
import org.sonar.scanner.fs.InputModuleHierarchy;
@@ -35,11 +35,11 @@ public class ScmRevisionImpl implements ScmRevision {
private static final Logger LOG = Loggers.get(ScmRevisionImpl.class);
private final CiConfiguration ciConfiguration;
- private final RawScannerProperties scannerConfiguration;
+ private final ScannerProperties scannerConfiguration;
private final ScmConfiguration scmConfiguration;
private final InputModuleHierarchy moduleHierarchy;
- public ScmRevisionImpl(CiConfiguration ciConfiguration, RawScannerProperties scannerConfiguration, ScmConfiguration scmConfiguration, InputModuleHierarchy moduleHierarchy) {
+ public ScmRevisionImpl(CiConfiguration ciConfiguration, ScannerProperties scannerConfiguration, ScmConfiguration scmConfiguration, InputModuleHierarchy moduleHierarchy) {
this.ciConfiguration = ciConfiguration;
this.scannerConfiguration = scannerConfiguration;
this.scmConfiguration = scmConfiguration;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
index 3578d8c4a65..e51054f190e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
@@ -58,7 +58,7 @@ public class DefaultScannerWsClientTest {
logTester.setLevel(LoggerLevel.DEBUG);
DefaultScannerWsClient underTest = new DefaultScannerWsClient(wsClient, false, new GlobalAnalysisMode(
- new RawScannerProperties(Collections.emptyMap())));
+ new ScannerProperties(Collections.emptyMap())));
WsResponse result = underTest.call(request);
@@ -99,7 +99,7 @@ public class DefaultScannerWsClientTest {
WsResponse response = newResponse().setCode(401);
when(wsClient.wsConnector().call(request)).thenReturn(response);
- new DefaultScannerWsClient(wsClient, false, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap()))).call(request);
+ new DefaultScannerWsClient(wsClient, false, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()))).call(request);
}
@Test
@@ -111,7 +111,7 @@ public class DefaultScannerWsClientTest {
WsResponse response = newResponse().setCode(401);
when(wsClient.wsConnector().call(request)).thenReturn(response);
- new DefaultScannerWsClient(wsClient, /* credentials are configured */true, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap()))).call(request);
+ new DefaultScannerWsClient(wsClient, /* credentials are configured */true, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()))).call(request);
}
@Test
@@ -124,7 +124,7 @@ public class DefaultScannerWsClientTest {
.setCode(403);
when(wsClient.wsConnector().call(request)).thenReturn(response);
- new DefaultScannerWsClient(wsClient, true, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap()))).call(request);
+ new DefaultScannerWsClient(wsClient, true, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()))).call(request);
}
@Test
@@ -138,7 +138,7 @@ public class DefaultScannerWsClientTest {
.setContent("{\"errors\":[{\"msg\":\"Boo! bad request! bad!\"}]}");
when(wsClient.wsConnector().call(request)).thenReturn(response);
- new DefaultScannerWsClient(wsClient, true, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap()))).call(request);
+ new DefaultScannerWsClient(wsClient, true, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()))).call(request);
}
private MockWsResponse newResponse() {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
index 2b57667e501..360c9138d50 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
@@ -41,12 +41,12 @@ public class GlobalConfigurationProviderTest {
public LogTester logTester = new LogTester();
GlobalServerSettings globalServerSettings;
- RawScannerProperties scannerProps;
+ ScannerProperties scannerProps;
@Before
public void prepare() {
globalServerSettings = mock(GlobalServerSettings.class);
- scannerProps = new RawScannerProperties(Collections.emptyMap());
+ scannerProps = new ScannerProperties(Collections.emptyMap());
}
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
index 3db5b63b450..652fedb8733 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
@@ -52,7 +52,7 @@ public class GlobalTempFolderProviderTest {
workingDir.delete();
TempFolder tempFolder = tempFolderProvider.provide(
- new RawScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.getAbsolutePath())));
+ new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.getAbsolutePath())));
tempFolder.newDir();
tempFolder.newFile();
assertThat(getCreatedTempDir(workingDir)).exists();
@@ -73,7 +73,7 @@ public class GlobalTempFolderProviderTest {
}
tempFolderProvider.provide(
- new RawScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.getAbsolutePath())));
+ new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.getAbsolutePath())));
// this also checks that all other temps were deleted
assertThat(getCreatedTempDir(workingDir)).exists();
@@ -87,7 +87,7 @@ public class GlobalTempFolderProviderTest {
File workingDir = new File(sonarHome, CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE).getAbsoluteFile();
TempFolder tempFolder = tempFolderProvider.provide(
- new RawScannerProperties(ImmutableMap.of("sonar.userHome", sonarHome.getAbsolutePath())));
+ new ScannerProperties(ImmutableMap.of("sonar.userHome", sonarHome.getAbsolutePath())));
tempFolder.newDir();
tempFolder.newFile();
assertThat(getCreatedTempDir(workingDir)).exists();
@@ -110,7 +110,7 @@ public class GlobalTempFolderProviderTest {
File workingDir = new File(defaultSonarHome, CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE).getAbsoluteFile();
try {
TempFolder tempFolder = tempFolderProvider.provide(
- new RawScannerProperties(Collections.emptyMap()));
+ new ScannerProperties(Collections.emptyMap()));
tempFolder.newDir();
tempFolder.newFile();
assertThat(getCreatedTempDir(workingDir)).exists();
@@ -124,7 +124,7 @@ public class GlobalTempFolderProviderTest {
public void dotWorkingDir() {
File sonarHome = temp.getRoot();
String globalWorkDir = ".";
- RawScannerProperties globalProperties = new RawScannerProperties(
+ ScannerProperties globalProperties = new ScannerProperties(
ImmutableMap.of("sonar.userHome", sonarHome.getAbsolutePath(), CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
TempFolder tempFolder = tempFolderProvider.provide(globalProperties);
@@ -140,7 +140,7 @@ public class GlobalTempFolderProviderTest {
File symlink = temp.newFolder();
symlink.delete();
Files.createSymbolicLink(symlink.toPath(), realSonarHome.toPath());
- RawScannerProperties globalProperties = new RawScannerProperties(ImmutableMap.of("sonar.userHome", symlink.getAbsolutePath()));
+ ScannerProperties globalProperties = new ScannerProperties(ImmutableMap.of("sonar.userHome", symlink.getAbsolutePath()));
TempFolder tempFolder = tempFolderProvider.provide(globalProperties);
File newFile = tempFolder.newFile();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
index dd6d43348bd..8bf01c1310b 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
@@ -73,7 +73,7 @@ public class PluginFilesTest {
@Before
public void setUp() throws Exception {
HttpConnector connector = HttpConnector.newBuilder().url(server.url("/").toString()).build();
- GlobalAnalysisMode analysisMode = new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap()));
+ GlobalAnalysisMode analysisMode = new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()));
DefaultScannerWsClient wsClient = new DefaultScannerWsClient(WsClientFactories.getDefault().newClient(connector), false, analysisMode);
userHome = temp.newFolder();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ProcessedScannerPropertiesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ProcessedScannerPropertiesTest.java
deleted file mode 100644
index c13d109b7ae..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ProcessedScannerPropertiesTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.bootstrap;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Test;
-import org.sonar.scanner.scan.EmptyExternalProjectKeyAndOrganization;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.entry;
-
-public class ProcessedScannerPropertiesTest {
- @Test
- public void test_copy_of_properties() {
- Map<String, String> map = new HashMap<>();
- map.put("foo", "bar");
-
- ProcessedScannerProperties underTest = new ProcessedScannerProperties(
- new RawScannerProperties(map),
- new EmptyExternalProjectKeyAndOrganization());
- assertThat(underTest.properties()).containsOnly(entry("foo", "bar"));
- assertThat(underTest.properties()).isNotSameAs(map);
-
- map.put("put", "after_copy");
- assertThat(underTest.properties()).hasSize(1);
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java
new file mode 100644
index 00000000000..ce96f9d042e
--- /dev/null
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java
@@ -0,0 +1,65 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.scanner.bootstrap;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class ScannerPropertiesTest {
+
+ @Test
+ public void initialization() {
+ ImmutableMap<String, String> map = ImmutableMap.<String, String>builder()
+ .put("prop-1", "{b64}Zm9v")
+ .put("sonar.projectKey", "my-project")
+ .build();
+ ScannerProperties underTest = new ScannerProperties(map);
+
+ assertThat(underTest.getEncryption()).isNotNull();
+ assertThat(underTest.properties())
+ .containsEntry("prop-1", "foo")
+ .containsEntry("sonar.projectKey", "my-project");
+ assertThat(underTest.getProjectKey()).isEqualTo("my-project");
+ }
+
+ @Test
+ public void encryption_fail() {
+ ImmutableMap<String, String> map = ImmutableMap.<String, String>builder()
+ .put("prop-1", "{aes}Zm9vzxc")
+ .build();
+ assertThatThrownBy(() -> new ScannerProperties(map))
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("Fail to decrypt the property");
+ }
+
+ @Test
+ public void encryption_ok() {
+ ImmutableMap<String, String> map = ImmutableMap.<String, String>builder()
+ .put("prop-1", "{b64}Zm9v")
+ .build();
+ ScannerProperties underTest = new ScannerProperties(map);
+
+ assertThat(underTest.property("prop-1")).isEqualTo("foo");
+ }
+
+}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerWsClientProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerWsClientProviderTest.java
index 3aa081c7abd..cff5e326981 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerWsClientProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerWsClientProviderTest.java
@@ -37,9 +37,9 @@ public class ScannerWsClientProviderTest {
@Test
public void provide_client_with_default_settings() {
- RawScannerProperties settings = new RawScannerProperties(new HashMap<>());
+ ScannerProperties settings = new ScannerProperties(new HashMap<>());
- DefaultScannerWsClient client = underTest.provide(settings, env, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap())), mock(System2.class));
+ DefaultScannerWsClient client = underTest.provide(settings, env, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap())), mock(System2.class));
assertThat(client).isNotNull();
assertThat(client.baseUrl()).isEqualTo("http://localhost:9000/");
@@ -57,9 +57,9 @@ public class ScannerWsClientProviderTest {
props.put("sonar.login", "theLogin");
props.put("sonar.password", "thePassword");
props.put("sonar.ws.timeout", "42");
- RawScannerProperties settings = new RawScannerProperties(props);
+ ScannerProperties settings = new ScannerProperties(props);
- DefaultScannerWsClient client = underTest.provide(settings, env, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap())), mock(System2.class));
+ DefaultScannerWsClient client = underTest.provide(settings, env, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap())), mock(System2.class));
assertThat(client).isNotNull();
HttpConnector httpConnector = (HttpConnector) client.wsConnector();
@@ -71,9 +71,9 @@ public class ScannerWsClientProviderTest {
public void build_singleton() {
System2 system = mock(System2.class);
- RawScannerProperties settings = new RawScannerProperties(new HashMap<>());
- DefaultScannerWsClient first = underTest.provide(settings, env, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap())), system);
- DefaultScannerWsClient second = underTest.provide(settings, env, new GlobalAnalysisMode(new RawScannerProperties(Collections.emptyMap())), system);
+ ScannerProperties settings = new ScannerProperties(new HashMap<>());
+ DefaultScannerWsClient first = underTest.provide(settings, env, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap())), system);
+ DefaultScannerWsClient second = underTest.provide(settings, env, new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap())), system);
assertThat(first).isSameAs(second);
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
index 01a995dda20..4f91b85e291 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
@@ -53,7 +53,6 @@ import org.sonar.scanner.protocol.output.ScannerReportWriter;
import org.sonar.scanner.repository.ForkDateSupplier;
import org.sonar.scanner.rule.QProfile;
import org.sonar.scanner.rule.QualityProfiles;
-import org.sonar.scanner.scan.ScanProperties;
import org.sonar.scanner.scan.branch.BranchConfiguration;
import org.sonar.scanner.scan.branch.BranchType;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
@@ -75,7 +74,6 @@ public class MetadataPublisherTest {
public TemporaryFolder temp = new TemporaryFolder();
private MetadataPublisher underTest;
- private final ScanProperties properties = mock(ScanProperties.class);
private final QualityProfiles qProfiles = mock(QualityProfiles.class);
private final ProjectInfo projectInfo = mock(ProjectInfo.class);
private final CpdSettings cpdSettings = mock(CpdSettings.class);
@@ -117,7 +115,7 @@ public class MetadataPublisherTest {
branches = mock(BranchConfiguration.class);
scmConfiguration = mock(ScmConfiguration.class);
when(scmConfiguration.provider()).thenReturn(scmProvider);
- underTest = new MetadataPublisher(projectInfo, inputModuleHierarchy, properties, qProfiles, cpdSettings,
+ underTest = new MetadataPublisher(projectInfo, inputModuleHierarchy, qProfiles, cpdSettings,
pluginRepository, branches, scmRevision, forkDateSupplier, componentStore, scmConfiguration);
}
@@ -176,7 +174,6 @@ public class MetadataPublisherTest {
@UseDataProvider("projectVersions")
public void write_project_version(@Nullable String projectVersion, String expected) throws Exception {
when(projectInfo.getProjectVersion()).thenReturn(Optional.ofNullable(projectVersion));
- when(properties.organizationKey()).thenReturn(Optional.of("SonarSource"));
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
@@ -203,7 +200,6 @@ public class MetadataPublisherTest {
@UseDataProvider("buildStrings")
public void write_buildString(@Nullable String buildString, String expected) throws Exception {
when(projectInfo.getBuildString()).thenReturn(Optional.ofNullable(buildString));
- when(properties.organizationKey()).thenReturn(Optional.of("SonarSource"));
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
index 211e1a062d3..460c3b507d5 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
@@ -25,7 +25,6 @@ import java.io.PipedOutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -97,11 +96,9 @@ public class ReportPublisherTest {
@Test
public void dump_information_about_report_uploading() throws IOException {
- when(properties.organizationKey()).thenReturn(Optional.of("MyOrg"));
underTest.prepareAndDumpMetadata("TASK-123");
assertThat(readFileToString(properties.metadataFilePath().toFile(), StandardCharsets.UTF_8)).isEqualTo(
- "organization=MyOrg\n" +
"projectKey=org.sonarsource.sonarqube:sonarqube\n" +
"serverUrl=https://localhost\n" +
"serverVersion=6.4\n" +
@@ -249,8 +246,6 @@ public class ReportPublisherTest {
@Test
public void test_ws_parameters() throws Exception {
- when(properties.organizationKey()).thenReturn(Optional.of("MyOrg"));
-
WsResponse response = mock(WsResponse.class);
PipedOutputStream out = new PipedOutputStream();
@@ -268,16 +263,12 @@ public class ReportPublisherTest {
verify(wsClient).call(capture.capture());
WsRequest wsRequest = capture.getValue();
- assertThat(wsRequest.getParameters().getKeys()).containsOnly("organization", "projectKey");
- assertThat(wsRequest.getParameters().getValue("organization")).isEqualTo("MyOrg");
+ assertThat(wsRequest.getParameters().getKeys()).containsOnly("projectKey");
assertThat(wsRequest.getParameters().getValue("projectKey")).isEqualTo("org.sonarsource.sonarqube:sonarqube");
}
@Test
public void test_send_branches_characteristics() throws Exception {
- String orgName = "MyOrg";
- when(properties.organizationKey()).thenReturn(Optional.of(orgName));
-
String branchName = "feature";
when(branchConfiguration.branchName()).thenReturn(branchName);
when(branchConfiguration.branchType()).thenReturn(BRANCH);
@@ -299,8 +290,7 @@ public class ReportPublisherTest {
verify(wsClient).call(capture.capture());
WsRequest wsRequest = capture.getValue();
- assertThat(wsRequest.getParameters().getKeys()).hasSize(3);
- assertThat(wsRequest.getParameters().getValues("organization")).containsExactly(orgName);
+ assertThat(wsRequest.getParameters().getKeys()).hasSize(2);
assertThat(wsRequest.getParameters().getValues("projectKey")).containsExactly("org.sonarsource.sonarqube:sonarqube");
assertThat(wsRequest.getParameters().getValues("characteristic"))
.containsExactlyInAnyOrder("branch=" + branchName, "branchType=" + BRANCH.name());
@@ -308,9 +298,6 @@ public class ReportPublisherTest {
@Test
public void send_pull_request_characteristic() throws Exception {
- String orgName = "MyOrg";
- when(properties.organizationKey()).thenReturn(Optional.of(orgName));
-
String branchName = "feature";
String pullRequestId = "pr-123";
when(branchConfiguration.branchName()).thenReturn(branchName);
@@ -334,8 +321,7 @@ public class ReportPublisherTest {
verify(wsClient).call(capture.capture());
WsRequest wsRequest = capture.getValue();
- assertThat(wsRequest.getParameters().getKeys()).hasSize(3);
- assertThat(wsRequest.getParameters().getValues("organization")).containsExactly(orgName);
+ assertThat(wsRequest.getParameters().getKeys()).hasSize(2);
assertThat(wsRequest.getParameters().getValues("projectKey")).containsExactly("org.sonarsource.sonarqube:sonarqube");
assertThat(wsRequest.getParameters().getValues("characteristic"))
.containsExactlyInAnyOrder("pullRequest=" + pullRequestId);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java
index ae721b16148..5d1a4381a1b 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java
@@ -23,7 +23,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -37,15 +36,14 @@ import org.sonarqube.ws.client.HttpException;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
public class DefaultQualityProfileLoaderTest {
@Rule
public ExpectedException exception = ExpectedException.none();
- private DefaultScannerWsClient wsClient = mock(DefaultScannerWsClient.class);
- private ScanProperties properties = mock(ScanProperties.class);
- private DefaultQualityProfileLoader underTest = new DefaultQualityProfileLoader(properties, wsClient);
+ private final DefaultScannerWsClient wsClient = mock(DefaultScannerWsClient.class);
+ private final ScanProperties properties = mock(ScanProperties.class);
+ private final DefaultQualityProfileLoader underTest = new DefaultQualityProfileLoader(wsClient);
@Test
public void load_gets_all_profiles_for_specified_project() throws IOException {
@@ -62,14 +60,6 @@ public class DefaultQualityProfileLoaderTest {
}
@Test
- public void load_sets_organization_parameter_if_defined_in_settings() throws IOException {
- when(properties.organizationKey()).thenReturn(Optional.of("my-org"));
- prepareCallWithResults();
- underTest.load("foo");
- verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo&organization=my-org");
- }
-
- @Test
public void load_tries_default_if_no_profiles_found_for_project() throws IOException {
HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No project found with key 'foo'\"}]}");
WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo", e);
@@ -82,19 +72,6 @@ public class DefaultQualityProfileLoaderTest {
}
@Test
- public void loadDefault_sets_organization_parameter_if_defined_in_settings() throws IOException {
- when(properties.organizationKey()).thenReturn(Optional.of("my-org"));
-
- HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No organization with key 'myorg'\"}]}");
- WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo&organization=my-org", e);
- WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true&organization=my-org", createStreamOfProfiles("qp"));
-
- underTest.load("foo");
-
- verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true&organization=my-org");
- }
-
- @Test
public void load_throws_MessageException_if_no_profiles_are_available_for_specified_project() throws IOException {
prepareCallWithEmptyResults();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesSupplierTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesSupplierTest.java
index cbb57e90116..ddba7a37d46 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesSupplierTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesSupplierTest.java
@@ -22,7 +22,7 @@ package org.sonar.scanner.repository;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.scan.branch.BranchConfiguration;
import static java.util.Collections.emptyMap;
@@ -39,7 +39,7 @@ public class ProjectRepositoriesSupplierTest {
private ProjectRepositories project;
private ProjectRepositoriesLoader loader = mock(ProjectRepositoriesLoader.class);
- private ProcessedScannerProperties props = mock(ProcessedScannerProperties.class);
+ private ScannerProperties props = mock(ScannerProperties.class);
private BranchConfiguration branchConfiguration = mock(BranchConfiguration.class);
@Before
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
index 889210c73ff..39d0a8fd63a 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
@@ -27,7 +27,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.rule.QualityProfiles;
import org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile;
@@ -46,7 +46,7 @@ public class QualityProfileProviderTest {
private QualityProfilesProvider qualityProfileProvider;
private QualityProfileLoader loader = mock(QualityProfileLoader.class);
- private ProcessedScannerProperties props = mock(ProcessedScannerProperties.class);
+ private ScannerProperties props = mock(ScannerProperties.class);
private List<QualityProfile> response;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoaderTest.java
index 52d13e495d7..eaa4d669342 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoaderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoaderTest.java
@@ -25,7 +25,7 @@ import java.io.PipedOutputStream;
import java.util.Map;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
import org.sonarqube.ws.Settings;
import org.sonarqube.ws.client.GetRequest;
@@ -41,7 +41,7 @@ import static org.mockito.Mockito.when;
public class DefaultProjectSettingsLoaderTest {
private DefaultScannerWsClient wsClient = mock(DefaultScannerWsClient.class);
- private ProcessedScannerProperties properties = mock(ProcessedScannerProperties.class);
+ private ScannerProperties properties = mock(ScannerProperties.class);
private DefaultProjectSettingsLoader underTest = new DefaultProjectSettingsLoader(wsClient, properties);
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProviderTest.java
deleted file mode 100644
index 35aa8f0a4b4..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProviderTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.scanner.bootstrap.RawScannerProperties;
-
-import static java.util.Optional.of;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ExternalProjectKeyAndOrganizationProviderTest {
-
- private ExternalProjectKeyAndOrganizationLoader loader = mock(ExternalProjectKeyAndOrganizationLoader.class);
- private RawScannerProperties rawProperties = mock(RawScannerProperties.class);
-
- private ExternalProjectKeyAndOrganizationProvider underTest = new ExternalProjectKeyAndOrganizationProvider();
-
- @Before
- public void setUp() {
- when(loader.load()).thenReturn(of(new ExternalProjectKeyAndOrganization() {
- @Override
- public Optional<String> getProjectKey() {
- return of("some_key");
- }
-
- @Override
- public Optional<String> getOrganization() {
- return of("organization_key");
- }
- }));
- }
-
- @Test
- public void does_nothing_when_key_autodetection_is_disabled() {
- when(rawProperties.property("sonar.keys_autodetection.disabled")).thenReturn("true");
-
- ExternalProjectKeyAndOrganization result = underTest.provide(rawProperties, loader);
-
- assertThat(result).isInstanceOf(EmptyExternalProjectKeyAndOrganization.class);
- }
-
- @Test
- public void by_default_attempts_to_autodetect_keys_if_external_key_loader_detected() {
- when(rawProperties.property("sonar.keys_autodetection.disabled")).thenReturn(null);
-
- ExternalProjectKeyAndOrganization result = underTest.provide(rawProperties, loader);
-
- assertThat(result).isNotInstanceOf(EmptyExternalProjectKeyAndOrganization.class);
- assertThat(result.getProjectKey()).isEqualTo(of("some_key"));
- assertThat(result.getOrganization()).isEqualTo(of("organization_key"));
- }
-
- @Test
- public void by_default_does_nothing_when_no_external_key_loader_detected() {
- when(rawProperties.property("sonar.keys_autodetection.disabled")).thenReturn(null);
-
- ExternalProjectKeyAndOrganization result = underTest.provide(rawProperties, null);
-
- assertThat(result).isInstanceOf(EmptyExternalProjectKeyAndOrganization.class);
- }
-
- @Test
- public void attempts_to_autodetect_keys_if_autodection_is_explicitly_enabled() {
- when(rawProperties.property("sonar.keys_autodetection.disabled")).thenReturn("false");
-
- ExternalProjectKeyAndOrganization result = underTest.provide(rawProperties, loader);
-
- assertThat(result).isNotInstanceOf(EmptyExternalProjectKeyAndOrganization.class);
- assertThat(result.getProjectKey()).isEqualTo(of("some_key"));
- assertThat(result.getOrganization()).isEqualTo(of("organization_key"));
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
index c3a38b15451..00c9cbbb134 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
@@ -37,8 +37,7 @@ import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.notifications.AnalysisWarnings;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
-import org.sonar.scanner.bootstrap.RawScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
@@ -391,8 +390,7 @@ public class ProjectReactorBuilderTest {
@Test
public void shouldInitRootWorkDir() {
- ProjectReactorBuilder builder = new ProjectReactorBuilder(new ProcessedScannerProperties(
- new RawScannerProperties(emptyMap()), new EmptyExternalProjectKeyAndOrganization()),
+ ProjectReactorBuilder builder = new ProjectReactorBuilder(new ScannerProperties(emptyMap()),
mock(AnalysisWarnings.class));
File baseDir = new File("target/tmp/baseDir");
@@ -404,9 +402,7 @@ public class ProjectReactorBuilderTest {
@Test
public void shouldInitWorkDirWithCustomRelativeFolder() {
Map<String, String> props = singletonMap("sonar.working.directory", ".foo");
- ProjectReactorBuilder builder = new ProjectReactorBuilder(new ProcessedScannerProperties(
- new RawScannerProperties(props),
- new EmptyExternalProjectKeyAndOrganization()),
+ ProjectReactorBuilder builder = new ProjectReactorBuilder(new ScannerProperties(props),
mock(AnalysisWarnings.class));
File baseDir = new File("target/tmp/baseDir");
@@ -418,8 +414,7 @@ public class ProjectReactorBuilderTest {
@Test
public void shouldInitRootWorkDirWithCustomAbsoluteFolder() {
Map<String, String> props = singletonMap("sonar.working.directory", new File("src").getAbsolutePath());
- ProjectReactorBuilder builder = new ProjectReactorBuilder(new ProcessedScannerProperties(
- new RawScannerProperties(props), new EmptyExternalProjectKeyAndOrganization()),
+ ProjectReactorBuilder builder = new ProjectReactorBuilder(new ScannerProperties(props),
mock(AnalysisWarnings.class));
File baseDir = new File("target/tmp/baseDir");
@@ -475,9 +470,7 @@ public class ProjectReactorBuilderTest {
private ProjectDefinition loadProjectDefinition(String projectFolder) {
Map<String, String> props = loadProps(projectFolder);
- ProcessedScannerProperties bootstrapProps = new ProcessedScannerProperties(
- new RawScannerProperties(props),
- new EmptyExternalProjectKeyAndOrganization());
+ ScannerProperties bootstrapProps = new ScannerProperties(props);
ProjectReactor projectReactor = new ProjectReactorBuilder(bootstrapProps, mock(AnalysisWarnings.class)).execute();
return projectReactor.getRoot();
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
index 3e43e986ae9..af662b664b2 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
@@ -27,18 +27,18 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.MessageException;
-import org.sonar.api.batch.fs.internal.DefaultInputProject;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ScanPropertiesTest {
- private MapSettings settings = new MapSettings();
- private DefaultInputProject project = mock(DefaultInputProject.class);
- private ScanProperties underTest = new ScanProperties(settings.asConfig(), project);
+ private final MapSettings settings = new MapSettings();
+ private final DefaultInputProject project = mock(DefaultInputProject.class);
+ private final ScanProperties underTest = new ScanProperties(settings.asConfig(), project);
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@@ -55,7 +55,6 @@ public class ScanPropertiesTest {
@Test
public void defaults_if_no_setting_defined() {
assertThat(underTest.branch()).isEmpty();
- assertThat(underTest.organizationKey()).isEmpty();
assertThat(underTest.preloadFileMetadata()).isFalse();
assertThat(underTest.shouldKeepReport()).isFalse();
assertThat(underTest.metadataFilePath()).isEqualTo(project.getWorkDir().resolve("report-task.txt"));
@@ -63,12 +62,6 @@ public class ScanPropertiesTest {
}
@Test
- public void should_define_organization_key() {
- settings.setProperty("sonar.organization", "org");
- assertThat(underTest.organizationKey()).isEqualTo(Optional.of("org"));
- }
-
- @Test
public void should_define_branch_name() {
settings.setProperty("sonar.branch.name", "name");
assertThat(underTest.branch()).isEqualTo(Optional.of("name"));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesProviderTest.java
index 4a9f1ae2d3e..3a0f8fc477e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesProviderTest.java
@@ -21,7 +21,7 @@ package org.sonar.scanner.scan.branch;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -31,13 +31,13 @@ public class ProjectBranchesProviderTest {
private ProjectBranchesProvider provider = new ProjectBranchesProvider();
private ProjectBranchesLoader mockLoader;
private ProjectBranches mockBranches;
- private ProcessedScannerProperties scannerProperties;
+ private ScannerProperties scannerProperties;
@Before
public void setUp() {
mockLoader = mock(ProjectBranchesLoader.class);
mockBranches = mock(ProjectBranches.class);
- scannerProperties = mock(ProcessedScannerProperties.class);
+ scannerProperties = mock(ScannerProperties.class);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProviderTest.java
index 35a85869a3a..510d24bd2f7 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProviderTest.java
@@ -21,7 +21,7 @@ package org.sonar.scanner.scan.branch;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.scanner.bootstrap.ProcessedScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,13 +32,13 @@ public class ProjectPullRequestsProviderTest {
private ProjectPullRequestsProvider provider = new ProjectPullRequestsProvider();
private ProjectPullRequestsLoader mockLoader;
private ProjectPullRequests pullRequests;
- private ProcessedScannerProperties scannerProperties;
+ private ScannerProperties scannerProperties;
@Before
public void setUp() {
mockLoader = mock(ProjectPullRequestsLoader.class);
pullRequests = new ProjectPullRequests(emptyList());
- scannerProperties = mock(ProcessedScannerProperties.class);
+ scannerProperties = mock(ScannerProperties.class);
}
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmRevisionImplTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmRevisionImplTest.java
index 16a02abfe65..37fbc99cd1a 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmRevisionImplTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmRevisionImplTest.java
@@ -24,7 +24,7 @@ import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import org.junit.Test;
-import org.sonar.scanner.bootstrap.RawScannerProperties;
+import org.sonar.scanner.bootstrap.ScannerProperties;
import org.sonar.scanner.ci.CiConfiguration;
import org.sonar.scanner.fs.InputModuleHierarchy;
@@ -65,7 +65,7 @@ public class ScmRevisionImplTest {
when(scmConfiguration.provider().revisionId(any())).thenThrow(new UnsupportedOperationException("BOOM"));
InputModuleHierarchy moduleHierarchy = mock(InputModuleHierarchy.class, RETURNS_DEEP_STUBS);
- ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new RawScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
+ ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new ScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
assertThat(underTest.get()).isEmpty();
}
@@ -79,7 +79,7 @@ public class ScmRevisionImplTest {
when(scmConfiguration.provider().revisionId(any())).thenReturn(scmValue);
InputModuleHierarchy moduleHierarchy = mock(InputModuleHierarchy.class, RETURNS_DEEP_STUBS);
- ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new RawScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
+ ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new ScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
return underTest.get();
}
}