]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/check-params/jobs.ts
Add new follow, mention and user registered notifs
[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,
9 runServer,
10 ServerInfo,
11 setAccessTokensToServers,
12 userLogin
13} from '../../../../shared/utils'
14import {
15 checkBadCountPagination,
16 checkBadSortPagination,
17 checkBadStartPagination
18} from '../../../../shared/utils/requests/check-api-params'
19import { makeGetRequest } from '../../../../shared/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
31 await flushTests()
32
33 server = await runServer(1)
34
35 await setAccessTokensToServers([ server ])
36
37 const user = {
38 username: 'user1',
39 password: 'my super password'
40 }
41 await createUser(server.url, server.accessToken, user.username, user.password)
eec63bbc 42 userAccessToken = await userLogin(server, user)
5cd80545
C
43 })
44
45 describe('When listing jobs', function () {
94a5ff8a
C
46
47 it('Should fail with a bad state', async function () {
48 await makeGetRequest({
49 url: server.url,
50 token: server.accessToken,
51 path: path + 'ade'
52 })
53 })
54
5cd80545 55 it('Should fail with a bad start pagination', async function () {
93e4a311 56 await checkBadStartPagination(server.url, path, server.accessToken)
5cd80545
C
57 })
58
59 it('Should fail with a bad count pagination', async function () {
93e4a311 60 await checkBadCountPagination(server.url, path, server.accessToken)
5cd80545
C
61 })
62
63 it('Should fail with an incorrect sort', async function () {
93e4a311 64 await checkBadSortPagination(server.url, path, server.accessToken)
5cd80545
C
65 })
66
67 it('Should fail with a non authenticated user', async function () {
93e4a311
C
68 await makeGetRequest({
69 url: server.url,
70 path,
71 statusCodeExpected: 401
72 })
5cd80545
C
73 })
74
75 it('Should fail with a non admin user', async function () {
93e4a311
C
76 await makeGetRequest({
77 url: server.url,
78 path,
79 token: userAccessToken,
80 statusCodeExpected: 403
81 })
5cd80545
C
82 })
83 })
84
85 after(async function () {
86 killallServers([ server ])
87
88 // Keep the logs if the test failed
89 if (this['ok']) {
90 await flushTests()
91 }
92 })
93})