From e39ab5c7dcfd6f16264b4a601aca7fa5a572dccf Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 10 Sep 2018 07:38:04 -0400 Subject: MM-12007 Add max dimensions to emoji images (#9379) --- api4/emoji_test.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'api4') diff --git a/api4/emoji_test.go b/api4/emoji_test.go index 1a9dc8e0f..e3aca4497 100644 --- a/api4/emoji_test.go +++ b/api4/emoji_test.go @@ -9,6 +9,7 @@ import ( _ "image/gif" "testing" + "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" @@ -105,16 +106,26 @@ func TestCreateEmoji(t *testing.T) { t.Fatal("create with wrong name") } + // try to create an emoji that's too wide + emoji = &model.Emoji{ + CreatorId: th.BasicUser.Id, + Name: model.NewId(), + } + + newEmoji, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, 10, app.MaxEmojiOriginalWidth+1), "image.gif") + if resp.Error == nil { + t.Fatal("should fail - emoji is too wide") + } + // try to create an emoji that's too tall emoji = &model.Emoji{ CreatorId: th.BasicUser.Id, Name: model.NewId(), } - newEmoji, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, 10, 1000), "image.gif") - CheckNoError(t, resp) - if newEmoji.Name != emoji.Name { - t.Fatal("create with wrong name") + newEmoji, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, app.MaxEmojiOriginalHeight+1, 10), "image.gif") + if resp.Error == nil { + t.Fatal("should fail - emoji is too tall") } // try to create an emoji that's too large -- cgit v1.2.3-1-g7c22