1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
12 setAccessTokensToServers
13 } from '@shared/extra-utils'
14 import { HttpStatusCode } from '@shared/models'
16 describe('Test jobs API validators', function () {
17 const path = '/api/v1/jobs/failed'
18 let server: PeerTubeServer
19 let userAccessToken = ''
21 // ---------------------------------------------------------------
23 before(async function () {
26 server = await createSingleServer(1)
28 await setAccessTokensToServers([ server ])
32 password: 'my super password'
34 await server.users.create({ username: user.username, password: user.password })
35 userAccessToken = await server.login.getAccessToken(user)
38 describe('When listing jobs', function () {
40 it('Should fail with a bad state', async function () {
41 await makeGetRequest({
43 token: server.accessToken,
48 it('Should fail with an incorrect job type', async function () {
49 await makeGetRequest({
51 token: server.accessToken,
59 it('Should fail with a bad start pagination', async function () {
60 await checkBadStartPagination(server.url, path, server.accessToken)
63 it('Should fail with a bad count pagination', async function () {
64 await checkBadCountPagination(server.url, path, server.accessToken)
67 it('Should fail with an incorrect sort', async function () {
68 await checkBadSortPagination(server.url, path, server.accessToken)
71 it('Should fail with a non authenticated user', async function () {
72 await makeGetRequest({
75 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
79 it('Should fail with a non admin user', async function () {
80 await makeGetRequest({
83 token: userAccessToken,
84 expectedStatus: HttpStatusCode.FORBIDDEN_403
90 after(async function () {
91 await cleanupTests([ server ])