1 /* tslint:disable:no-unused-expression */
11 setAccessTokensToServers,
13 } from '../../../../shared/utils'
15 checkBadCountPagination,
16 checkBadSortPagination,
17 checkBadStartPagination
18 } from '../../../../shared/utils/requests/check-api-params'
19 import { makeGetRequest } from '../../../../shared/utils/requests/requests'
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 () {
33 server = await runServer(1)
35 await setAccessTokensToServers([ server ])
39 password: 'my super password'
41 await createUser(server.url, server.accessToken, user.username, user.password)
42 userAccessToken = await userLogin(server, user)
45 describe('When listing jobs', function () {
47 it('Should fail with a bad state', async function () {
48 await makeGetRequest({
50 token: server.accessToken,
55 it('Should fail with a bad start pagination', async function () {
56 await checkBadStartPagination(server.url, path, server.accessToken)
59 it('Should fail with a bad count pagination', async function () {
60 await checkBadCountPagination(server.url, path, server.accessToken)
63 it('Should fail with an incorrect sort', async function () {
64 await checkBadSortPagination(server.url, path, server.accessToken)
67 it('Should fail with a non authenticated user', async function () {
68 await makeGetRequest({
71 statusCodeExpected: 401
75 it('Should fail with a non admin user', async function () {
76 await makeGetRequest({
79 token: userAccessToken,
80 statusCodeExpected: 403
85 after(async function () {
86 killallServers([ server ])
88 // Keep the logs if the test failed