aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/jobs.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-30 10:51:13 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-30 10:55:06 +0100
commit5cd80545422bba855cc9a730a2e13cc9d982c34b (patch)
tree9a60cd7c9218c296a1460938d11e3bce784f7cc0 /server/tests/api/check-params/jobs.ts
parent1f3e9feca2caf68024168b0ea9ed39d8438fa235 (diff)
downloadPeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.gz
PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.zst
PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.zip
Add ability to list jobs
Diffstat (limited to 'server/tests/api/check-params/jobs.ts')
-rw-r--r--server/tests/api/check-params/jobs.ts84
1 files changed, 84 insertions, 0 deletions
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
new file mode 100644
index 000000000..7a0dd6e8c
--- /dev/null
+++ b/server/tests/api/check-params/jobs.ts
@@ -0,0 +1,84 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as request from 'supertest'
5
6import { createUser, flushTests, getUserAccessToken, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils'
7
8describe('Test jobs API validators', function () {
9 const path = '/api/v1/jobs/'
10 let server: ServerInfo
11 let userAccessToken = ''
12
13 // ---------------------------------------------------------------
14
15 before(async function () {
16 this.timeout(120000)
17
18 await flushTests()
19
20 server = await runServer(1)
21
22 await setAccessTokensToServers([ server ])
23
24 const user = {
25 username: 'user1',
26 password: 'my super password'
27 }
28 await createUser(server.url, server.accessToken, user.username, user.password)
29 userAccessToken = await getUserAccessToken(server, user)
30 })
31
32 describe('When listing jobs', function () {
33 it('Should fail with a bad start pagination', async function () {
34 await request(server.url)
35 .get(path)
36 .query({ start: 'hello' })
37 .set('Accept', 'application/json')
38 .set('Authorization', 'Bearer ' + server.accessToken)
39 .expect(400)
40 })
41
42 it('Should fail with a bad count pagination', async function () {
43 await request(server.url)
44 .get(path)
45 .query({ count: 'hello' })
46 .set('Accept', 'application/json')
47 .set('Authorization', 'Bearer ' + server.accessToken)
48 .expect(400)
49 })
50
51 it('Should fail with an incorrect sort', async function () {
52 await request(server.url)
53 .get(path)
54 .query({ sort: 'hello' })
55 .set('Accept', 'application/json')
56 .set('Authorization', 'Bearer ' + server.accessToken)
57 .expect(400)
58 })
59
60 it('Should fail with a non authenticated user', async function () {
61 await request(server.url)
62 .get(path)
63 .set('Accept', 'application/json')
64 .expect(401)
65 })
66
67 it('Should fail with a non admin user', async function () {
68 await request(server.url)
69 .get(path)
70 .set('Accept', 'application/json')
71 .set('Authorization', 'Bearer ' + userAccessToken)
72 .expect(403)
73 })
74 })
75
76 after(async function () {
77 killallServers([ server ])
78
79 // Keep the logs if the test failed
80 if (this['ok']) {
81 await flushTests()
82 }
83 })
84})