1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
9 setAccessTokensToServers
10 } from '../../../../shared/extra-utils'
12 checkBadCountPagination,
13 checkBadSortPagination,
14 checkBadStartPagination
15 } from '../../../../shared/extra-utils/requests/check-api-params'
16 import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
17 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 describe('Test jobs API validators', function () {
20 const path = '/api/v1/jobs/failed'
21 let server: PeerTubeServer
22 let userAccessToken = ''
24 // ---------------------------------------------------------------
26 before(async function () {
29 server = await createSingleServer(1)
31 await setAccessTokensToServers([ server ])
35 password: 'my super password'
37 await server.users.create({ username: user.username, password: user.password })
38 userAccessToken = await server.login.getAccessToken(user)
41 describe('When listing jobs', function () {
43 it('Should fail with a bad state', async function () {
44 await makeGetRequest({
46 token: server.accessToken,
51 it('Should fail with an incorrect job type', async function () {
52 await makeGetRequest({
54 token: server.accessToken,
62 it('Should fail with a bad start pagination', async function () {
63 await checkBadStartPagination(server.url, path, server.accessToken)
66 it('Should fail with a bad count pagination', async function () {
67 await checkBadCountPagination(server.url, path, server.accessToken)
70 it('Should fail with an incorrect sort', async function () {
71 await checkBadSortPagination(server.url, path, server.accessToken)
74 it('Should fail with a non authenticated user', async function () {
75 await makeGetRequest({
78 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
82 it('Should fail with a non admin user', async function () {
83 await makeGetRequest({
86 token: userAccessToken,
87 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
93 after(async function () {
94 await cleanupTests([ server ])