This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new c1a6790514 [Alert] [HTTP Plugin] Lose HTTP port (#14341)
c1a6790514 is described below
commit c1a67905149a1d791ec23dca477bc59c08c4f607
Author: 旺阳 <[email protected]>
AuthorDate: Wed Jun 14 17:38:58 2023 +0800
[Alert] [HTTP Plugin] Lose HTTP port (#14341)
---
.../apache/dolphinscheduler/plugin/alert/http/HttpSender.java | 6 +++++-
.../dolphinscheduler/plugin/alert/http/HttpSenderTest.java | 10 +++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
index ab4189bd13..4c0dda1af4 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
@@ -120,7 +120,7 @@ public final class HttpSender {
// GET request add param in url
setMsgInUrl(msg);
URL unencodeUrl = new URL(url);
- URI uri = new URI(unencodeUrl.getProtocol(),
unencodeUrl.getHost(), unencodeUrl.getPath(),
+ URI uri = new URI(unencodeUrl.getProtocol(),
unencodeUrl.getAuthority(), unencodeUrl.getPath(),
unencodeUrl.getQuery(), null);
httpRequest = new HttpGet(uri);
@@ -175,4 +175,8 @@ public final class HttpSender {
log.error("send http alert msg exception : {}", e.getMessage());
}
}
+
+ public String getRequestUrl() {
+ return httpRequest.getURI().toString();
+ }
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java
index 73473876f6..9f4e017b86 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java
@@ -35,15 +35,19 @@ public class HttpSenderTest {
@Test
public void sendTest() throws IOException {
Map<String, String> paramsMap = new HashMap<>();
- paramsMap.put(HttpAlertConstants.NAME_URL,
"http://www.dolphinscheduler-not-exists-web.com");
- paramsMap.put(HttpAlertConstants.NAME_REQUEST_TYPE, "POST");
+ String url = "https://www.dolphinscheduler-not-exists-web.com:12345";
+ String contentField = "content";
+ paramsMap.put(HttpAlertConstants.NAME_URL, url);
+ paramsMap.put(HttpAlertConstants.NAME_REQUEST_TYPE, "GET");
paramsMap.put(HttpAlertConstants.NAME_HEADER_PARAMS,
"{\"Content-Type\":\"application/json\"}");
paramsMap.put(HttpAlertConstants.NAME_BODY_PARAMS,
"{\"number\":\"123456\"}");
- paramsMap.put(HttpAlertConstants.NAME_CONTENT_FIELD, "content");
+ paramsMap.put(HttpAlertConstants.NAME_CONTENT_FIELD, contentField);
HttpSender httpSender = spy(new HttpSender(paramsMap));
doReturn("success").when(httpSender).getResponseString(any());
AlertResult alertResult = httpSender.send("Fault tolerance warning");
Assertions.assertEquals("true", alertResult.getStatus());
+ Assertions.assertTrue(httpSender.getRequestUrl().contains(url));
+
Assertions.assertTrue(httpSender.getRequestUrl().contains(contentField));
}
}