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