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 a bad start pagination', async function () {
55 await checkBadStartPagination(server.url, path, server.accessToken)
58 it('Should fail with a bad count pagination', async function () {
59 await checkBadCountPagination(server.url, path, server.accessToken)
62 it('Should fail with an incorrect sort', async function () {
63 await checkBadSortPagination(server.url, path, server.accessToken)
66 it('Should fail with a non authenticated user', async function () {
67 await makeGetRequest({
70 statusCodeExpected: 401
74 it('Should fail with a non admin user', async function () {
75 await makeGetRequest({
78 token: userAccessToken,
79 statusCodeExpected: 403
84 after(async function () {
85 await cleanupTests([ server ])