Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/groovy/com/rundeck/plugin/HttpNotificationPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import com.google.gson.Gson
import com.rundeck.plugin.oauth.OAuthClient
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.EncoderRegistry
import groovyx.net.http.Method
import org.apache.log4j.Logger
import java.nio.charset.Charset;

/**
* Created by rundeck on 12/27/17.
Expand Down Expand Up @@ -207,7 +209,8 @@ class HttpNotificationPlugin implements NotificationPlugin, Describable {
}

@Override
boolean postNotification(String trigger, Map executionData, Map config) {
boolean postNotification(String trigger, Map executionData, Map config)
{
String remoteUrl = config.containsKey(HTTP_URL) ? config.get(HTTP_URL).toString() : null
String method = config.containsKey(HTTP_METHOD) ? config.get(HTTP_METHOD).toString() : null
String contentTypeStr = config.containsKey(HTTP_CONTENT_TYPE) ? config.get(HTTP_CONTENT_TYPE).toString() : null
Expand All @@ -228,6 +231,9 @@ class HttpNotificationPlugin implements NotificationPlugin, Describable {
def requestBody = parseBody(bodyStr)

def http = new HTTPBuilder()

http.encoderRegistry = new EncoderRegistry( charset: 'utf-8' )

if(ignoreSSL){
http.ignoreSSLIssues()
}
Expand Down Expand Up @@ -311,7 +317,8 @@ class HttpNotificationPlugin implements NotificationPlugin, Describable {
return result
}

Map<String,String> parseHeaders(String headers){
Map<String,String> parseHeaders(String headers)
{
Map<String,String> requestHeaders = new HashMap<>();

//checking json
Expand Down
10 changes: 6 additions & 4 deletions src/test/groovy/HttpNotificationPluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class HttpNotificationPluginSpec extends Specification{

def notificator = new HttpNotificationPlugin()

String remoteUrl="http://google.com"
String methodStr = "GET"
String contentType ="text/html"
String remoteUrl="https://outlook.office.com/webhook/79d86a26-f956-4e3a-bc3a-9dc11cc6903f@b1fd7989-50d8-455b-9070-a00d818974ec/IncomingWebhook/8cf770284a124a92a52a39c8f7895eb3/1b958be6-edb8-44db-b423-f8fcafb1a1fe"
String methodStr = "POST"
String contentType ="application/json"
String bodyStr1 = "{\"text\":\"1111111111111wrong 한글은.\"}";
String bodyStr = new String(bodyStr1.getBytes("UTF-8"),"UTF-8");
def executionData = [:]
def config = [remoteUrl:remoteUrl,method:methodStr,contentType:contentType]
def config = [remoteUrl:remoteUrl,method:methodStr,contentType:contentType,body:bodyStr]
String trigger ="success"

when:
Expand Down