]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13312 drop 'sonar.organization' scanner parameter
authorJacek <jacek.poreda@sonarsource.com>
Fri, 18 Dec 2020 09:27:51 +0000 (10:27 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 22 Dec 2020 20:09:38 +0000 (20:09 +0000)
- drop unused bitbucket pipelines references

45 files changed:
sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalTempFolderProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ProcessedScannerProperties.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfilesProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/EmptyExternalProjectKeyAndOrganization.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganization.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationLoader.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProvider.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranchesProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmRevisionImpl.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ProcessedScannerPropertiesTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPropertiesTest.java [new file with mode: 0644]
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerWsClientProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesSupplierTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultProjectSettingsLoaderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ExternalProjectKeyAndOrganizationProviderTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmRevisionImplTest.java

index 3432080c90689e8e0b9fda49452df577e94f1285..a2bd839cc25cbedf978201c95b4efb3db36f3a4a 100644 (file)
@@ -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.")
index 9140420216adfa1387616841a4fd4ccdc5bad8bd..d1d297c6a27b74cbeeb245e9688bff92285a0dac 100644 (file)
@@ -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
index 9eb931293770d90eda6e29b7f3151df3671750ed..c4468eb90e46bff8c55a865a3f9b502aa1d9cb9a 100644 (file)
@@ -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");
index c72f7ef089bea03fe2f7c5d827f22c8af9bcb9a0..efc9db8abe7abf56d654caf09d28682db06651bd 100644 (file)
@@ -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<>();
index 9dfd4d3367d9e85d3dd9ff2edc76212fb756388a..42aa1bb706445583eb44c7dc12387432583ed824 100644 (file)
@@ -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);
index 913fa7866b8011b49c3cd38051d4167212642b2f..7456a5877492c468edcb525e7b989779688ba628 100644 (file)
@@ -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 (file)
index a8ca80a..0000000
+++ /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/RawScannerProperties.java
deleted file mode 100644 (file)
index 8d468a0..0000000
+++ /dev/null
@@ -1,66 +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.api.CoreProperties;
-import org.sonar.api.config.internal.Encryption;
-
-/**
- * Properties that are coming from scanner.
- */
-@Immutable
-public class RawScannerProperties {
-
-  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));
-    Map<String, String> decryptedProps = new HashMap<>(properties.size());
-    for (Map.Entry<String, String> entry : properties.entrySet()) {
-      String value = entry.getValue();
-      if (value != null && encryption.isEncrypted(value)) {
-        try {
-          value = encryption.decrypt(value);
-        } catch (Exception e) {
-          throw new IllegalStateException("Fail to decrypt the property " + entry.getKey() + ". Please check your secret key.", e);
-        }
-      }
-      decryptedProps.put(entry.getKey(), value);
-    }
-    this.properties = Collections.unmodifiableMap(new HashMap<>(decryptedProps));
-  }
-
-  public Encryption getEncryption() {
-    return encryption;
-  }
-
-  public Map<String, String> properties() {
-    return properties;
-  }
-
-  public String property(String key) {
-    return properties.get(key);
-  }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerProperties.java
new file mode 100644 (file)
index 0000000..1316642
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.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 ScannerProperties {
+
+  private final Map<String, String> properties;
+  private final Encryption encryption;
+
+  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();
+      if (value != null && encryption.isEncrypted(value)) {
+        try {
+          value = encryption.decrypt(value);
+        } catch (Exception e) {
+          throw new IllegalStateException("Fail to decrypt the property " + entry.getKey() + ". Please check your secret key.", e);
+        }
+      }
+      decryptedProps.put(entry.getKey(), value);
+    }
+    this.properties = Collections.unmodifiableMap(new HashMap<>(decryptedProps));
+  }
+
+  public Encryption getEncryption() {
+    return encryption;
+  }
+
+  public Map<String, String> properties() {
+    return properties;
+  }
+
+  public String property(String key) {
+    return properties.get(key);
+  }
+
+  public String getProjectKey() {
+    return properties.get(PROJECT_KEY_PROPERTY);
+  }
+}
index 6c3bfd7718ba8d6a0ba834847d3ca890d220c43b..ea5cf27ee388721186dcb40cd46a0efeb08a512d 100644 (file)
@@ -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");
index f1513799d457375070261f5fdb32c1325b71f607..70e53add993f031a010bd59a67b4d3a8ec6edc09 100644 (file)
@@ -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;
index 323f76096bec484143f81a66c6a120d75b75da42..4e20af54b310a57bedfffaee2a68588729bf1842 100644 (file)
@@ -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());
index 6958bbbcc649dfd9b5a92a7d5e73c4de109dc9d2..4080fe9cba28f99690d909f4d1b67fb979f9ff1d 100644 (file)
@@ -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()) {
index 95edbdfc06dc391d86d05ffbdd04c89fef2cc21a..be762b019152f85d680bce98c7f7da48e70e48a6 100644 (file)
@@ -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;
index 51b520d33b3cc6149d192a8adea7bf95ccd865fa..da570ee99685ffb02555f581165738a6d0313e25 100644 (file)
@@ -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()));
index cd54bd3daf445fb7d755388f8f958e6adcddce23..91aa811db495144345e180bb706bb8acdfb70a52 100644 (file)
 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 (file)
index ebdcf31..0000000
+++ /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 (file)
index e0f45e1..0000000
+++ /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 (file)
index ac8ac89..0000000
+++ /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 (file)
index 243067b..0000000
+++ /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;
-  }
-}
index e4134169b4117ec403a64192162f6d7285d9c034..74c098e8b00017f61050659f479db8e973452a59 100644 (file)
@@ -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;
   }
index 30aac02d9f157900459c72184aaa4c4c1f28e743..cff29808988f27b12a740fa569a02abcd5d165e6 100644 (file)
@@ -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.");
index 133f014e263f4c1f5c78563a797987e5c7a02c44..0c60018201677d1b7c96184f620837cbff17584e 100644 (file)
@@ -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);
   }
index 0e4cc2662589d92fcb3b9b771211b1e70098c633..e7cc510c5e8285bf2fb5be3265507c91e5791d03 100644 (file)
@@ -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;
     }
index 35012cc3ec298391f427ff689df7ec2c1555a9a4..f0d6582174f87a32e0ec8789d59710cf92cb9fd6 100644 (file)
@@ -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;
     }
index f4c1fad464dbb33f4b50c427c4069fbe59224151..c9fd38d251781390a9d41edec0fbfd50614936cf 100644 (file)
@@ -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;
index 3578d8c4a6556ffd965e5afa2216f83b401d6122..e51054f190eada01ce7d4b5564457fc443102fe9 100644 (file)
@@ -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() {
index 2b57667e5014ca0aa0a32cf8e4098a5bae4cc632..360c9138d50273ad7ae19bf6db616ca7d4153a22 100644 (file)
@@ -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
index 3db5b63b4505f3d0fe6a3fc8b3b4af6dab9a9755..652fedb8733cbdc249c727cc5baefad4e801b62f 100644 (file)
@@ -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();
index dd6d43348bde410f97a20e7e4fff7ff0ab0fb24b..8bf01c1310b8c1fd80b7185a6278c17f9cab5f0d 100644 (file)
@@ -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 (file)
index c13d109..0000000
+++ /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 (file)
index 0000000..ce96f9d
--- /dev/null
@@ -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");
+  }
+
+}
index 3aa081c7abd4308a3e0b8511abcee1cf0e617aff..cff5e3269811fd5467359f0e7154c9a843fe550d 100644 (file)
@@ -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);
   }
 }
index 01a995dda20dfd120f73ae8e93df084757c369fd..4f91b85e2915eab128ed2b4cb1f41985c25cc892 100644 (file)
@@ -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);
index 211e1a062d35513e67cdfa6a22cf461573412bf1..460c3b507d55376b483a22f393c5285a86f1deaf 100644 (file)
@@ -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);
index ae721b16148dc5f4063e7c26eac23ef828028d46..5d1a4381a1b6f6dc9138ba72ebf38f0fa4703c9e 100644 (file)
@@ -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 {
@@ -61,14 +59,6 @@ public class DefaultQualityProfileLoaderTest {
     verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo%232");
   }
 
-  @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'\"}]}");
@@ -81,19 +71,6 @@ public class DefaultQualityProfileLoaderTest {
     verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true");
   }
 
-  @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();
index cbb57e901169a67c1519a59ad15f483e38a55183..ddba7a37d46489300a88a487b2bab6238ce96a00 100644 (file)
@@ -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
index 889210c73ff3067182f9678f2284fed7e40dc1c0..39d0a8fd63a552ad3bae9a22e38ad8ce830128e5 100644 (file)
@@ -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;
 
index 52d13e495d7aa6a810897b142f1f2ec3bc436faa..eaa4d669342848d628382f492a423203a35bc14e 100644 (file)
@@ -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 (file)
index 35aa8f0..0000000
+++ /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"));
-  }
-}
index c3a38b15451015a9529a1750373b37d593789c8d..00c9cbbb134e045029a04c2d2e44dfbb81e167c7 100644 (file)
@@ -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();
   }
index 3e43e986ae9cc65067dc2b78759d40e5ca5531c9..af662b664b2d11881b66483095492be91b320891 100644 (file)
@@ -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,19 +55,12 @@ 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"));
     underTest.validate();
   }
 
-  @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");
index 4a9f1ae2d3e17715d6a8db3a8934575391e8966e..3a0f8fc477e09e723980e863cf084dd6598f58d9 100644 (file)
@@ -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);
 
   }
 
index 35a85869a3a7f7a983d0afad45413cb5bed8772e..510d24bd2f71a7524a2448aeb2fe361a65d9c854 100644 (file)
@@ -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
index 16a02abfe659a1e2e1398820689ca5e556efed0c..37fbc99cd1a058071d70384b1ae66506c74cedc2 100644 (file)
@@ -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();
   }
 }