mirror of
https://github.com/immich-app/immich.git
synced 2026-08-01 00:21:10 -07:00
fix: shared check for server setup availability (#30311)
* fix: shared check for server setup availability * chore: add medium test * feat: require @Authenticated decorator everywhere * fix: lints
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { AuthController } from 'src/controllers/auth.controller';
|
||||
import { LoginResponseDto } from 'src/dtos/auth.dto';
|
||||
import { AuthService } from 'src/services/auth.service';
|
||||
@@ -76,6 +77,18 @@ describe(AuthController.name, () => {
|
||||
.send({ name: 'admin', password: 'password', email: 'admin@local' });
|
||||
expect(status).toEqual(201);
|
||||
});
|
||||
|
||||
it('should not sign up an admin when setup is unavailable', async () => {
|
||||
ctx.requireSetupAvailable.mockRejectedValue(new BadRequestException('Admin setup is not available'));
|
||||
|
||||
const { status, body } = await request(ctx.getHttpServer())
|
||||
.post('/auth/admin-sign-up')
|
||||
.send({ name, email, password });
|
||||
|
||||
expect(status).toEqual(400);
|
||||
expect(body).toEqual(errorDto.badRequest('Admin setup is not available'));
|
||||
expect(service.adminSignUp).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /auth/login', () => {
|
||||
|
||||
Reference in New Issue
Block a user