From: Michal Duda Date: Wed, 1 Jul 2020 09:43:29 +0000 (+0200) Subject: SONAR-13341 improved error message X-Git-Tag: 7.9.4~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ac1960bb8c50ab2039f0932d9233c86e9691bf5a;p=sonarqube.git SONAR-13341 improved error message --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookSupport.java b/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookSupport.java index daa74e2b9c7..3a6f842f715 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookSupport.java +++ b/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookSupport.java @@ -60,7 +60,7 @@ public class WebhookSupport { InetAddress address = InetAddress.getByName(okUrl.host()); if (configuration.getBoolean(SONAR_VALIDATE_WEBHOOKS.getKey()).orElse(true) && (address.isLoopbackAddress() || address.isAnyLocalAddress())) { - throw new IllegalArgumentException("Invalid URL"); + throw new IllegalArgumentException("Invalid URL: loopback and wildcard addresses are not allowed for webhooks."); } } catch (UnknownHostException e) { // if a host can not be resolved the deliveries will fail - no need to block it from being set diff --git a/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookSupportTest.java b/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookSupportTest.java index cca13f0a68c..49ff03b4be7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookSupportTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookSupportTest.java @@ -78,7 +78,7 @@ public class WebhookSupportTest { public void checkUrlPatternFailsForLoopbackAddress(String url) { assertThatThrownBy(() -> underTest.checkUrlPattern(url, "msg")) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Invalid URL"); + .hasMessage("Invalid URL: loopback and wildcard addresses are not allowed for webhooks."); } @Test