diff --git a/test/backend/unit/assets/old_photo.jpg b/test/backend/assets/old_photo.jpg similarity index 100% rename from test/backend/unit/assets/old_photo.jpg rename to test/backend/assets/old_photo.jpg diff --git a/test/backend/unit/assets/old_photo.json b/test/backend/assets/old_photo.json similarity index 100% rename from test/backend/unit/assets/old_photo.json rename to test/backend/assets/old_photo.json diff --git a/test/backend/unit/assets/test image öüóőúéáű-.,.jpg b/test/backend/assets/test image öüóőúéáű-.,.jpg similarity index 100% rename from test/backend/unit/assets/test image öüóőúéáű-.,.jpg rename to test/backend/assets/test image öüóőúéáű-.,.jpg diff --git a/test/backend/unit/assets/test image öüóőúéáű-.,.json b/test/backend/assets/test image öüóőúéáű-.,.json similarity index 100% rename from test/backend/unit/assets/test image öüóőúéáű-.,.json rename to test/backend/assets/test image öüóőúéáű-.,.json diff --git a/test/backend/unit/assets/test_png.png b/test/backend/assets/test_png.png similarity index 100% rename from test/backend/unit/assets/test_png.png rename to test/backend/assets/test_png.png diff --git a/test/backend/unit/assets/video.json b/test/backend/assets/video.json similarity index 100% rename from test/backend/unit/assets/video.json rename to test/backend/assets/video.json diff --git a/test/backend/unit/assets/video.mp4 b/test/backend/assets/video.mp4 similarity index 100% rename from test/backend/unit/assets/video.mp4 rename to test/backend/assets/video.mp4 diff --git a/test/backend/unit/middlewares/user/AuthenticationMWs.ts b/test/backend/unit/middlewares/user/AuthenticationMWs.ts index 43568d62..b3c1a2d4 100644 --- a/test/backend/unit/middlewares/user/AuthenticationMWs.ts +++ b/test/backend/unit/middlewares/user/AuthenticationMWs.ts @@ -50,7 +50,10 @@ describe('Authentication middleware', () => { expect(err.code).to.be.eql(ErrorCodes.NOT_AUTHENTICATED); done(); }; - AuthenticationMWs.authenticate(req, null, next); + AuthenticationMWs.authenticate(req, { + status: () => { + } + }, next); }); }); @@ -59,7 +62,9 @@ describe('Authentication middleware', () => { describe('authorisePath', () => { const req = { - user: {permissions: null}, + session: { + user: {permissions: null} + }, sessionOptions: {}, query: {}, params: { @@ -80,14 +85,14 @@ describe('Authentication middleware', () => { }; it('should catch unauthorized path usage', async () => { - req.user.permissions = [path.normalize('/sub/subsub')]; + req.session.user.permissions = [path.normalize('/sub/subsub')]; expect(await test('/sub/subsub')).to.be.eql('ok'); expect(await test('/test')).to.be.eql(403); expect(await test('/')).to.be.eql(403); expect(await test('/sub/test')).to.be.eql(403); expect(await test('/sub/subsub/test')).to.be.eql(403); expect(await test('/sub/subsub/test/test2')).to.be.eql(403); - req.user.permissions = [path.normalize('/sub/subsub'), path.normalize('/sub/subsub2')]; + req.session.user.permissions = [path.normalize('/sub/subsub'), path.normalize('/sub/subsub2')]; expect(await test('/sub/subsub2')).to.be.eql('ok'); expect(await test('/sub/subsub')).to.be.eql('ok'); expect(await test('/test')).to.be.eql(403); @@ -95,7 +100,7 @@ describe('Authentication middleware', () => { expect(await test('/sub/test')).to.be.eql(403); expect(await test('/sub/subsub/test')).to.be.eql(403); expect(await test('/sub/subsub2/test')).to.be.eql(403); - req.user.permissions = [path.normalize('/sub/subsub*')]; + req.session.user.permissions = [path.normalize('/sub/subsub*')]; expect(await test('/b')).to.be.eql(403); expect(await test('/sub')).to.be.eql(403); expect(await test('/sub/subsub2')).to.be.eql(403); @@ -272,7 +277,7 @@ describe('Authentication middleware', () => { }; const next = (err: ErrorDTO) => { expect(err).to.be.undefined; - expect(req.user).to.be.eql('test user'); + expect(req.session.user).to.be.eql('test user'); done(); }; ObjectManagers.getInstance().UserManager = { diff --git a/test/backend/unit/model/fileprocessing/PhotoProcessing.spec.ts b/test/backend/unit/model/fileprocessing/PhotoProcessing.spec.ts index 6ee86ffd..fe8d5b61 100644 --- a/test/backend/unit/model/fileprocessing/PhotoProcessing.spec.ts +++ b/test/backend/unit/model/fileprocessing/PhotoProcessing.spec.ts @@ -12,7 +12,7 @@ describe('PhotoProcessing', () => { Config.load(); Config.Client.Media.Thumbnail.thumbnailSizes = []; - ProjectPath.ImageFolder = path.join(__dirname, './../../assets'); + ProjectPath.ImageFolder = path.join(__dirname, './../../../assets'); const photoPath = path.join(ProjectPath.ImageFolder, 'test_png.png'); expect(await PhotoProcessing @@ -39,7 +39,7 @@ describe('PhotoProcessing', () => { Config.load(); Config.Server.Media.Photo.Converting.resolution = null; Config.Client.Media.Thumbnail.thumbnailSizes = [10, 20]; - ProjectPath.ImageFolder = path.join(__dirname, './../../assets'); + ProjectPath.ImageFolder = path.join(__dirname, './../../../assets'); const photoPath = path.join(ProjectPath.ImageFolder, 'test_png.png'); for (let i = 0; i < Config.Client.Media.Thumbnail.thumbnailSizes.length; ++i) { diff --git a/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts b/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts index 89ceae76..4a296570 100644 --- a/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts +++ b/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts @@ -10,7 +10,7 @@ describe('VideoProcessing', () => { // tslint:disable:no-unused-expression it('should generate converted file path', async () => { - ProjectPath.ImageFolder = path.join(__dirname, './../../assets'); + ProjectPath.ImageFolder = path.join(__dirname, './../../../assets'); const videoPath = path.join(ProjectPath.ImageFolder, 'video.mp4'); expect(await VideoProcessing .isValidConvertedPath(VideoProcessing.generateConvertedFilePath(videoPath))) diff --git a/test/backend/unit/model/threading/DiskMangerWorker.spec.ts b/test/backend/unit/model/threading/DiskMangerWorker.spec.ts index c0e307d1..ed3544eb 100644 --- a/test/backend/unit/model/threading/DiskMangerWorker.spec.ts +++ b/test/backend/unit/model/threading/DiskMangerWorker.spec.ts @@ -8,11 +8,11 @@ import {Utils} from '../../../../../src/common/Utils'; describe('DiskMangerWorker', () => { it('should parse metadata', async () => { - Config.Server.Media.folder = path.join(__dirname, '/../../assets'); - ProjectPath.ImageFolder = path.join(__dirname, '/../../assets'); + Config.Server.Media.folder = path.join(__dirname, '/../../../assets'); + ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets'); const dir = await DiskMangerWorker.scanDirectory('/'); expect(dir.media.length).to.be.equals(4); - const expected = require(path.join(__dirname, '/../../assets/test image öüóőúéáű-.,.json')); + const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json')); expect(Utils.clone(dir.media[1].name)).to.be.deep.equal('test image öüóőúéáű-.,.jpg'); expect(Utils.clone(dir.media[1].metadata)).to.be.deep.equal(expected); }); diff --git a/test/backend/unit/model/threading/MetaDataLoader.spec.ts b/test/backend/unit/model/threading/MetaDataLoader.spec.ts index 17506154..18844107 100644 --- a/test/backend/unit/model/threading/MetaDataLoader.spec.ts +++ b/test/backend/unit/model/threading/MetaDataLoader.spec.ts @@ -6,7 +6,7 @@ import * as path from 'path'; describe('MetadataLoader', () => { it('should load png', async () => { - const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../assets/test_png.png')); + const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/test_png.png')); delete data.creationDate; // creation time for png not supported expect(Utils.clone(data)).to.be.deep.equal(Utils.clone({ fileSize: 2155, @@ -19,22 +19,22 @@ describe('MetadataLoader', () => { }); it('should load jpg', async () => { - const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../assets/test image öüóőúéáű-.,.jpg')); - const expected = require(path.join(__dirname, '/../../assets/test image öüóőúéáű-.,.json')); + const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.jpg')); + const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should load jpg 2', async () => { - const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../assets/old_photo.jpg')); - const expected = require(path.join(__dirname, '/../../assets/old_photo.json')); + const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/old_photo.jpg')); + const expected = require(path.join(__dirname, '/../../../assets/old_photo.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should load mp4', async () => { - const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../assets/video.mp4')); - const expected = require(path.join(__dirname, '/../../assets/video.json')); + const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/video.mp4')); + const expected = require(path.join(__dirname, '/../../../assets/video.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); });