diff options
author | Martin Kraft <mkraft@users.noreply.github.com> | 2018-05-22 14:15:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-22 14:15:54 -0400 |
commit | f40666f9e8ee9aef5f7e9739f0fa8857bfbc76ab (patch) | |
tree | 85d274cb7ecca9ea6e8e595b15aa631c54acf1ea /web/webhook_test.go | |
parent | 4c683aff7627040ff811f065848a820b2cb19d59 (diff) | |
parent | ce378adc97399dcae9e1c9621c584669b813b2d2 (diff) | |
download | chat-f40666f9e8ee9aef5f7e9739f0fa8857bfbc76ab.tar.gz chat-f40666f9e8ee9aef5f7e9739f0fa8857bfbc76ab.tar.bz2 chat-f40666f9e8ee9aef5f7e9739f0fa8857bfbc76ab.zip |
Merge branch 'master' into advanced-permissions-phase-2
Diffstat (limited to 'web/webhook_test.go')
-rw-r--r-- | web/webhook_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/web/webhook_test.go b/web/webhook_test.go index 48e0a2744..64ce7bf25 100644 --- a/web/webhook_test.go +++ b/web/webhook_test.go @@ -182,6 +182,29 @@ func TestIncomingWebhook(t *testing.T) { assert.True(t, resp.StatusCode == http.StatusOK) }) + t.Run("ChannelLockedWebhook", func(t *testing.T) { + channel, err := th.App.CreateChannel(&model.Channel{TeamId: th.BasicTeam.Id, Name: model.NewId(), DisplayName: model.NewId(), Type: model.CHANNEL_OPEN, CreatorId: th.BasicUser.Id}, true) + require.Nil(t, err) + + hook, err := th.App.CreateIncomingWebhookForChannel(th.BasicUser.Id, th.BasicChannel, &model.IncomingWebhook{ChannelId: th.BasicChannel.Id, ChannelLocked: true}) + require.Nil(t, err) + + url := ApiClient.Url + "/hooks/" + hook.Id + + payload := "payload={\"text\": \"test text\"}" + resp, err2 := http.Post(url, "application/x-www-form-urlencoded", strings.NewReader(payload)) + require.Nil(t, err2) + assert.True(t, resp.StatusCode == http.StatusOK) + + resp, err2 = http.Post(url, "application/json", strings.NewReader(fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", th.BasicChannel.Name))) + require.Nil(t, err2) + assert.True(t, resp.StatusCode == http.StatusOK) + + resp, err2 = http.Post(url, "application/json", strings.NewReader(fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", channel.Name))) + require.Nil(t, err2) + assert.True(t, resp.StatusCode == http.StatusForbidden) + }) + t.Run("DisableWebhooks", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = false }) resp, err := http.Post(url, "application/json", strings.NewReader("{\"text\":\"this is a test\"}")) |