summaryrefslogtreecommitdiffstats
path: root/app/webhook_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-03-12 12:40:11 +0100
committerJoram Wilander <jwawilander@gmail.com>2018-03-12 07:40:11 -0400
commitcb1b8fc3337f2e7611b342d077573312a62d5619 (patch)
tree445806a0e52a30d170ed82d6673dc50d031e6153 /app/webhook_test.go
parent46fea093c8d77da3f3a6e5417632ba686eef8092 (diff)
downloadchat-cb1b8fc3337f2e7611b342d077573312a62d5619.tar.gz
chat-cb1b8fc3337f2e7611b342d077573312a62d5619.tar.bz2
chat-cb1b8fc3337f2e7611b342d077573312a62d5619.zip
[MM-9725] Slack compatibility code in webhooks captures incorrect text (#8428)
Diffstat (limited to 'app/webhook_test.go')
-rw-r--r--app/webhook_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/app/webhook_test.go b/app/webhook_test.go
index 850e74efc..4d2bc58fa 100644
--- a/app/webhook_test.go
+++ b/app/webhook_test.go
@@ -317,6 +317,64 @@ func TestCreateWebhookPost(t *testing.T) {
if err == nil {
t.Fatal("should have failed - bad post type")
}
+
+ expectedText := "`<>|<>|`"
+ post, err = th.App.CreateWebhookPost(hook.UserId, th.BasicChannel, expectedText, "user", "http://iconurl", model.StringInterface{
+ "attachments": []*model.SlackAttachment{
+ {
+ Text: "text",
+ },
+ },
+ "webhook_display_name": hook.DisplayName,
+ }, model.POST_SLACK_ATTACHMENT, "")
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+ assert.Equal(t, expectedText, post.Message)
+
+ expectedText = "< | \n|\n>"
+ post, err = th.App.CreateWebhookPost(hook.UserId, th.BasicChannel, expectedText, "user", "http://iconurl", model.StringInterface{
+ "attachments": []*model.SlackAttachment{
+ {
+ Text: "text",
+ },
+ },
+ "webhook_display_name": hook.DisplayName,
+ }, model.POST_SLACK_ATTACHMENT, "")
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+ assert.Equal(t, expectedText, post.Message)
+
+ expectedText = `commit bc95839e4a430ace453e8b209a3723c000c1729a
+Author: foo <foo@example.org>
+Date: Thu Mar 1 19:46:54 2018 +0300
+
+ commit message 2
+
+ test | 1 +
+ 1 file changed, 1 insertion(+)
+
+commit 5df78b7139b543997838071cd912e375d8bd69b2
+Author: foo <foo@example.org>
+Date: Thu Mar 1 19:46:48 2018 +0300
+
+ commit message 1
+
+ test | 3 +++
+ 1 file changed, 3 insertions(+)`
+ post, err = th.App.CreateWebhookPost(hook.UserId, th.BasicChannel, expectedText, "user", "http://iconurl", model.StringInterface{
+ "attachments": []*model.SlackAttachment{
+ {
+ Text: "text",
+ },
+ },
+ "webhook_display_name": hook.DisplayName,
+ }, model.POST_SLACK_ATTACHMENT, "")
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+ assert.Equal(t, expectedText, post.Message)
}
func TestSplitWebhookPost(t *testing.T) {