diff options
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/jobs.ts | 43 |
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' | |||
4 | import * as request from 'supertest' | 4 | import * as request from 'supertest' |
5 | 5 | ||
6 | import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' | 6 | import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' |
7 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | ||
8 | import { makeGetRequest } from '../../utils/requests/requests' | ||
7 | 9 | ||
8 | describe('Test jobs API validators', function () { | 10 | describe('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 | ||