后台
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user