1 /* tslint:disable:no-unused-expression */
11 setAccessTokensToServers,
14 } from '../../../../shared/extra-utils'
16 checkBadCountPagination,
17 checkBadSortPagination,
18 checkBadStartPagination
19 } from '../../../../shared/extra-utils/requests/check-api-params'
20 import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
22 describe('Test jobs API validators', function () {
23 const path = '/api/v1/jobs/failed'
24 let server: ServerInfo
25 let userAccessToken = ''
27 // ---------------------------------------------------------------
29 before(async function () {
32 server = await flushAndRunServer(1)
34 await setAccessTokensToServers([ server ])
38 password: 'my super password'
40 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
41 userAccessToken = await userLogin(server, user)
44 describe('When listing jobs', function () {
46 it('Should fail with a bad state', async function () {
47 await makeGetRequest({
49 token: server.accessToken,
54 it('Should fail with an incorrect job type', async function () {
55 await makeGetRequest({
57 token: server.accessToken,
65 it('Should fail with a bad start pagination', async function () {
66 await checkBadStartPagination(server.url, path, server.accessToken)
69 it('Should fail with a bad count pagination', async function () {
70 await checkBadCountPagination(server.url, path, server.accessToken)
73 it('Should fail with an incorrect sort', async function () {
74 await checkBadSortPagination(server.url, path, server.accessToken)
77 it('Should fail with a non authenticated user', async function () {
78 await makeGetRequest({
81 statusCodeExpected: 401
85 it('Should fail with a non admin user', async function () {
86 await makeGetRequest({
89 token: userAccessToken,
90 statusCodeExpected: 403
96 after(async function () {
97 await cleanupTests([ server ])