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

Этот коммит содержится в:
Harrison Healey
2018-09-13 13:10:10 -04:00
коммит произвёл Carlos Tadeu Panato Junior
родитель 7d60bc8cf5
Коммит fd21e53365
3 изменённых файлов: 29 добавлений и 7 удалений

Просмотреть файл

@@ -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