1 /* tslint:disable:no-unused-expression */
11 setAccessTokensToServers,
13 } from '../../../../shared/extra-utils'
15 checkBadCountPagination,
16 checkBadSortPagination,
17 checkBadStartPagination
18 } from '../../../../shared/extra-utils/requests/check-api-params'
19 import { makeGetRequest } from '../../../../shared/extra-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 () {
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 a bad start pagination', async function () {
54 await checkBadStartPagination(server.url, path, server.accessToken)
57 it('Should fail with a bad count pagination', async function () {
58 await checkBadCountPagination(server.url, path, server.accessToken)
61 it('Should fail with an incorrect sort', async function () {
62 await checkBadSortPagination(server.url, path, server.accessToken)
65 it('Should fail with a non authenticated user', async function () {
66 await makeGetRequest({
69 statusCodeExpected: 401
73 it('Should fail with a non admin user', async function () {
74 await makeGetRequest({
77 token: userAccessToken,
78 statusCodeExpected: 403
84 killallServers([ server ])