summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-07-16 13:04:52 +0100
committerGitHub <noreply@github.com>2018-07-16 13:04:52 +0100
commit9d9fcd9ac5d10a6ff1050477d527385d6af2f6bf (patch)
tree034047530a94301369accb0174a8146cdf554895 /api4
parent10f571784b55509a7995093b36f28ed4b848dd53 (diff)
downloadchat-9d9fcd9ac5d10a6ff1050477d527385d6af2f6bf.tar.gz
chat-9d9fcd9ac5d10a6ff1050477d527385d6af2f6bf.tar.bz2
chat-9d9fcd9ac5d10a6ff1050477d527385d6af2f6bf.zip
MM-11172: Don't allow reacting in read-only town square. (#9106)
Diffstat (limited to 'api4')
-rw-r--r--api4/reaction_test.go62
1 files changed, 62 insertions, 0 deletions
diff --git a/api4/reaction_test.go b/api4/reaction_test.go
index ac1a49671..dda9a578a 100644
--- a/api4/reaction_test.go
+++ b/api4/reaction_test.go
@@ -172,6 +172,33 @@ func TestSaveReaction(t *testing.T) {
}
th.AddPermissionToRole(model.PERMISSION_ADD_REACTION.Id, model.CHANNEL_USER_ROLE_ID)
})
+
+ t.Run("unable-to-react-in-read-only-town-square", func(t *testing.T) {
+ th.LoginBasic()
+
+ channel, err := th.App.GetChannelByName("town-square", th.BasicTeam.Id)
+ assert.Nil(t, err)
+ post := th.CreatePostWithClient(th.Client, channel)
+
+ th.App.SetLicense(model.NewTestLicense())
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
+
+ reaction := &model.Reaction{
+ UserId: userId,
+ PostId: post.Id,
+ EmojiName: "smile",
+ }
+
+ _, resp := Client.SaveReaction(reaction)
+ CheckForbiddenStatus(t, resp)
+
+ if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 3 {
+ t.Fatal("should have not created a reactions")
+ }
+
+ th.App.RemoveLicense()
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
+ })
}
func TestGetReactions(t *testing.T) {
@@ -451,4 +478,39 @@ func TestDeleteReaction(t *testing.T) {
}
th.AddPermissionToRole(model.PERMISSION_REMOVE_OTHERS_REACTIONS.Id, model.SYSTEM_ADMIN_ROLE_ID)
})
+
+ t.Run("unable-to-delete-reactions-in-read-only-town-square", func(t *testing.T) {
+ th.LoginBasic()
+
+ channel, err := th.App.GetChannelByName("town-square", th.BasicTeam.Id)
+ assert.Nil(t, err)
+ post := th.CreatePostWithClient(th.Client, channel)
+
+ th.App.SetLicense(model.NewTestLicense())
+
+ reaction := &model.Reaction{
+ UserId: userId,
+ PostId: post.Id,
+ EmojiName: "smile",
+ }
+
+ r1, resp := Client.SaveReaction(reaction)
+ CheckNoError(t, resp)
+
+ if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 1 {
+ t.Fatal("should have created a reactions")
+ }
+
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
+
+ _, resp = th.SystemAdminClient.DeleteReaction(r1)
+ CheckForbiddenStatus(t, resp)
+
+ if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 1 {
+ t.Fatal("should have not deleted a reactions")
+ }
+
+ th.App.RemoveLicense()
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
+ })
}