]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/check-params/custom-pages.ts
Remove unnecessary logs
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / custom-pages.ts
CommitLineData
2539932e
C
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
2539932e
C
4import {
5 cleanupTests,
254d3579 6 createSingleServer,
c0e8b12e
C
7 makeGetRequest,
8 makePutBodyRequest,
254d3579 9 PeerTubeServer,
41d1d075 10 setAccessTokensToServers
bf54587a 11} from '@shared/server-commands'
c0e8b12e 12import { HttpStatusCode } from '@shared/models'
2539932e
C
13
14describe('Test custom pages validators', function () {
15 const path = '/api/v1/custom-pages/homepage/instance'
16
254d3579 17 let server: PeerTubeServer
2539932e
C
18 let userAccessToken: string
19
20 // ---------------------------------------------------------------
21
22 before(async function () {
23 this.timeout(120000)
24
254d3579 25 server = await createSingleServer(1)
2539932e
C
26 await setAccessTokensToServers([ server ])
27
28 const user = { username: 'user1', password: 'password' }
89d241a7 29 await server.users.create({ username: user.username, password: user.password })
2539932e 30
89d241a7 31 userAccessToken = await server.login.getAccessToken(user)
2539932e
C
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' },
c0e8b12e 41 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
2539932e
C
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' },
c0e8b12e 51 expectedStatus: HttpStatusCode.FORBIDDEN_403
2539932e
C
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' },
c0e8b12e 61 expectedStatus: HttpStatusCode.NO_CONTENT_204
2539932e
C
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,
c0e8b12e 72 expectedStatus: HttpStatusCode.OK_200
2539932e
C
73 })
74 })
75 })
76
77 after(async function () {
78 await cleanupTests([ server ])
79 })
80})