aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 14:40:11 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 14:40:11 +0100
commit93e4a311f37d7fc82ec81190553f8beae28fdef5 (patch)
treebced0a69b51d0bab35b01bfede629eef60ce3675 /server/tests/api/check-params
parenteec63bbc0f4fdb39e56f37127b35c449f90a135f (diff)
downloadPeerTube-93e4a311f37d7fc82ec81190553f8beae28fdef5.tar.gz
PeerTube-93e4a311f37d7fc82ec81190553f8beae28fdef5.tar.zst
PeerTube-93e4a311f37d7fc82ec81190553f8beae28fdef5.zip
Improve check jobs parameters tests
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/jobs.ts43
1 files changed, 16 insertions, 27 deletions
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index 3795d1d64..46b05cb4e 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -4,6 +4,8 @@ import 'mocha'
4import * as request from 'supertest' 4import * as request from 'supertest'
5 5
6import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' 6import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils'
7import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
8import { makeGetRequest } from '../../utils/requests/requests'
7 9
8describe('Test jobs API validators', function () { 10describe('Test jobs API validators', function () {
9 const path = '/api/v1/jobs/' 11 const path = '/api/v1/jobs/'
@@ -31,45 +33,32 @@ describe('Test jobs API validators', function () {
31 33
32 describe('When listing jobs', function () { 34 describe('When listing jobs', function () {
33 it('Should fail with a bad start pagination', async function () { 35 it('Should fail with a bad start pagination', async function () {
34 await request(server.url) 36 await checkBadStartPagination(server.url, path, server.accessToken)
35 .get(path)
36 .query({ start: 'hello' })
37 .set('Accept', 'application/json')
38 .set('Authorization', 'Bearer ' + server.accessToken)
39 .expect(400)
40 }) 37 })
41 38
42 it('Should fail with a bad count pagination', async function () { 39 it('Should fail with a bad count pagination', async function () {
43 await request(server.url) 40 await checkBadCountPagination(server.url, path, server.accessToken)
44 .get(path)
45 .query({ count: 'hello' })
46 .set('Accept', 'application/json')
47 .set('Authorization', 'Bearer ' + server.accessToken)
48 .expect(400)
49 }) 41 })
50 42
51 it('Should fail with an incorrect sort', async function () { 43 it('Should fail with an incorrect sort', async function () {
52 await request(server.url) 44 await checkBadSortPagination(server.url, path, server.accessToken)
53 .get(path)
54 .query({ sort: 'hello' })
55 .set('Accept', 'application/json')
56 .set('Authorization', 'Bearer ' + server.accessToken)
57 .expect(400)
58 }) 45 })
59 46
60 it('Should fail with a non authenticated user', async function () { 47 it('Should fail with a non authenticated user', async function () {
61 await request(server.url) 48 await makeGetRequest({
62 .get(path) 49 url: server.url,
63 .set('Accept', 'application/json') 50 path,
64 .expect(401) 51 statusCodeExpected: 401
52 })
65 }) 53 })
66 54
67 it('Should fail with a non admin user', async function () { 55 it('Should fail with a non admin user', async function () {
68 await request(server.url) 56 await makeGetRequest({
69 .get(path) 57 url: server.url,
70 .set('Accept', 'application/json') 58 path,
71 .set('Authorization', 'Bearer ' + userAccessToken) 59 token: userAccessToken,
72 .expect(403) 60 statusCodeExpected: 403
61 })
73 }) 62 })
74 }) 63 })
75 64