1 /* tslint:disable:no-unused-expression */
5 import { createUser, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, userLogin } from '../../utils'
6 import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
7 import { makeGetRequest } from '../../utils/requests/requests'
9 describe('Test jobs API validators', function () {
10 const path = '/api/v1/jobs/failed'
11 let server: ServerInfo
12 let userAccessToken = ''
14 // ---------------------------------------------------------------
16 before(async function () {
21 server = await runServer(1)
23 await setAccessTokensToServers([ server ])
27 password: 'my super password'
29 await createUser(server.url, server.accessToken, user.username, user.password)
30 userAccessToken = await userLogin(server, user)
33 describe('When listing jobs', function () {
35 it('Should fail with a bad state', async function () {
36 await makeGetRequest({
38 token: server.accessToken,
43 it('Should fail with a bad start pagination', async function () {
44 await checkBadStartPagination(server.url, path, server.accessToken)
47 it('Should fail with a bad count pagination', async function () {
48 await checkBadCountPagination(server.url, path, server.accessToken)
51 it('Should fail with an incorrect sort', async function () {
52 await checkBadSortPagination(server.url, path, server.accessToken)
55 it('Should fail with a non authenticated user', async function () {
56 await makeGetRequest({
59 statusCodeExpected: 401
63 it('Should fail with a non admin user', async function () {
64 await makeGetRequest({
67 token: userAccessToken,
68 statusCodeExpected: 403
73 after(async function () {
74 killallServers([ server ])
76 // Keep the logs if the test failed