aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/services.ts67
1 files changed, 66 insertions, 1 deletions
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index e63f09884..5d1713e03 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -1,6 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode, VideoCreateResult, VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
4import { 5import {
5 cleanupTests, 6 cleanupTests,
6 createSingleServer, 7 createSingleServer,
@@ -9,12 +10,17 @@ import {
9 setAccessTokensToServers, 10 setAccessTokensToServers,
10 setDefaultVideoChannel 11 setDefaultVideoChannel
11} from '@shared/server-commands' 12} from '@shared/server-commands'
12import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
13 13
14describe('Test services API validators', function () { 14describe('Test services API validators', function () {
15 let server: PeerTubeServer 15 let server: PeerTubeServer
16 let playlistUUID: string 16 let playlistUUID: string
17 17
18 let privateVideo: VideoCreateResult
19 let unlistedVideo: VideoCreateResult
20
21 let privatePlaylist: VideoPlaylistCreateResult
22 let unlistedPlaylist: VideoPlaylistCreateResult
23
18 // --------------------------------------------------------------- 24 // ---------------------------------------------------------------
19 25
20 before(async function () { 26 before(async function () {
@@ -26,6 +32,9 @@ describe('Test services API validators', function () {
26 32
27 server.store.videoCreated = await server.videos.upload({ attributes: { name: 'my super name' } }) 33 server.store.videoCreated = await server.videos.upload({ attributes: { name: 'my super name' } })
28 34
35 privateVideo = await server.videos.quickUpload({ name: 'private', privacy: VideoPrivacy.PRIVATE })
36 unlistedVideo = await server.videos.quickUpload({ name: 'unlisted', privacy: VideoPrivacy.UNLISTED })
37
29 { 38 {
30 const created = await server.playlists.create({ 39 const created = await server.playlists.create({
31 attributes: { 40 attributes: {
@@ -36,6 +45,22 @@ describe('Test services API validators', function () {
36 }) 45 })
37 46
38 playlistUUID = created.uuid 47 playlistUUID = created.uuid
48
49 privatePlaylist = await server.playlists.create({
50 attributes: {
51 displayName: 'private',
52 privacy: VideoPlaylistPrivacy.PRIVATE,
53 videoChannelId: server.store.channel.id
54 }
55 })
56
57 unlistedPlaylist = await server.playlists.create({
58 attributes: {
59 displayName: 'unlisted',
60 privacy: VideoPlaylistPrivacy.UNLISTED,
61 videoChannelId: server.store.channel.id
62 }
63 })
39 } 64 }
40 }) 65 })
41 66
@@ -91,6 +116,46 @@ describe('Test services API validators', function () {
91 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' }) 116 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' })
92 }) 117 })
93 118
119 it('Should fail with a private video', async function () {
120 const embedUrl = `http://localhost:${server.port}/videos/watch/${privateVideo.uuid}`
121
122 await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403)
123 })
124
125 it('Should fail with an unlisted video with the int id', async function () {
126 const embedUrl = `http://localhost:${server.port}/videos/watch/${unlistedVideo.id}`
127
128 await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403)
129 })
130
131 it('Should succeed with an unlisted video using the uuid id', async function () {
132 for (const uuid of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) {
133 const embedUrl = `http://localhost:${server.port}/videos/watch/${uuid}`
134
135 await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200)
136 }
137 })
138
139 it('Should fail with a private playlist', async function () {
140 const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${privatePlaylist.uuid}`
141
142 await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403)
143 })
144
145 it('Should fail with an unlisted playlist using the int id', async function () {
146 const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${unlistedPlaylist.id}`
147
148 await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403)
149 })
150
151 it('Should succeed with an unlisted playlist using the uuid id', async function () {
152 for (const uuid of [ unlistedPlaylist.uuid, unlistedPlaylist.shortUUID ]) {
153 const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${uuid}`
154
155 await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200)
156 }
157 })
158
94 it('Should succeed with the correct params with a video', async function () { 159 it('Should succeed with the correct params with a video', async function () {
95 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}` 160 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}`
96 const query = { 161 const query = {