summaryrefslogtreecommitdiffstats
path: root/web/webhook_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2018-07-07 12:04:18 -0400
committerJoramWilander <jwawilander@gmail.com>2018-07-07 12:04:18 -0400
commitb78b216a3c8eb354085f97f33dac5e7661ac9188 (patch)
treedc7a253730a684bc6744c0b0bf36a87944242583 /web/webhook_test.go
parent359f12db33d45b6ffade0872ddf3652a5c52f4a8 (diff)
parent9e5ec7d09d4c51e278f17f25fb6c0f3484b50a3b (diff)
downloadchat-b78b216a3c8eb354085f97f33dac5e7661ac9188.tar.gz
chat-b78b216a3c8eb354085f97f33dac5e7661ac9188.tar.bz2
chat-b78b216a3c8eb354085f97f33dac5e7661ac9188.zip
Merge branch 'master' into plugins-2
Diffstat (limited to 'web/webhook_test.go')
-rw-r--r--web/webhook_test.go29
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) {