]>
Commit | Line | Data |
---|---|---|
5d79474c C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
4 | ||
5 | import { | |
6 | createUser, | |
7 | flushTests, | |
8 | killallServers, | |
210feb6c | 9 | flushAndRunServer, |
5d79474c C |
10 | ServerInfo, |
11 | setAccessTokensToServers, | |
7c3b7976 | 12 | userLogin, cleanupTests |
94565d52 C |
13 | } from '../../../../shared/extra-utils' |
14 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' | |
5d79474c C |
15 | |
16 | describe('Test debug API validators', function () { | |
17 | const path = '/api/v1/server/debug' | |
18 | let server: ServerInfo | |
19 | let userAccessToken = '' | |
20 | ||
21 | // --------------------------------------------------------------- | |
22 | ||
23 | before(async function () { | |
24 | this.timeout(120000) | |
25 | ||
210feb6c | 26 | server = await flushAndRunServer(1) |
5d79474c C |
27 | |
28 | await setAccessTokensToServers([ server ]) | |
29 | ||
30 | const user = { | |
31 | username: 'user1', | |
32 | password: 'my super password' | |
33 | } | |
1eddc9a7 | 34 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
5d79474c C |
35 | userAccessToken = await userLogin(server, user) |
36 | }) | |
37 | ||
38 | describe('When getting debug endpoint', function () { | |
39 | ||
40 | it('Should fail with a non authenticated user', async function () { | |
41 | await makeGetRequest({ | |
42 | url: server.url, | |
43 | path, | |
44 | statusCodeExpected: 401 | |
45 | }) | |
46 | }) | |
47 | ||
48 | it('Should fail with a non admin user', async function () { | |
49 | await makeGetRequest({ | |
50 | url: server.url, | |
51 | path, | |
52 | token: userAccessToken, | |
53 | statusCodeExpected: 403 | |
54 | }) | |
55 | }) | |
56 | ||
57 | it('Should succeed with the correct params', async function () { | |
58 | await makeGetRequest({ | |
59 | url: server.url, | |
60 | path, | |
61 | token: server.accessToken, | |
62 | query: { startDate: new Date().toISOString() }, | |
63 | statusCodeExpected: 200 | |
64 | }) | |
65 | }) | |
66 | }) | |
67 | ||
7c3b7976 C |
68 | after(async function () { |
69 | await cleanupTests([ server ]) | |
5d79474c C |
70 | }) |
71 | }) |