1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
10 setAccessTokensToServers,
12 } from '../../../../shared/extra-utils'
14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
17 } from '../../../../shared/extra-utils/requests/check-api-params'
18 import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
19 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
21 describe('Test jobs API validators', function () {
22 const path = '/api/v1/jobs/failed'
23 let server: ServerInfo
24 let userAccessToken = ''
26 // ---------------------------------------------------------------
28 before(async function () {
31 server = await flushAndRunServer(1)
33 await setAccessTokensToServers([ server ])
37 password: 'my super password'
39 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
40 userAccessToken = await userLogin(server, user)
43 describe('When listing jobs', function () {
45 it('Should fail with a bad state', async function () {
46 await makeGetRequest({
48 token: server.accessToken,
53 it('Should fail with an incorrect job type', async function () {
54 await makeGetRequest({
56 token: server.accessToken,
64 it('Should fail with a bad start pagination', async function () {
65 await checkBadStartPagination(server.url, path, server.accessToken)
68 it('Should fail with a bad count pagination', async function () {
69 await checkBadCountPagination(server.url, path, server.accessToken)
72 it('Should fail with an incorrect sort', async function () {
73 await checkBadSortPagination(server.url, path, server.accessToken)
76 it('Should fail with a non authenticated user', async function () {
77 await makeGetRequest({
80 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
84 it('Should fail with a non admin user', async function () {
85 await makeGetRequest({
88 token: userAccessToken,
89 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
95 after(async function () {
96 await cleanupTests([ server ])