|
|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
import { LoginResponseDto } from '@immich/sdk';
|
|
|
|
|
import { LoginResponseDto, getConfig } from '@immich/sdk';
|
|
|
|
|
import { createUserDto } from 'src/fixtures';
|
|
|
|
|
import { errorDto } from 'src/responses';
|
|
|
|
|
import { app, utils } from 'src/utils';
|
|
|
|
|
import { app, asBearerAuth, utils } from 'src/utils';
|
|
|
|
|
import request from 'supertest';
|
|
|
|
|
import { beforeAll, describe, expect, it } from 'vitest';
|
|
|
|
|
|
|
|
|
|
const getSystemConfig = (accessToken: string) => getConfig({ headers: asBearerAuth(accessToken) });
|
|
|
|
|
|
|
|
|
|
describe('/system-config', () => {
|
|
|
|
|
let admin: LoginResponseDto;
|
|
|
|
|
let nonAdmin: LoginResponseDto;
|
|
|
|
|
@ -60,4 +62,25 @@ describe('/system-config', () => {
|
|
|
|
|
expect(body).toEqual(expect.objectContaining({ id: 'immich-map-dark' }));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('PUT /system-config', () => {
|
|
|
|
|
it('should require authentication', async () => {
|
|
|
|
|
const { status, body } = await request(app).put('/system-config');
|
|
|
|
|
expect(status).toBe(401);
|
|
|
|
|
expect(body).toEqual(errorDto.unauthorized);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should reject an invalid config entry', async () => {
|
|
|
|
|
const { status, body } = await request(app)
|
|
|
|
|
.put('/system-config')
|
|
|
|
|
.set('Authorization', `Bearer ${admin.accessToken}`)
|
|
|
|
|
.send({
|
|
|
|
|
...(await getSystemConfig(admin.accessToken)),
|
|
|
|
|
storageTemplate: { enabled: true, hashVerificationEnabled: true, template: '{{foo}}' },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(status).toBe(400);
|
|
|
|
|
expect(body).toEqual(errorDto.badRequest(expect.stringContaining('Invalid storage template')));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|