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'
20 describe('Test jobs API validators', function () {
21 const path = '/api/v1/jobs/failed'
22 let server: ServerInfo
23 let userAccessToken = ''
25 // ---------------------------------------------------------------
27 before(async function () {
30 server = await flushAndRunServer(1)
32 await setAccessTokensToServers([ server ])
36 password: 'my super password'
38 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
39 userAccessToken = await userLogin(server, user)
42 describe('When listing jobs', function () {
44 it('Should fail with a bad state', async function () {
45 await makeGetRequest({
47 token: server.accessToken,
52 it('Should fail with an incorrect job type', async function () {
53 await makeGetRequest({
55 token: server.accessToken,
63 it('Should fail with a bad start pagination', async function () {
64 await checkBadStartPagination(server.url, path, server.accessToken)
67 it('Should fail with a bad count pagination', async function () {
68 await checkBadCountPagination(server.url, path, server.accessToken)
71 it('Should fail with an incorrect sort', async function () {
72 await checkBadSortPagination(server.url, path, server.accessToken)
75 it('Should fail with a non authenticated user', async function () {
76 await makeGetRequest({
79 statusCodeExpected: 401
83 it('Should fail with a non admin user', async function () {
84 await makeGetRequest({
87 token: userAccessToken,
88 statusCodeExpected: 403
94 after(async function () {
95 await cleanupTests([ server ])