diff options
author | cpanato <ctadeu@gmail.com> | 2018-07-06 10:57:40 +0200 |
---|---|---|
committer | cpanato <ctadeu@gmail.com> | 2018-07-06 10:57:40 +0200 |
commit | a92f5addccad0f77079308ff853a8251db5f2d09 (patch) | |
tree | f4aefb58970b38a5b561551ccd3d4cd430dbdce7 /web/webhook_test.go | |
parent | 4de50ddfc3ef09ddc0a56c8ff9bf2429df524aa5 (diff) | |
parent | 0896b5c64ef224f0f8835b9727d1c1b94cbe7c29 (diff) | |
download | chat-a92f5addccad0f77079308ff853a8251db5f2d09.tar.gz chat-a92f5addccad0f77079308ff853a8251db5f2d09.tar.bz2 chat-a92f5addccad0f77079308ff853a8251db5f2d09.zip |
Merge remote-tracking branch 'upstream/release-5.1' into release-5.1-daily-merge-20180706
Diffstat (limited to 'web/webhook_test.go')
-rw-r--r-- | web/webhook_test.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/web/webhook_test.go b/web/webhook_test.go index 64ce7bf25..07fca70ed 100644 --- a/web/webhook_test.go +++ b/web/webhook_test.go @@ -97,13 +97,30 @@ func TestIncomingWebhook(t *testing.T) { assert.True(t, resp.StatusCode == http.StatusOK) }) - t.Run("WebhookExperimentReadOnly", func(t *testing.T) { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false }) - _, err := http.Post(url, "application/json", strings.NewReader(fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", model.DEFAULT_CHANNEL))) - assert.Nil(t, err, "Not read only") - - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true }) + t.Run("WebhookExperimentalReadOnly", func(t *testing.T) { th.App.SetLicense(model.NewTestLicense()) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true }) + + // Read only default channel should fail. + resp, err := http.Post(url, "application/json", strings.NewReader(fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", model.DEFAULT_CHANNEL))) + require.Nil(t, err) + assert.True(t, resp.StatusCode != http.StatusOK) + + // None-default channel should still work. + resp, err = http.Post(url, "application/json", strings.NewReader(fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", th.BasicChannel.Name))) + require.Nil(t, err) + assert.True(t, resp.StatusCode == http.StatusOK) + + // System-Admin Owned Hook + adminHook, err := th.App.CreateIncomingWebhookForChannel(th.SystemAdminUser.Id, th.BasicChannel, &model.IncomingWebhook{ChannelId: th.BasicChannel.Id}) + require.Nil(t, err) + adminUrl := ApiClient.Url + "/hooks/" + adminHook.Id + + resp, err = http.Post(adminUrl, "application/json", strings.NewReader(fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", model.DEFAULT_CHANNEL))) + require.Nil(t, err) + assert.True(t, resp.StatusCode == http.StatusOK) + + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false }) }) t.Run("WebhookAttachments", func(t *testing.T) { |