From ac1960bb8c50ab2039f0932d9233c86e9691bf5a Mon Sep 17 00:00:00 2001 From: Michal Duda Date: Wed, 1 Jul 2020 11:43:29 +0200 Subject: [PATCH] SONAR-13341 improved error message --- .../main/java/org/sonar/server/webhook/ws/WebhookSupport.java | 2 +- .../java/org/sonar/server/webhook/ws/WebhookSupportTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 -- 2.39.5