feat: add number library routing and cdr location support
This commit is contained in:
@@ -5,6 +5,7 @@ import { Test, type TestingModule } from '@nestjs/testing';
|
||||
import { FastifyAdapter, type NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
import request from 'supertest';
|
||||
import { hashPasswordArgon2id, sha256Token } from '@lisglosips/auth';
|
||||
import { CaptchaService } from './captcha.service.js';
|
||||
import { AUTH_REPOSITORY, type AuthRepository, type AuthSessionRecord, type AuthUserRecord, type CreateSessionInput } from './auth.types.js';
|
||||
|
||||
class E2eAuthRepository implements AuthRepository {
|
||||
@@ -77,6 +78,7 @@ class E2eAuthRepository implements AuthRepository {
|
||||
describe('LisgloSIPS Auth API', () => {
|
||||
let app: NestFastifyApplication;
|
||||
let repo: E2eAuthRepository;
|
||||
let captchaService: CaptchaService;
|
||||
let secret: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -101,6 +103,7 @@ describe('LisgloSIPS Auth API', () => {
|
||||
app.setGlobalPrefix('api/v2');
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
captchaService = app.get(CaptchaService);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -108,9 +111,20 @@ describe('LisgloSIPS Auth API', () => {
|
||||
});
|
||||
|
||||
it('logs in, refreshes with cookie rotation, and logs out', async () => {
|
||||
const login = await request(app.getHttpServer())
|
||||
const publicCaptcha = await request(app.getHttpServer()).get('/api/v2/auth/captcha').expect(200);
|
||||
expect(publicCaptcha.body.captchaId).toBeTypeOf('string');
|
||||
expect(publicCaptcha.body.imageDataUrl).toMatch(/^data:image\/svg\+xml;base64,/);
|
||||
expect(publicCaptcha.body.answer).toBeUndefined();
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.post('/api/v2/auth/login')
|
||||
.send({ username: 'operator', password: secret })
|
||||
.expect(401);
|
||||
|
||||
const captcha = captchaService.createChallenge();
|
||||
const login = await request(app.getHttpServer())
|
||||
.post('/api/v2/auth/login')
|
||||
.send({ username: 'operator', password: secret, captchaId: captcha.id, captchaCode: captcha.answer })
|
||||
.expect(200);
|
||||
const loginCookie = login.headers['set-cookie'][0];
|
||||
const firstRefreshToken = /lisglosips_refresh=([^;]+)/.exec(loginCookie)?.[1] ?? '';
|
||||
|
||||
Reference in New Issue
Block a user