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:
bo0tzz
2026-07-30 15:12:25 -04:00
committed by GitHub
parent 1f16fe16c2
commit a316ba35ca
24 changed files with 249 additions and 66 deletions
@@ -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', () => {