This commit is contained in:
浅念
2026-08-27 16:11:49 +08:00
commit 2d8ef3d7bb
104 changed files with 20196 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import request from 'supertest';
import { setupApp, teardown } from './setup.js';
let app: any;
beforeAll(async () => {
({ app } = await setupApp());
}, 90000);
afterAll(async () => {
await teardown();
});
describe('auth', () => {
it('login with admin env creds returns token', async () => {
const res = await request(app)
.post('/api/auth/login')
.send({ username: 'admin', password: 'admin-password-1234' });
expect(res.status).toBe(200);
expect(res.body.token).toMatch(/^[A-Za-z0-9._-]+$/);
});
it('wrong password 401', async () => {
const res = await request(app)
.post('/api/auth/login')
.send({ username: 'admin', password: 'wrong' });
expect(res.status).toBe(401);
});
});