mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(server): auth delete device (#4720)
* refactor(server): auth delete device * fix: person e2e
This commit is contained in:
@@ -189,6 +189,14 @@ describe(`${AuthController.name} (e2e)`, () => {
|
||||
expect(body).toEqual(errorStub.unauthorized);
|
||||
});
|
||||
|
||||
it('should throw an error for a non-existent device id', async () => {
|
||||
const { status, body } = await request(server)
|
||||
.delete(`/auth/devices/${uuidStub.notFound}`)
|
||||
.set('Authorization', `Bearer ${accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorStub.badRequest('Not found or no authDevice.delete access'));
|
||||
});
|
||||
|
||||
it('should logout a device', async () => {
|
||||
const [device] = await api.authApi.getAuthDevices(server, accessToken);
|
||||
const { status } = await request(server)
|
||||
|
||||
@@ -139,10 +139,10 @@ describe(`${PersonController.name}`, () => {
|
||||
|
||||
it('should not accept invalid birth dates', async () => {
|
||||
for (const { birthDate, response } of [
|
||||
{ birthDate: false, response: ['id must be a UUID'] },
|
||||
{ birthDate: false, response: 'Not found or no person.write access' },
|
||||
{ birthDate: 'false', response: ['birthDate must be a Date instance'] },
|
||||
{ birthDate: '123567', response: ['id must be a UUID'] },
|
||||
{ birthDate: 123456, response: ['id must be a UUID'] },
|
||||
{ birthDate: '123567', response: 'Not found or no person.write access' },
|
||||
{ birthDate: 123567, response: 'Not found or no person.write access' },
|
||||
]) {
|
||||
const { status, body } = await request(server)
|
||||
.put(`/person/${uuidStub.notFound}`)
|
||||
|
||||
3
server/test/fixtures/uuid.stub.ts
vendored
3
server/test/fixtures/uuid.stub.ts
vendored
@@ -1,4 +1,5 @@
|
||||
export const uuidStub = {
|
||||
invalid: 'invalid-uuid',
|
||||
notFound: '00000000-0000-0000-0000-000000000000',
|
||||
// valid uuid v4
|
||||
notFound: '00000000-0000-4000-a000-000000000000',
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import { AccessCore, IAccessRepository } from '@app/domain';
|
||||
export interface IAccessRepositoryMock {
|
||||
asset: jest.Mocked<IAccessRepository['asset']>;
|
||||
album: jest.Mocked<IAccessRepository['album']>;
|
||||
authDevice: jest.Mocked<IAccessRepository['authDevice']>;
|
||||
library: jest.Mocked<IAccessRepository['library']>;
|
||||
timeline: jest.Mocked<IAccessRepository['timeline']>;
|
||||
person: jest.Mocked<IAccessRepository['person']>;
|
||||
@@ -27,6 +28,10 @@ export const newAccessRepositoryMock = (reset = true): IAccessRepositoryMock =>
|
||||
hasSharedLinkAccess: jest.fn(),
|
||||
},
|
||||
|
||||
authDevice: {
|
||||
hasOwnerAccess: jest.fn(),
|
||||
},
|
||||
|
||||
library: {
|
||||
hasOwnerAccess: jest.fn(),
|
||||
hasPartnerAccess: jest.fn(),
|
||||
|
||||
Reference in New Issue
Block a user