summaryrefslogtreecommitdiffstats
path: root/api/webhook_test.go
diff options
context:
space:
mode:
authorDavid Meza <dmeza@users.noreply.github.com>2017-09-01 08:53:55 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-09-01 09:53:55 -0400
commit3c5280119357e3742811fd724601d0bef01bcb29 (patch)
tree70a63e6748a5fd15b001f2750992deb03b4b68cf /api/webhook_test.go
parentbaa992a5594c271504c4551177a3d69eab848913 (diff)
downloadchat-3c5280119357e3742811fd724601d0bef01bcb29.tar.gz
chat-3c5280119357e3742811fd724601d0bef01bcb29.tar.bz2
chat-3c5280119357e3742811fd724601d0bef01bcb29.zip
Config to make town square read only (#7140)
* Be able to make Town Square read-only (Disable typing messages for non admins). * Do not emit UserTypingEvent when TownSquareIsReadOnly and is Town Square. * Add unit tests for TownSquareIsReadOnly config value and logic. * Add TownSquareIsReadOnly to System console>Policy. Added Telemetry. * Add control for TownSquareIsReadOnly=true only for License Enterprise Edition E10 & E20. * Update en.json * Update en.json * Update policy_settings.jsx * Change config value from TownSquareIsReadOnly to ExperimentalTownSquareIsReadOnly. * Refactored to simplify. Avoid code repeat and multiple db calls.
Diffstat (limited to 'api/webhook_test.go')
-rw-r--r--api/webhook_test.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/api/webhook_test.go b/api/webhook_test.go
index 93d596bb1..c84aee992 100644
--- a/api/webhook_test.go
+++ b/api/webhook_test.go
@@ -956,7 +956,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
}
func TestIncomingWebhooks(t *testing.T) {
- th := Setup().InitSystemAdmin()
+ th := Setup().InitBasic().InitSystemAdmin()
Client := th.SystemAdminClient
team := th.SystemAdminTeam
channel1 := th.CreateChannel(Client, team)
@@ -1004,6 +1004,29 @@ func TestIncomingWebhooks(t *testing.T) {
t.Fatal(err)
}
+ if _, err := th.BasicClient.DoPost(url, fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", model.DEFAULT_CHANNEL), "application/json"); err != nil {
+ t.Fatal("should not have failed -- ExperimentalTownSquareIsReadOnly is false and it's not a read only channel")
+ }
+
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
+ disableTownSquareReadOnly := utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly
+ defer func() {
+ utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = disableTownSquareReadOnly
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
+ utils.SetDefaultRolesBasedOnConfig()
+ }()
+ *utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true
+ utils.SetDefaultRolesBasedOnConfig()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
+
+ if _, err := th.BasicClient.DoPost(url, fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", model.DEFAULT_CHANNEL), "application/json"); err == nil {
+ t.Fatal("should have failed -- ExperimentalTownSquareIsReadOnly is true and it's a read only channel")
+ }
+
attachmentPayload := `{
"text": "this is a test",
"attachments": [