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