]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/check-params/custom-pages.ts
Remove unnecessary logs
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / custom-pages.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import 'mocha'
4 import {
5 cleanupTests,
6 createSingleServer,
7 makeGetRequest,
8 makePutBodyRequest,
9 PeerTubeServer,
10 setAccessTokensToServers
11 } from '@shared/server-commands'
12 import { HttpStatusCode } from '@shared/models'
13
14 describe('Test custom pages validators', function () {
15 const path = '/api/v1/custom-pages/homepage/instance'
16
17 let server: PeerTubeServer
18 let userAccessToken: string
19
20 // ---------------------------------------------------------------
21
22 before(async function () {
23 this.timeout(120000)
24
25 server = await createSingleServer(1)
26 await setAccessTokensToServers([ server ])
27
28 const user = { username: 'user1', password: 'password' }
29 await server.users.create({ username: user.username, password: user.password })
30
31 userAccessToken = await server.login.getAccessToken(user)
32 })
33
34 describe('When updating instance homepage', function () {
35
36 it('Should fail with an unauthenticated user', async function () {
37 await makePutBodyRequest({
38 url: server.url,
39 path,
40 fields: { content: 'super content' },
41 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
42 })
43 })
44
45 it('Should fail with a non admin user', async function () {
46 await makePutBodyRequest({
47 url: server.url,
48 path,
49 token: userAccessToken,
50 fields: { content: 'super content' },
51 expectedStatus: HttpStatusCode.FORBIDDEN_403
52 })
53 })
54
55 it('Should succeed with the correct params', async function () {
56 await makePutBodyRequest({
57 url: server.url,
58 path,
59 token: server.accessToken,
60 fields: { content: 'super content' },
61 expectedStatus: HttpStatusCode.NO_CONTENT_204
62 })
63 })
64 })
65
66 describe('When getting instance homapage', function () {
67
68 it('Should succeed with the correct params', async function () {
69 await makeGetRequest({
70 url: server.url,
71 path,
72 expectedStatus: HttpStatusCode.OK_200
73 })
74 })
75 })
76
77 after(async function () {
78 await cleanupTests([ server ])
79 })
80 })