1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { HttpStatusCode, VideoPrivacy } from '@shared/models'
4 import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
6 describe('Test video tokens', function () {
7 let server: PeerTubeServer
11 // ---------------------------------------------------------------
13 before(async function () {
16 server = await createSingleServer(1)
17 await setAccessTokensToServers([ server ])
19 const { uuid } = await server.videos.quickUpload({ name: 'video', privacy: VideoPrivacy.PRIVATE })
22 userToken = await server.users.generateUserAndToken('user1')
25 it('Should not generate tokens for unauthenticated user', async function () {
26 await server.videoToken.create({ videoId, token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
29 it('Should not generate tokens of unknown video', async function () {
30 await server.videoToken.create({ videoId: 404, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
33 it('Should not generate tokens of a non owned video', async function () {
34 await server.videoToken.create({ videoId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
37 it('Should generate token', async function () {
38 await server.videoToken.create({ videoId })
41 after(async function () {
42 await cleanupTests([ server ])