fix: only check external path once (#4419)

This commit is contained in:
Jonathan Jogenfors 2023-10-10 15:44:43 +02:00 committed by GitHub
parent f57acc0802
commit 83b63ca12e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 69 deletions

View file

@ -415,61 +415,6 @@ describe(LibraryService.name, () => {
});
});
it('should skip an asset if the user cannot be found', async () => {
userMock.get.mockResolvedValue(null);
const mockLibraryJob: ILibraryFileJob = {
id: libraryStub.externalLibrary1.id,
ownerId: mockUser.id,
assetPath: '/data/user1/photo.jpg',
force: false,
};
expect(sut.handleAssetRefresh(mockLibraryJob)).resolves.toBe(false);
});
it('should skip an asset if external path is not set', async () => {
mockUser = userStub.admin;
userMock.get.mockResolvedValue(mockUser);
const mockLibraryJob: ILibraryFileJob = {
id: libraryStub.externalLibrary1.id,
ownerId: mockUser.id,
assetPath: '/data/user1/photo.jpg',
force: false,
};
expect(sut.handleAssetRefresh(mockLibraryJob)).resolves.toBe(false);
});
it("should skip an asset if it isn't in the external path", async () => {
mockUser = userStub.externalPath1;
userMock.get.mockResolvedValue(mockUser);
const mockLibraryJob: ILibraryFileJob = {
id: libraryStub.externalLibrary1.id,
ownerId: mockUser.id,
assetPath: '/etc/rootpassword.jpg',
force: false,
};
expect(sut.handleAssetRefresh(mockLibraryJob)).resolves.toBe(false);
});
it('should skip an asset if directory traversal is attempted', async () => {
mockUser = userStub.externalPath1;
userMock.get.mockResolvedValue(mockUser);
const mockLibraryJob: ILibraryFileJob = {
id: libraryStub.externalLibrary1.id,
ownerId: mockUser.id,
assetPath: '/data/user1/../../etc/rootpassword.jpg',
force: false,
};
expect(sut.handleAssetRefresh(mockLibraryJob)).resolves.toBe(false);
});
it('should set a missing asset to offline', async () => {
storageMock.stat.mockRejectedValue(new Error());