fix: only allow png/jpg/bmp in cover/profile images

This commit is contained in:
Barış Soner Uşaklı
2019-09-21 23:10:49 -04:00
parent 5505628c8d
commit 96ab8d05aa
5 changed files with 76 additions and 46 deletions

View File

@@ -1296,7 +1296,10 @@ describe('Groups', function () {
it('should upload group cover image from file', function (done) {
var data = {
groupName: 'Test',
file: imagePath,
file: {
path: imagePath,
type: 'image/png',
},
};
socketGroups.cover.update({ uid: adminUid }, data, function (err, data) {
assert.ifError(err);
@@ -1328,6 +1331,17 @@ describe('Groups', function () {
});
});
it('should fail to upload group cover with invalid image', function (done) {
var data = {
groupName: 'Test',
imageData: 'data:image/svg;base64,iVBORw0KGgoAAAANSUhEUgAAABwA',
};
socketGroups.cover.update({ uid: adminUid }, data, function (err, data) {
assert.equal(err.message, '[[error:invalid-image]]');
done();
});
});
it('should update group cover position', function (done) {
var data = {
groupName: 'Test',