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