]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/check-params/jobs.ts
hls-plugin: destroy hls upon third err
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / jobs.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
5cd80545
C
2
3import 'mocha'
5cd80545 4
9639bd17 5import {
a1587156 6 cleanupTests,
9639bd17 7 createUser,
210feb6c 8 flushAndRunServer,
9639bd17 9 ServerInfo,
10 setAccessTokensToServers,
a1587156 11 userLogin
94565d52 12} from '../../../../shared/extra-utils'
9639bd17 13import {
14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
94565d52
C
17} from '../../../../shared/extra-utils/requests/check-api-params'
18import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
5cd80545
C
19
20describe('Test jobs API validators', function () {
94a5ff8a 21 const path = '/api/v1/jobs/failed'
5cd80545
C
22 let server: ServerInfo
23 let userAccessToken = ''
24
25 // ---------------------------------------------------------------
26
27 before(async function () {
28 this.timeout(120000)
29
210feb6c 30 server = await flushAndRunServer(1)
5cd80545
C
31
32 await setAccessTokensToServers([ server ])
33
34 const user = {
35 username: 'user1',
36 password: 'my super password'
37 }
1eddc9a7 38 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
eec63bbc 39 userAccessToken = await userLogin(server, user)
5cd80545
C
40 })
41
42 describe('When listing jobs', function () {
94a5ff8a
C
43
44 it('Should fail with a bad state', async function () {
45 await makeGetRequest({
46 url: server.url,
47 token: server.accessToken,
48 path: path + 'ade'
49 })
50 })
51
1061c73f
C
52 it('Should fail with an incorrect job type', async function () {
53 await makeGetRequest({
54 url: server.url,
55 token: server.accessToken,
56 path,
57 query: {
58 jobType: 'toto'
59 }
60 })
61 })
62
5cd80545 63 it('Should fail with a bad start pagination', async function () {
93e4a311 64 await checkBadStartPagination(server.url, path, server.accessToken)
5cd80545
C
65 })
66
67 it('Should fail with a bad count pagination', async function () {
93e4a311 68 await checkBadCountPagination(server.url, path, server.accessToken)
5cd80545
C
69 })
70
71 it('Should fail with an incorrect sort', async function () {
93e4a311 72 await checkBadSortPagination(server.url, path, server.accessToken)
5cd80545
C
73 })
74
75 it('Should fail with a non authenticated user', async function () {
93e4a311
C
76 await makeGetRequest({
77 url: server.url,
78 path,
79 statusCodeExpected: 401
80 })
5cd80545
C
81 })
82
83 it('Should fail with a non admin user', async function () {
93e4a311
C
84 await makeGetRequest({
85 url: server.url,
86 path,
87 token: userAccessToken,
88 statusCodeExpected: 403
89 })
5cd80545 90 })
1061c73f 91
5cd80545
C
92 })
93
7c3b7976
C
94 after(async function () {
95 await cleanupTests([ server ])
5cd80545
C
96 })
97})