diff options
author | Thomas Balthazar <tbalthazar@users.noreply.github.com> | 2016-05-17 14:56:38 +0200 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-05-17 08:56:38 -0400 |
commit | 5580c28e54015b78893c33cc3bf41da75712c4cb (patch) | |
tree | bb8c8ac07de4046b6131b45e26bce819f6ab88af /api | |
parent | 45527a9c1d370a2de9584d9dbe8e44ce2c7a587e (diff) | |
download | chat-5580c28e54015b78893c33cc3bf41da75712c4cb.tar.gz chat-5580c28e54015b78893c33cc3bf41da75712c4cb.tar.bz2 chat-5580c28e54015b78893c33cc3bf41da75712c4cb.zip |
PLT-2188 Integrations: Support raw new lines in the text payload (#2993)
* Integrations: Support raw new lines in the text payload
* Improve support for raw new lines in text payload
The regexp used to escape control characters now also searches for
additional fields:
text|fallback|pretext|author_name|title|value
Diffstat (limited to 'api')
-rw-r--r-- | api/webhook_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/api/webhook_test.go b/api/webhook_test.go index 5198056cc..1b13bb5d4 100644 --- a/api/webhook_test.go +++ b/api/webhook_test.go @@ -511,6 +511,7 @@ func TestRegenOutgoingHookToken(t *testing.T) { t.Fatal("should have errored - webhooks turned off") } } + func TestIncomingWebhooks(t *testing.T) { th := Setup().InitSystemAdmin() Client := th.SystemAdminClient @@ -529,11 +530,17 @@ func TestIncomingWebhooks(t *testing.T) { hook = Client.Must(Client.CreateIncomingWebhook(hook)).Data.(*model.IncomingWebhook) url := "/hooks/" + hook.Id + text := `this is a \"test\" + that contains a newline and a tab` if _, err := Client.DoPost(url, "{\"text\":\"this is a test\"}", "application/json"); err != nil { t.Fatal(err) } + if _, err := Client.DoPost(url, "{\"text\":\""+text+"\"}", "application/json"); err != nil { + t.Fatal(err) + } + if _, err := Client.DoPost(url, fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", channel1.Name), "application/json"); err != nil { t.Fatal(err) } @@ -552,6 +559,10 @@ func TestIncomingWebhooks(t *testing.T) { t.Fatal(err) } + if _, err := Client.DoPost(url, "payload={\"text\":\""+text+"\"}", "application/x-www-form-urlencoded"); err != nil { + t.Fatal(err) + } + attachmentPayload := `{ "text": "this is a test", "attachments": [ |