1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5 import { HttpStatusCode } from '@shared/models'
7 describe('Test debug API validators', function () {
8 const path = '/api/v1/server/debug'
9 let server: PeerTubeServer
10 let userAccessToken = ''
12 // ---------------------------------------------------------------
14 before(async function () {
17 server = await createSingleServer(1)
19 await setAccessTokensToServers([ server ])
23 password: 'my super password'
25 await server.users.create({ username: user.username, password: user.password })
26 userAccessToken = await server.login.getAccessToken(user)
29 describe('When getting debug endpoint', function () {
31 it('Should fail with a non authenticated user', async function () {
32 await makeGetRequest({
35 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
39 it('Should fail with a non admin user', async function () {
40 await makeGetRequest({
43 token: userAccessToken,
44 expectedStatus: HttpStatusCode.FORBIDDEN_403
48 it('Should succeed with the correct params', async function () {
49 await makeGetRequest({
52 token: server.accessToken,
53 query: { startDate: new Date().toISOString() },
54 expectedStatus: HttpStatusCode.OK_200
59 after(async function () {
60 await cleanupTests([ server ])