aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-blacklist.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-22 14:28:03 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-07-26 11:29:31 +0200
commit83903cb65d531a6b6b91715387493ba8312b264d (patch)
treefd172e26a483331e74f15a062743a9d40d4016d3 /server/tests/api/check-params/video-blacklist.ts
parentc4fa01f7c45b66b112ebd08abce744b7c4041feb (diff)
downloadPeerTube-83903cb65d531a6b6b91715387493ba8312b264d.tar.gz
PeerTube-83903cb65d531a6b6b91715387493ba8312b264d.tar.zst
PeerTube-83903cb65d531a6b6b91715387493ba8312b264d.zip
Generate random uuid for video files
Diffstat (limited to 'server/tests/api/check-params/video-blacklist.ts')
-rw-r--r--server/tests/api/check-params/video-blacklist.ts42
1 files changed, 25 insertions, 17 deletions
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index d28c6a952..1f926d227 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -51,7 +51,7 @@ describe('Test video blacklist API validators', function () {
51 } 51 }
52 52
53 { 53 {
54 servers[0].store.video = await servers[0].videos.upload({ token: userAccessToken1 }) 54 servers[0].store.videoCreated = await servers[0].videos.upload({ token: userAccessToken1 })
55 } 55 }
56 56
57 { 57 {
@@ -73,7 +73,7 @@ describe('Test video blacklist API validators', function () {
73 const basePath = '/api/v1/videos/' 73 const basePath = '/api/v1/videos/'
74 74
75 it('Should fail with nothing', async function () { 75 it('Should fail with nothing', async function () {
76 const path = basePath + servers[0].store.video + '/blacklist' 76 const path = basePath + servers[0].store.videoCreated + '/blacklist'
77 const fields = {} 77 const fields = {}
78 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 78 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
79 }) 79 })
@@ -85,13 +85,13 @@ describe('Test video blacklist API validators', function () {
85 }) 85 })
86 86
87 it('Should fail with a non authenticated user', async function () { 87 it('Should fail with a non authenticated user', async function () {
88 const path = basePath + servers[0].store.video + '/blacklist' 88 const path = basePath + servers[0].store.videoCreated + '/blacklist'
89 const fields = {} 89 const fields = {}
90 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 90 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
91 }) 91 })
92 92
93 it('Should fail with a non admin user', async function () { 93 it('Should fail with a non admin user', async function () {
94 const path = basePath + servers[0].store.video + '/blacklist' 94 const path = basePath + servers[0].store.videoCreated + '/blacklist'
95 const fields = {} 95 const fields = {}
96 await makePostBodyRequest({ 96 await makePostBodyRequest({
97 url: servers[0].url, 97 url: servers[0].url,
@@ -103,7 +103,7 @@ describe('Test video blacklist API validators', function () {
103 }) 103 })
104 104
105 it('Should fail with an invalid reason', async function () { 105 it('Should fail with an invalid reason', async function () {
106 const path = basePath + servers[0].store.video.uuid + '/blacklist' 106 const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'
107 const fields = { reason: 'a'.repeat(305) } 107 const fields = { reason: 'a'.repeat(305) }
108 108
109 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 109 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
@@ -123,7 +123,7 @@ describe('Test video blacklist API validators', function () {
123 }) 123 })
124 124
125 it('Should succeed with the correct params', async function () { 125 it('Should succeed with the correct params', async function () {
126 const path = basePath + servers[0].store.video.uuid + '/blacklist' 126 const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'
127 const fields = {} 127 const fields = {}
128 128
129 await makePostBodyRequest({ 129 await makePostBodyRequest({
@@ -158,13 +158,13 @@ describe('Test video blacklist API validators', function () {
158 }) 158 })
159 159
160 it('Should fail with a non authenticated user', async function () { 160 it('Should fail with a non authenticated user', async function () {
161 const path = basePath + servers[0].store.video + '/blacklist' 161 const path = basePath + servers[0].store.videoCreated + '/blacklist'
162 const fields = {} 162 const fields = {}
163 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 163 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
164 }) 164 })
165 165
166 it('Should fail with a non admin user', async function () { 166 it('Should fail with a non admin user', async function () {
167 const path = basePath + servers[0].store.video + '/blacklist' 167 const path = basePath + servers[0].store.videoCreated + '/blacklist'
168 const fields = {} 168 const fields = {}
169 await makePutBodyRequest({ 169 await makePutBodyRequest({
170 url: servers[0].url, 170 url: servers[0].url,
@@ -176,14 +176,14 @@ describe('Test video blacklist API validators', function () {
176 }) 176 })
177 177
178 it('Should fail with an invalid reason', async function () { 178 it('Should fail with an invalid reason', async function () {
179 const path = basePath + servers[0].store.video.uuid + '/blacklist' 179 const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'
180 const fields = { reason: 'a'.repeat(305) } 180 const fields = { reason: 'a'.repeat(305) }
181 181
182 await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 182 await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
183 }) 183 })
184 184
185 it('Should succeed with the correct params', async function () { 185 it('Should succeed with the correct params', async function () {
186 const path = basePath + servers[0].store.video.shortUUID + '/blacklist' 186 const path = basePath + servers[0].store.videoCreated.shortUUID + '/blacklist'
187 const fields = { reason: 'hello' } 187 const fields = { reason: 'hello' }
188 188
189 await makePutBodyRequest({ 189 await makePutBodyRequest({
@@ -199,24 +199,24 @@ describe('Test video blacklist API validators', function () {
199 describe('When getting blacklisted video', function () { 199 describe('When getting blacklisted video', function () {
200 200
201 it('Should fail with a non authenticated user', async function () { 201 it('Should fail with a non authenticated user', async function () {
202 await servers[0].videos.get({ id: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 202 await servers[0].videos.get({ id: servers[0].store.videoCreated.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
203 }) 203 })
204 204
205 it('Should fail with another user', async function () { 205 it('Should fail with another user', async function () {
206 await servers[0].videos.getWithToken({ 206 await servers[0].videos.getWithToken({
207 token: userAccessToken2, 207 token: userAccessToken2,
208 id: servers[0].store.video.uuid, 208 id: servers[0].store.videoCreated.uuid,
209 expectedStatus: HttpStatusCode.FORBIDDEN_403 209 expectedStatus: HttpStatusCode.FORBIDDEN_403
210 }) 210 })
211 }) 211 })
212 212
213 it('Should succeed with the owner authenticated user', async function () { 213 it('Should succeed with the owner authenticated user', async function () {
214 const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.video.uuid }) 214 const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.videoCreated.uuid })
215 expect(video.blacklisted).to.be.true 215 expect(video.blacklisted).to.be.true
216 }) 216 })
217 217
218 it('Should succeed with an admin', async function () { 218 it('Should succeed with an admin', async function () {
219 const video = servers[0].store.video 219 const video = servers[0].store.videoCreated
220 220
221 for (const id of [ video.id, video.uuid, video.shortUUID ]) { 221 for (const id of [ video.id, video.uuid, video.shortUUID ]) {
222 const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 }) 222 const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
@@ -228,11 +228,19 @@ describe('Test video blacklist API validators', function () {
228 describe('When removing a video in blacklist', function () { 228 describe('When removing a video in blacklist', function () {
229 229
230 it('Should fail with a non authenticated user', async function () { 230 it('Should fail with a non authenticated user', async function () {
231 await command.remove({ token: 'fake token', videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 231 await command.remove({
232 token: 'fake token',
233 videoId: servers[0].store.videoCreated.uuid,
234 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
235 })
232 }) 236 })
233 237
234 it('Should fail with a non admin user', async function () { 238 it('Should fail with a non admin user', async function () {
235 await command.remove({ token: userAccessToken2, videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 239 await command.remove({
240 token: userAccessToken2,
241 videoId: servers[0].store.videoCreated.uuid,
242 expectedStatus: HttpStatusCode.FORBIDDEN_403
243 })
236 }) 244 })
237 245
238 it('Should fail with an incorrect id', async function () { 246 it('Should fail with an incorrect id', async function () {
@@ -245,7 +253,7 @@ describe('Test video blacklist API validators', function () {
245 }) 253 })
246 254
247 it('Should succeed with the correct params', async function () { 255 it('Should succeed with the correct params', async function () {
248 await command.remove({ videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) 256 await command.remove({ videoId: servers[0].store.videoCreated.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
249 }) 257 })
250 }) 258 })
251 259