]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/check-params/debug.ts
Adapt CLI to new commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / debug.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
5d79474c
C
2
3import 'mocha'
4
5import {
a1587156 6 cleanupTests,
5d79474c 7 createUser,
210feb6c 8 flushAndRunServer,
5d79474c 9 ServerInfo,
41d1d075 10 setAccessTokensToServers
94565d52
C
11} from '../../../../shared/extra-utils'
12import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
2d53be02 13import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5d79474c
C
14
15describe('Test debug API validators', function () {
16 const path = '/api/v1/server/debug'
17 let server: ServerInfo
18 let userAccessToken = ''
19
20 // ---------------------------------------------------------------
21
22 before(async function () {
23 this.timeout(120000)
24
210feb6c 25 server = await flushAndRunServer(1)
5d79474c
C
26
27 await setAccessTokensToServers([ server ])
28
29 const user = {
30 username: 'user1',
31 password: 'my super password'
32 }
1eddc9a7 33 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
41d1d075 34 userAccessToken = await server.loginCommand.getAccessToken(user)
5d79474c
C
35 })
36
37 describe('When getting debug endpoint', function () {
38
39 it('Should fail with a non authenticated user', async function () {
40 await makeGetRequest({
41 url: server.url,
42 path,
2d53be02 43 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
5d79474c
C
44 })
45 })
46
47 it('Should fail with a non admin user', async function () {
48 await makeGetRequest({
49 url: server.url,
50 path,
51 token: userAccessToken,
2d53be02 52 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
5d79474c
C
53 })
54 })
55
56 it('Should succeed with the correct params', async function () {
57 await makeGetRequest({
58 url: server.url,
59 path,
60 token: server.accessToken,
61 query: { startDate: new Date().toISOString() },
2d53be02 62 statusCodeExpected: HttpStatusCode.OK_200
5d79474c
C
63 })
64 })
65 })
66
7c3b7976
C
67 after(async function () {
68 await cleanupTests([ server ])
5d79474c
C
69 })
70})