MM-12007 Add max dimensions to emoji images (5.3) (#9407)

This commit is contained in:
Harrison Healey
2018-09-13 19:10:10 +02:00
committed by Carlos Tadeu Panato Junior
parent 7d60bc8cf5
commit fd21e53365
3 changed files with 29 additions and 7 deletions
+15 -4
View File
@@ -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