]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10345 Remove old webhook UI in the settings
authorGuillaume Jambet <guillaume.jambet@sonarsource.com>
Fri, 16 Feb 2018 15:56:38 +0000 (16:56 +0100)
committerGuillaume Jambet <guillaume.jambet@gmail.com>
Thu, 1 Mar 2018 14:21:05 +0000 (15:21 +0100)
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistAnalysisPropertiesStep.java
server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-core/src/main/java/org/sonar/core/config/WebhookProperties.java [deleted file]
sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java

index 3ab7291a64c709b07385c4b475d293e3ef406cae..bf87bddc6538db7d6684a7f2189536c71377921c 100644 (file)
@@ -120,7 +120,7 @@ public class ComputeEngineContainerImplTest {
         + 26 // level 1
         + 53 // content of DaoModule
         + 3 // content of EsSearchModule
-        + 59 // content of CorePropertyDefinitions
+        + 57 // content of CorePropertyDefinitions
         + 1 // StopFlagContainer
     );
     assertThat(
index 5db426bc69f34793eb74c933d165ce89bfc50531..eeb23ef31adb51d289f197f7ab2bb287c72afd1c 100644 (file)
@@ -93,8 +93,6 @@ public class DaoModule extends Module {
     CeTaskInputDao.class,
     ComponentDao.class,
     ComponentKeyUpdaterDao.class,
-    ProjectLinkDao.class,
-    LiveMeasureDao.class,
     CustomMeasureDao.class,
     DefaultQProfileDao.class,
     DuplicationDao.class,
@@ -116,6 +114,7 @@ public class DaoModule extends Module {
     PermissionTemplateCharacteristicDao.class,
     PermissionTemplateDao.class,
     PluginDao.class,
+    ProjectLinkDao.class,
     ProjectQgateAssociationDao.class,
     PropertiesDao.class,
     PurgeDao.class,
index a9e2569702700e79dedd9c44fd84b33ee59d7bde..3ca4d4a33e751ae2fc5199ca26a8d870b0db80aa 100644 (file)
@@ -29,13 +29,14 @@ import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetada
 import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.server.computation.task.step.ComputationStep;
 
+import static org.sonar.core.config.CorePropertyDefinitions.SONAR_ANALYSIS;
+
 /**
  * Persist analysis properties
  * Only properties starting with "sonar.analysis" or "sonar.pullrequest" will be persisted in database
  */
 public class PersistAnalysisPropertiesStep implements ComputationStep {
 
-  private static final String SONAR_ANALYSIS = "sonar.analysis.";
   private static final String SONAR_PULL_REQUEST = "sonar.pullrequest.";
 
   private final DbClient dbClient;
index c957607c4954cdfd494e5a7277f8bd354b466ad6..96c24d254fb9db4d54159b4f9633219eba6b95b8 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.server.qualitygate.EvaluatedCondition;
 import org.sonar.server.qualitygate.EvaluatedQualityGate;
 
 import static java.lang.String.format;
-import static org.sonar.core.config.WebhookProperties.ANALYSIS_PROPERTY_PREFIX;
+import static org.sonar.core.config.CorePropertyDefinitions.SONAR_ANALYSIS;
 
 @ComputeEngineSide
 public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
@@ -91,7 +91,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
       .beginObject();
     properties.entrySet()
       .stream()
-      .filter(prop -> prop.getKey().startsWith(ANALYSIS_PROPERTY_PREFIX))
+      .filter(prop -> prop.getKey().startsWith(SONAR_ANALYSIS))
       .forEach(prop -> writer.prop(prop.getKey(), prop.getValue()));
     writer.endObject();
   }
index 01acaad196a0573f6d513f9489faf99f0591630c..286d0ece9bec979a10c29c613463e0c4645f6994 100644 (file)
@@ -38,6 +38,7 @@ public class CorePropertyDefinitions {
   public static final String LEAK_PERIOD_MODE_VERSION = "version";
   public static final String LEAK_PERIOD_MODE_DAYS = "days";
   public static final String LEAK_PERIOD_MODE_PREVIOUS_VERSION = "previous_version";
+  public static final String SONAR_ANALYSIS = "sonar.analysis.";
 
   private static final String DEFAULT_LEAK_PERIOD = LEAK_PERIOD_MODE_PREVIOUS_VERSION;
 
@@ -60,7 +61,6 @@ public class CorePropertyDefinitions {
     defs.addAll(DebtProperties.all());
     defs.addAll(PurgeProperties.all());
     defs.addAll(EmailSettings.definitions());
-    defs.addAll(WebhookProperties.all());
     defs.addAll(ScannerProperties.all());
 
     defs.addAll(asList(
diff --git a/sonar-core/src/main/java/org/sonar/core/config/WebhookProperties.java b/sonar-core/src/main/java/org/sonar/core/config/WebhookProperties.java
deleted file mode 100644 (file)
index 91c654f..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.core.config;
-
-import java.util.List;
-import org.sonar.api.PropertyType;
-import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.config.PropertyFieldDefinition;
-import org.sonar.api.resources.Qualifiers;
-
-import static java.util.Arrays.asList;
-
-public class WebhookProperties {
-
-  public static final String GLOBAL_KEY = "sonar.webhooks.global";
-  public static final String PROJECT_KEY = "sonar.webhooks.project";
-  public static final String NAME_FIELD = "name";
-  public static final String URL_FIELD = "url";
-
-  /**
-   * Maximum allowed number of webhooks per type (globally or per project).
-   * That is required to not become a DoS attacker, for instance
-   * if thousands of webhooks are configured.
-   * Important - note that this number is written in full in {@link #DESCRIPTION}.
-   */
-  public static final long MAX_WEBHOOKS_PER_TYPE = 10;
-
-  /**
-   * Prefix of the properties to be automatically exported from scanner to payload
-   */
-  public static final String ANALYSIS_PROPERTY_PREFIX = "sonar.analysis.";
-
-  private static final String CATEGORY = "webhooks";
-  private static final String DESCRIPTION = "Webhooks are used to notify external services when a project analysis is done. " +
-    "An HTTP POST request including a JSON payload is sent to each of the first ten provided URLs. <br/>" +
-    "Learn more in the <a href=\"https://redirect.sonarsource.com/doc/webhooks.html\">Webhooks documentation</a>.";
-  private static final String URL_DESCRIPTION = "Server endpoint that will receive the webhook payload, for example 'http://my_server/foo'. " +
-    "If HTTP Basic authentication is used, HTTPS is recommended to avoid man in the middle attacks. " +
-    "Example: 'https://myLogin:myPassword@my_server/foo'";
-
-  private WebhookProperties() {
-    // only static stuff
-  }
-
-  static List<PropertyDefinition> all() {
-    return asList(
-      PropertyDefinition.builder(GLOBAL_KEY)
-        .category(CATEGORY)
-        .name("Webhooks")
-        .description(DESCRIPTION)
-        .fields(
-          PropertyFieldDefinition.build(NAME_FIELD)
-            .name("Name")
-            .type(PropertyType.STRING)
-            .build(),
-          PropertyFieldDefinition.build(URL_FIELD)
-            .name("URL")
-            .type(PropertyType.STRING)
-            .description(URL_DESCRIPTION)
-            .build())
-        .build(),
-
-      PropertyDefinition.builder(PROJECT_KEY)
-        .category(CATEGORY)
-        .name("Project Webhooks")
-        .description(DESCRIPTION)
-        .onlyOnQualifiers(Qualifiers.PROJECT)
-        .fields(
-          PropertyFieldDefinition.build(NAME_FIELD)
-            .name("Name")
-            .type(PropertyType.STRING)
-            .build(),
-          PropertyFieldDefinition.build(URL_FIELD)
-            .name("URL")
-            .type(PropertyType.STRING)
-            .description(URL_DESCRIPTION)
-            .build())
-        .build());
-  }
-
-}
index b3054a31a22143ac21403b3c84aa3a93ed43c5c4..a3cfb1e2bc5a19bb724d41a352dccff03ec6fbbc 100644 (file)
@@ -30,7 +30,7 @@ public class CorePropertyDefinitionsTest {
   @Test
   public void all() {
     List<PropertyDefinition> defs = CorePropertyDefinitions.all();
-    assertThat(defs).hasSize(59);
+    assertThat(defs).hasSize(57);
   }
 
   @Test
index 55b5eb9cadc45f74dd84c165643d8922e6c0470d..48384ca95cf7d9c9fc061d4519ed2e7821a247ce 100644 (file)
@@ -24,13 +24,12 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.annotation.Nonnull;
+import org.sonar.core.config.CorePropertyDefinitions;
 import org.sonar.scanner.config.DefaultConfiguration;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.repository.ContextPropertiesCache;
 
-import static org.sonar.core.config.WebhookProperties.ANALYSIS_PROPERTY_PREFIX;
-
 public class ContextPropertiesPublisher implements ReportPublisherStep {
 
   private final ContextPropertiesCache cache;
@@ -51,7 +50,7 @@ public class ContextPropertiesPublisher implements ReportPublisherStep {
     // properties that are automatically included to report so that
     // they can be included to webhook payloads
     Stream<ScannerReport.ContextProperty> fromSettings = config.getProperties().entrySet().stream()
-      .filter(e -> e.getKey().startsWith(ANALYSIS_PROPERTY_PREFIX))
+      .filter(e -> e.getKey().startsWith(CorePropertyDefinitions.SONAR_ANALYSIS))
       .map(transformer);
 
     writer.writeContextProperties(Stream.concat(fromCache, fromSettings).collect(Collectors.toList()));