aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/tests/api/check-params/video-blacklist.ts47
-rw-r--r--server/tests/api/live/live-save-replay.ts5
-rw-r--r--server/tests/api/live/live.ts3
-rw-r--r--server/tests/api/moderation/video-blacklist.ts144
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts12
-rw-r--r--server/tests/api/server/email.ts6
-rw-r--r--server/tests/api/users/users.ts3
-rw-r--r--server/tests/api/videos/video-playlists.ts6
-rw-r--r--server/tests/external-plugins/auto-block-videos.ts11
9 files changed, 92 insertions, 145 deletions
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index ce7f5fa17..98cf2e11a 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -1,32 +1,28 @@
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'
4 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
5import { 6import {
7 BlacklistCommand,
8 checkBadCountPagination,
9 checkBadSortPagination,
10 checkBadStartPagination,
6 cleanupTests, 11 cleanupTests,
7 createUser, 12 createUser,
8 doubleFollow, 13 doubleFollow,
9 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
10 getBlacklistedVideosList,
11 getVideo, 15 getVideo,
12 getVideoWithToken, 16 getVideoWithToken,
13 makePostBodyRequest, 17 makePostBodyRequest,
14 makePutBodyRequest, 18 makePutBodyRequest,
15 removeVideoFromBlacklist,
16 ServerInfo, 19 ServerInfo,
17 setAccessTokensToServers, 20 setAccessTokensToServers,
18 uploadVideo, 21 uploadVideo,
19 userLogin, 22 userLogin,
20 waitJobs 23 waitJobs
21} from '../../../../shared/extra-utils' 24} from '@shared/extra-utils'
22import { 25import { VideoBlacklistType, VideoDetails } from '@shared/models'
23 checkBadCountPagination,
24 checkBadSortPagination,
25 checkBadStartPagination
26} from '../../../../shared/extra-utils/requests/check-api-params'
27import { VideoBlacklistType, VideoDetails } from '../../../../shared/models/videos'
28import { expect } from 'chai'
29import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
30 26
31describe('Test video blacklist API validators', function () { 27describe('Test video blacklist API validators', function () {
32 let servers: ServerInfo[] 28 let servers: ServerInfo[]
@@ -34,6 +30,7 @@ describe('Test video blacklist API validators', function () {
34 let remoteVideoUUID: string 30 let remoteVideoUUID: string
35 let userAccessToken1 = '' 31 let userAccessToken1 = ''
36 let userAccessToken2 = '' 32 let userAccessToken2 = ''
33 let command: BlacklistCommand
37 34
38 // --------------------------------------------------------------- 35 // ---------------------------------------------------------------
39 36
@@ -75,6 +72,8 @@ describe('Test video blacklist API validators', function () {
75 } 72 }
76 73
77 await waitJobs(servers) 74 await waitJobs(servers)
75
76 command = servers[0].blacklistCommand
78 }) 77 })
79 78
80 describe('When adding a video in blacklist', function () { 79 describe('When adding a video in blacklist', function () {
@@ -234,25 +233,26 @@ describe('Test video blacklist API validators', function () {
234 }) 233 })
235 234
236 describe('When removing a video in blacklist', function () { 235 describe('When removing a video in blacklist', function () {
236
237 it('Should fail with a non authenticated user', async function () { 237 it('Should fail with a non authenticated user', async function () {
238 await removeVideoFromBlacklist(servers[0].url, 'fake token', servers[0].video.uuid, HttpStatusCode.UNAUTHORIZED_401) 238 await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
239 }) 239 })
240 240
241 it('Should fail with a non admin user', async function () { 241 it('Should fail with a non admin user', async function () {
242 await removeVideoFromBlacklist(servers[0].url, userAccessToken2, servers[0].video.uuid, HttpStatusCode.FORBIDDEN_403) 242 await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
243 }) 243 })
244 244
245 it('Should fail with an incorrect id', async function () { 245 it('Should fail with an incorrect id', async function () {
246 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400) 246 await command.remove({ videoId: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
247 }) 247 })
248 248
249 it('Should fail with a not blacklisted video', async function () { 249 it('Should fail with a not blacklisted video', async function () {
250 // The video was not added to the blacklist so it should fail 250 // The video was not added to the blacklist so it should fail
251 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, notBlacklistedVideoId, HttpStatusCode.NOT_FOUND_404) 251 await command.remove({ videoId: notBlacklistedVideoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
252 }) 252 })
253 253
254 it('Should succeed with the correct params', async function () { 254 it('Should succeed with the correct params', async function () {
255 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, servers[0].video.uuid, HttpStatusCode.NO_CONTENT_204) 255 await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
256 }) 256 })
257 }) 257 })
258 258
@@ -260,11 +260,11 @@ describe('Test video blacklist API validators', function () {
260 const basePath = '/api/v1/videos/blacklist/' 260 const basePath = '/api/v1/videos/blacklist/'
261 261
262 it('Should fail with a non authenticated user', async function () { 262 it('Should fail with a non authenticated user', async function () {
263 await getBlacklistedVideosList({ url: servers[0].url, token: 'fake token', specialStatus: HttpStatusCode.UNAUTHORIZED_401 }) 263 await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
264 }) 264 })
265 265
266 it('Should fail with a non admin user', async function () { 266 it('Should fail with a non admin user', async function () {
267 await getBlacklistedVideosList({ url: servers[0].url, token: userAccessToken2, specialStatus: HttpStatusCode.FORBIDDEN_403 }) 267 await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
268 }) 268 })
269 269
270 it('Should fail with a bad start pagination', async function () { 270 it('Should fail with a bad start pagination', async function () {
@@ -280,16 +280,11 @@ describe('Test video blacklist API validators', function () {
280 }) 280 })
281 281
282 it('Should fail with an invalid type', async function () { 282 it('Should fail with an invalid type', async function () {
283 await getBlacklistedVideosList({ 283 await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
284 url: servers[0].url,
285 token: servers[0].accessToken,
286 type: 0,
287 specialStatus: HttpStatusCode.BAD_REQUEST_400
288 })
289 }) 284 })
290 285
291 it('Should succeed with the correct parameters', async function () { 286 it('Should succeed with the correct parameters', async function () {
292 await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlacklistType.MANUAL }) 287 await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL })
293 }) 288 })
294 }) 289 })
295 290
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 9acd5601d..363fb561c 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -6,7 +6,6 @@ import { FfmpegCommand } from 'fluent-ffmpeg'
6import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' 6import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
7import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 7import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
8import { 8import {
9 addVideoToBlacklist,
10 checkLiveCleanup, 9 checkLiveCleanup,
11 cleanupTests, 10 cleanupTests,
12 ConfigCommand, 11 ConfigCommand,
@@ -172,7 +171,7 @@ describe('Save replay setting', function () {
172 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 171 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
173 172
174 await Promise.all([ 173 await Promise.all([
175 addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true), 174 servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
176 testFfmpegStreamError(ffmpegCommand, true) 175 testFfmpegStreamError(ffmpegCommand, true)
177 ]) 176 ])
178 177
@@ -280,7 +279,7 @@ describe('Save replay setting', function () {
280 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 279 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
281 280
282 await Promise.all([ 281 await Promise.all([
283 addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true), 282 servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
284 testFfmpegStreamError(ffmpegCommand, true) 283 testFfmpegStreamError(ffmpegCommand, true)
285 ]) 284 ])
286 285
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 5d70d8513..cb52e4431 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -7,7 +7,6 @@ import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-
7import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' 7import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
9import { 9import {
10 addVideoToBlacklist,
11 buildServerDirectory, 10 buildServerDirectory,
12 checkLiveCleanup, 11 checkLiveCleanup,
13 checkLiveSegmentHash, 12 checkLiveSegmentHash,
@@ -347,7 +346,7 @@ describe('Test live', function () {
347 346
348 liveVideo = await createLiveWrapper() 347 liveVideo = await createLiveWrapper()
349 348
350 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideo.uuid) 349 await servers[0].blacklistCommand.add({ videoId: liveVideo.uuid })
351 350
352 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 351 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
353 await testFfmpegStreamError(command, true) 352 await testFfmpegStreamError(command, true)
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts
index 4a4930c98..17a68e4a6 100644
--- a/server/tests/api/moderation/video-blacklist.ts
+++ b/server/tests/api/moderation/video-blacklist.ts
@@ -4,22 +4,19 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { orderBy } from 'lodash' 5import { orderBy } from 'lodash'
6import { 6import {
7 addVideoToBlacklist, 7 BlacklistCommand,
8 cleanupTests, 8 cleanupTests,
9 createUser, 9 createUser,
10 doubleFollow, 10 doubleFollow,
11 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
12 getBlacklistedVideosList,
13 getMyUserInformation, 12 getMyUserInformation,
14 getMyVideos, 13 getMyVideos,
15 getVideosList, 14 getVideosList,
16 killallServers, 15 killallServers,
17 removeVideoFromBlacklist,
18 reRunServer, 16 reRunServer,
19 ServerInfo, 17 ServerInfo,
20 setAccessTokensToServers, 18 setAccessTokensToServers,
21 updateVideo, 19 updateVideo,
22 updateVideoBlacklist,
23 uploadVideo, 20 uploadVideo,
24 userLogin, 21 userLogin,
25 waitJobs 22 waitJobs
@@ -32,13 +29,14 @@ const expect = chai.expect
32describe('Test video blacklist', function () { 29describe('Test video blacklist', function () {
33 let servers: ServerInfo[] = [] 30 let servers: ServerInfo[] = []
34 let videoId: number 31 let videoId: number
32 let command: BlacklistCommand
35 33
36 async function blacklistVideosOnServer (server: ServerInfo) { 34 async function blacklistVideosOnServer (server: ServerInfo) {
37 const res = await getVideosList(server.url) 35 const res = await getVideosList(server.url)
38 36
39 const videos = res.body.data 37 const videos = res.body.data
40 for (const video of videos) { 38 for (const video of videos) {
41 await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') 39 await server.blacklistCommand.add({ videoId: video.id, reason: 'super reason' })
42 } 40 }
43 } 41 }
44 42
@@ -61,6 +59,8 @@ describe('Test video blacklist', function () {
61 // Wait videos propagation, server 2 has transcoding enabled 59 // Wait videos propagation, server 2 has transcoding enabled
62 await waitJobs(servers) 60 await waitJobs(servers)
63 61
62 command = servers[0].blacklistCommand
63
64 // Blacklist the two videos on server 1 64 // Blacklist the two videos on server 1
65 await blacklistVideosOnServer(servers[0]) 65 await blacklistVideosOnServer(servers[0])
66 }) 66 })
@@ -77,7 +77,7 @@ describe('Test video blacklist', function () {
77 } 77 }
78 78
79 { 79 {
80 const body = await servers[0].searchCommand.searchVideos({ search: 'name' }) 80 const body = await servers[0].searchCommand.searchVideos({ search: 'video' })
81 81
82 expect(body.total).to.equal(0) 82 expect(body.total).to.equal(0)
83 expect(body.data).to.be.an('array') 83 expect(body.data).to.be.an('array')
@@ -95,7 +95,7 @@ describe('Test video blacklist', function () {
95 } 95 }
96 96
97 { 97 {
98 const body = await servers[1].searchCommand.searchVideos({ search: 'name' }) 98 const body = await servers[1].searchCommand.searchVideos({ search: 'video' })
99 99
100 expect(body.total).to.equal(2) 100 expect(body.total).to.equal(2)
101 expect(body.data).to.be.an('array') 101 expect(body.data).to.be.an('array')
@@ -106,11 +106,10 @@ describe('Test video blacklist', function () {
106 106
107 describe('When listing manually blacklisted videos', function () { 107 describe('When listing manually blacklisted videos', function () {
108 it('Should display all the blacklisted videos', async function () { 108 it('Should display all the blacklisted videos', async function () {
109 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken }) 109 const body = await command.list()
110 110 expect(body.total).to.equal(2)
111 expect(res.body.total).to.equal(2)
112 111
113 const blacklistedVideos = res.body.data 112 const blacklistedVideos = body.data
114 expect(blacklistedVideos).to.be.an('array') 113 expect(blacklistedVideos).to.be.an('array')
115 expect(blacklistedVideos.length).to.equal(2) 114 expect(blacklistedVideos.length).to.equal(2)
116 115
@@ -121,79 +120,66 @@ describe('Test video blacklist', function () {
121 }) 120 })
122 121
123 it('Should display all the blacklisted videos when applying manual type filter', async function () { 122 it('Should display all the blacklisted videos when applying manual type filter', async function () {
124 const res = await getBlacklistedVideosList({ 123 const body = await command.list({ type: VideoBlacklistType.MANUAL })
125 url: servers[0].url, 124 expect(body.total).to.equal(2)
126 token: servers[0].accessToken,
127 type: VideoBlacklistType.MANUAL
128 })
129 125
130 expect(res.body.total).to.equal(2) 126 const blacklistedVideos = body.data
131
132 const blacklistedVideos = res.body.data
133 expect(blacklistedVideos).to.be.an('array') 127 expect(blacklistedVideos).to.be.an('array')
134 expect(blacklistedVideos.length).to.equal(2) 128 expect(blacklistedVideos.length).to.equal(2)
135 }) 129 })
136 130
137 it('Should display nothing when applying automatic type filter', async function () { 131 it('Should display nothing when applying automatic type filter', async function () {
138 const res = await getBlacklistedVideosList({ 132 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
139 url: servers[0].url, 133 expect(body.total).to.equal(0)
140 token: servers[0].accessToken,
141 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
142 })
143 134
144 expect(res.body.total).to.equal(0) 135 const blacklistedVideos = body.data
145
146 const blacklistedVideos = res.body.data
147 expect(blacklistedVideos).to.be.an('array') 136 expect(blacklistedVideos).to.be.an('array')
148 expect(blacklistedVideos.length).to.equal(0) 137 expect(blacklistedVideos.length).to.equal(0)
149 }) 138 })
150 139
151 it('Should get the correct sort when sorting by descending id', async function () { 140 it('Should get the correct sort when sorting by descending id', async function () {
152 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-id' }) 141 const body = await command.list({ sort: '-id' })
153 expect(res.body.total).to.equal(2) 142 expect(body.total).to.equal(2)
154 143
155 const blacklistedVideos = res.body.data 144 const blacklistedVideos = body.data
156 expect(blacklistedVideos).to.be.an('array') 145 expect(blacklistedVideos).to.be.an('array')
157 expect(blacklistedVideos.length).to.equal(2) 146 expect(blacklistedVideos.length).to.equal(2)
158 147
159 const result = orderBy(res.body.data, [ 'id' ], [ 'desc' ]) 148 const result = orderBy(body.data, [ 'id' ], [ 'desc' ])
160
161 expect(blacklistedVideos).to.deep.equal(result) 149 expect(blacklistedVideos).to.deep.equal(result)
162 }) 150 })
163 151
164 it('Should get the correct sort when sorting by descending video name', async function () { 152 it('Should get the correct sort when sorting by descending video name', async function () {
165 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) 153 const body = await command.list({ sort: '-name' })
166 expect(res.body.total).to.equal(2) 154 expect(body.total).to.equal(2)
167 155
168 const blacklistedVideos = res.body.data 156 const blacklistedVideos = body.data
169 expect(blacklistedVideos).to.be.an('array') 157 expect(blacklistedVideos).to.be.an('array')
170 expect(blacklistedVideos.length).to.equal(2) 158 expect(blacklistedVideos.length).to.equal(2)
171 159
172 const result = orderBy(res.body.data, [ 'name' ], [ 'desc' ]) 160 const result = orderBy(body.data, [ 'name' ], [ 'desc' ])
173
174 expect(blacklistedVideos).to.deep.equal(result) 161 expect(blacklistedVideos).to.deep.equal(result)
175 }) 162 })
176 163
177 it('Should get the correct sort when sorting by ascending creation date', async function () { 164 it('Should get the correct sort when sorting by ascending creation date', async function () {
178 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) 165 const body = await command.list({ sort: 'createdAt' })
179 expect(res.body.total).to.equal(2) 166 expect(body.total).to.equal(2)
180 167
181 const blacklistedVideos = res.body.data 168 const blacklistedVideos = body.data
182 expect(blacklistedVideos).to.be.an('array') 169 expect(blacklistedVideos).to.be.an('array')
183 expect(blacklistedVideos.length).to.equal(2) 170 expect(blacklistedVideos.length).to.equal(2)
184 171
185 const result = orderBy(res.body.data, [ 'createdAt' ]) 172 const result = orderBy(body.data, [ 'createdAt' ])
186
187 expect(blacklistedVideos).to.deep.equal(result) 173 expect(blacklistedVideos).to.deep.equal(result)
188 }) 174 })
189 }) 175 })
190 176
191 describe('When updating blacklisted videos', function () { 177 describe('When updating blacklisted videos', function () {
192 it('Should change the reason', async function () { 178 it('Should change the reason', async function () {
193 await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') 179 await command.update({ videoId, reason: 'my super reason updated' })
194 180
195 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) 181 const body = await command.list({ sort: '-name' })
196 const video = res.body.data.find(b => b.video.id === videoId) 182 const video = body.data.find(b => b.video.id === videoId)
197 183
198 expect(video.reason).to.equal('my super reason updated') 184 expect(video.reason).to.equal('my super reason updated')
199 }) 185 })
@@ -228,12 +214,12 @@ describe('Test video blacklist', function () {
228 214
229 it('Should remove a video from the blacklist on server 1', async function () { 215 it('Should remove a video from the blacklist on server 1', async function () {
230 // Get one video in the blacklist 216 // Get one video in the blacklist
231 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) 217 const body = await command.list({ sort: '-name' })
232 videoToRemove = res.body.data[0] 218 videoToRemove = body.data[0]
233 blacklist = res.body.data.slice(1) 219 blacklist = body.data.slice(1)
234 220
235 // Remove it 221 // Remove it
236 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.video.id) 222 await command.remove({ videoId: videoToRemove.video.id })
237 }) 223 })
238 224
239 it('Should have the ex-blacklisted video in videos list on server 1', async function () { 225 it('Should have the ex-blacklisted video in videos list on server 1', async function () {
@@ -249,10 +235,10 @@ describe('Test video blacklist', function () {
249 }) 235 })
250 236
251 it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { 237 it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () {
252 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) 238 const body = await command.list({ sort: '-name' })
253 expect(res.body.total).to.equal(1) 239 expect(body.total).to.equal(1)
254 240
255 const videos = res.body.data 241 const videos = body.data
256 expect(videos).to.be.an('array') 242 expect(videos).to.be.an('array')
257 expect(videos.length).to.equal(1) 243 expect(videos.length).to.equal(1)
258 expect(videos).to.deep.equal(blacklist) 244 expect(videos).to.deep.equal(blacklist)
@@ -281,7 +267,7 @@ describe('Test video blacklist', function () {
281 it('Should blacklist video 3 and keep it federated', async function () { 267 it('Should blacklist video 3 and keep it federated', async function () {
282 this.timeout(10000) 268 this.timeout(10000)
283 269
284 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video3UUID, 'super reason', false) 270 await command.add({ videoId: video3UUID, reason: 'super reason', unfederate: false })
285 271
286 await waitJobs(servers) 272 await waitJobs(servers)
287 273
@@ -299,7 +285,7 @@ describe('Test video blacklist', function () {
299 it('Should unfederate the video', async function () { 285 it('Should unfederate the video', async function () {
300 this.timeout(10000) 286 this.timeout(10000)
301 287
302 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video4UUID, 'super reason', true) 288 await command.add({ videoId: video4UUID, reason: 'super reason', unfederate: true })
303 289
304 await waitJobs(servers) 290 await waitJobs(servers)
305 291
@@ -323,9 +309,9 @@ describe('Test video blacklist', function () {
323 }) 309 })
324 310
325 it('Should have the correct video blacklist unfederate attribute', async function () { 311 it('Should have the correct video blacklist unfederate attribute', async function () {
326 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) 312 const body = await command.list({ sort: 'createdAt' })
327 313
328 const blacklistedVideos: VideoBlacklist[] = res.body.data 314 const blacklistedVideos = body.data
329 const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) 315 const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID)
330 const video4Blacklisted = blacklistedVideos.find(b => b.video.uuid === video4UUID) 316 const video4Blacklisted = blacklistedVideos.find(b => b.video.uuid === video4UUID)
331 317
@@ -336,7 +322,7 @@ describe('Test video blacklist', function () {
336 it('Should remove the video from blacklist and refederate the video', async function () { 322 it('Should remove the video from blacklist and refederate the video', async function () {
337 this.timeout(10000) 323 this.timeout(10000)
338 324
339 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video4UUID) 325 await command.remove({ videoId: video4UUID })
340 326
341 await waitJobs(servers) 327 await waitJobs(servers)
342 328
@@ -407,14 +393,9 @@ describe('Test video blacklist', function () {
407 it('Should auto blacklist a video on upload', async function () { 393 it('Should auto blacklist a video on upload', async function () {
408 await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' }) 394 await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' })
409 395
410 const res = await getBlacklistedVideosList({ 396 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
411 url: servers[0].url, 397 expect(body.total).to.equal(1)
412 token: servers[0].accessToken, 398 expect(body.data[0].video.name).to.equal('blacklisted')
413 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
414 })
415
416 expect(res.body.total).to.equal(1)
417 expect(res.body.data[0].video.name).to.equal('blacklisted')
418 }) 399 })
419 400
420 it('Should auto blacklist a video on URL import', async function () { 401 it('Should auto blacklist a video on URL import', async function () {
@@ -427,15 +408,9 @@ describe('Test video blacklist', function () {
427 } 408 }
428 await importVideo(servers[0].url, userWithoutFlag, attributes) 409 await importVideo(servers[0].url, userWithoutFlag, attributes)
429 410
430 const res = await getBlacklistedVideosList({ 411 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
431 url: servers[0].url, 412 expect(body.total).to.equal(2)
432 token: servers[0].accessToken, 413 expect(body.data[1].video.name).to.equal('URL import')
433 sort: 'createdAt',
434 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
435 })
436
437 expect(res.body.total).to.equal(2)
438 expect(res.body.data[1].video.name).to.equal('URL import')
439 }) 414 })
440 415
441 it('Should auto blacklist a video on torrent import', async function () { 416 it('Should auto blacklist a video on torrent import', async function () {
@@ -446,27 +421,16 @@ describe('Test video blacklist', function () {
446 } 421 }
447 await importVideo(servers[0].url, userWithoutFlag, attributes) 422 await importVideo(servers[0].url, userWithoutFlag, attributes)
448 423
449 const res = await getBlacklistedVideosList({ 424 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
450 url: servers[0].url, 425 expect(body.total).to.equal(3)
451 token: servers[0].accessToken, 426 expect(body.data[2].video.name).to.equal('Torrent import')
452 sort: 'createdAt',
453 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
454 })
455
456 expect(res.body.total).to.equal(3)
457 expect(res.body.data[2].video.name).to.equal('Torrent import')
458 }) 427 })
459 428
460 it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () { 429 it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () {
461 await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' }) 430 await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' })
462 431
463 const res = await getBlacklistedVideosList({ 432 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
464 url: servers[0].url, 433 expect(body.total).to.equal(3)
465 token: servers[0].accessToken,
466 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
467 })
468
469 expect(res.body.total).to.equal(3)
470 }) 434 })
471 }) 435 })
472 436
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 605b41947..52ade0548 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -4,7 +4,6 @@ import 'mocha'
4import { buildUUID } from '@server/helpers/uuid' 4import { buildUUID } from '@server/helpers/uuid'
5import { 5import {
6 addVideoCommentThread, 6 addVideoCommentThread,
7 addVideoToBlacklist,
8 checkAbuseStateChange, 7 checkAbuseStateChange,
9 checkAutoInstanceFollowing, 8 checkAutoInstanceFollowing,
10 CheckerBaseParams, 9 CheckerBaseParams,
@@ -28,7 +27,6 @@ import {
28 MockSmtpServer, 27 MockSmtpServer,
29 prepareNotificationsTest, 28 prepareNotificationsTest,
30 registerUser, 29 registerUser,
31 removeVideoFromBlacklist,
32 ServerInfo, 30 ServerInfo,
33 uploadVideo, 31 uploadVideo,
34 wait, 32 wait,
@@ -297,7 +295,7 @@ describe('Test moderation notifications', function () {
297 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 295 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
298 const uuid = resVideo.body.video.uuid 296 const uuid = resVideo.body.video.uuid
299 297
300 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid) 298 await servers[0].blacklistCommand.add({ videoId: uuid })
301 299
302 await waitJobs(servers) 300 await waitJobs(servers)
303 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist') 301 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
@@ -310,10 +308,10 @@ describe('Test moderation notifications', function () {
310 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 308 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
311 const uuid = resVideo.body.video.uuid 309 const uuid = resVideo.body.video.uuid
312 310
313 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid) 311 await servers[0].blacklistCommand.add({ videoId: uuid })
314 312
315 await waitJobs(servers) 313 await waitJobs(servers)
316 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid) 314 await servers[0].blacklistCommand.remove({ videoId: uuid })
317 await waitJobs(servers) 315 await waitJobs(servers)
318 316
319 await wait(500) 317 await wait(500)
@@ -517,7 +515,7 @@ describe('Test moderation notifications', function () {
517 it('Should send video published and unblacklist after video unblacklisted', async function () { 515 it('Should send video published and unblacklist after video unblacklisted', async function () {
518 this.timeout(40000) 516 this.timeout(40000)
519 517
520 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoUUID) 518 await servers[0].blacklistCommand.remove({ videoId: videoUUID })
521 519
522 await waitJobs(servers) 520 await waitJobs(servers)
523 521
@@ -554,7 +552,7 @@ describe('Test moderation notifications', function () {
554 const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) 552 const resVideo = await uploadVideo(servers[0].url, userAccessToken, data)
555 const uuid = resVideo.body.video.uuid 553 const uuid = resVideo.body.video.uuid
556 554
557 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid) 555 await servers[0].blacklistCommand.remove({ videoId: uuid })
558 556
559 await waitJobs(servers) 557 await waitJobs(servers)
560 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist') 558 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index 85844ae9d..5d997713b 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -4,14 +4,12 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 6import {
7 addVideoToBlacklist,
8 askResetPassword, 7 askResetPassword,
9 askSendVerifyEmail, 8 askSendVerifyEmail,
10 blockUser, 9 blockUser,
11 cleanupTests, 10 cleanupTests,
12 createUser, 11 createUser,
13 flushAndRunServer, 12 flushAndRunServer,
14 removeVideoFromBlacklist,
15 resetPassword, 13 resetPassword,
16 ServerInfo, 14 ServerInfo,
17 setAccessTokensToServers, 15 setAccessTokensToServers,
@@ -248,7 +246,7 @@ describe('Test emails', function () {
248 this.timeout(10000) 246 this.timeout(10000)
249 247
250 const reason = 'my super reason' 248 const reason = 'my super reason'
251 await addVideoToBlacklist(server.url, server.accessToken, videoUserUUID, reason) 249 await server.blacklistCommand.add({ videoId: videoUserUUID, reason })
252 250
253 await waitJobs(server) 251 await waitJobs(server)
254 expect(emails).to.have.lengthOf(6) 252 expect(emails).to.have.lengthOf(6)
@@ -266,7 +264,7 @@ describe('Test emails', function () {
266 it('Should send the notification email', async function () { 264 it('Should send the notification email', async function () {
267 this.timeout(10000) 265 this.timeout(10000)
268 266
269 await removeVideoFromBlacklist(server.url, server.accessToken, videoUserUUID) 267 await server.blacklistCommand.remove({ videoId: videoUserUUID })
270 268
271 await waitJobs(server) 269 await waitJobs(server)
272 expect(emails).to.have.lengthOf(7) 270 expect(emails).to.have.lengthOf(7)
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 3beea5d50..4b9056306 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -11,7 +11,6 @@ import {
11 createUser, 11 createUser,
12 deleteMe, 12 deleteMe,
13 flushAndRunServer, 13 flushAndRunServer,
14 getBlacklistedVideosList,
15 getMyUserInformation, 14 getMyUserInformation,
16 getMyUserVideoQuotaUsed, 15 getMyUserVideoQuotaUsed,
17 getMyUserVideoRating, 16 getMyUserVideoRating,
@@ -808,7 +807,7 @@ describe('Test users', function () {
808 807
809 describe('Video blacklists', function () { 808 describe('Video blacklists', function () {
810 it('Should be able to list video blacklist by a moderator', async function () { 809 it('Should be able to list video blacklist by a moderator', async function () {
811 await getBlacklistedVideosList({ url: server.url, token: accessTokenUser }) 810 await server.blacklistCommand.list({ token: accessTokenUser })
812 }) 811 })
813 }) 812 })
814 813
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 90189721a..069450453 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -6,7 +6,6 @@ import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 addVideoChannel, 7 addVideoChannel,
8 addVideoInPlaylist, 8 addVideoInPlaylist,
9 addVideoToBlacklist,
10 checkPlaylistFilesWereRemoved, 9 checkPlaylistFilesWereRemoved,
11 cleanupTests, 10 cleanupTests,
12 createUser, 11 createUser,
@@ -28,7 +27,6 @@ import {
28 getVideoPlaylistsList, 27 getVideoPlaylistsList,
29 getVideoPlaylistWithToken, 28 getVideoPlaylistWithToken,
30 removeUser, 29 removeUser,
31 removeVideoFromBlacklist,
32 removeVideoFromPlaylist, 30 removeVideoFromPlaylist,
33 reorderVideosPlaylist, 31 reorderVideosPlaylist,
34 ServerInfo, 32 ServerInfo,
@@ -728,7 +726,7 @@ describe('Test video playlists', function () {
728 const position = 1 726 const position = 1
729 727
730 { 728 {
731 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video1, 'reason', true) 729 await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true })
732 await waitJobs(servers) 730 await waitJobs(servers)
733 731
734 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 732 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -738,7 +736,7 @@ describe('Test video playlists', function () {
738 } 736 }
739 737
740 { 738 {
741 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video1) 739 await servers[0].blacklistCommand.remove({ videoId: video1 })
742 await waitJobs(servers) 740 await waitJobs(servers)
743 741
744 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 742 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts
index 6baf37566..6659b6f39 100644
--- a/server/tests/external-plugins/auto-block-videos.ts
+++ b/server/tests/external-plugins/auto-block-videos.ts
@@ -2,13 +2,11 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { Video, VideoBlacklist } from '@shared/models' 5import { Video } from '@shared/models'
6import { 6import {
7 doubleFollow, 7 doubleFollow,
8 getBlacklistedVideosList,
9 getVideosList, 8 getVideosList,
10 MockBlocklist, 9 MockBlocklist,
11 removeVideoFromBlacklist,
12 setAccessTokensToServers, 10 setAccessTokensToServers,
13 uploadVideoAndGetId, 11 uploadVideoAndGetId,
14 wait 12 wait
@@ -97,10 +95,9 @@ describe('Official plugin auto-block videos', function () {
97 }) 95 })
98 96
99 it('Should have video in blacklists', async function () { 97 it('Should have video in blacklists', async function () {
100 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken }) 98 const body = await servers[0].blacklistCommand.list()
101
102 const videoBlacklists = res.body.data as VideoBlacklist[]
103 99
100 const videoBlacklists = body.data
104 expect(videoBlacklists).to.have.lengthOf(1) 101 expect(videoBlacklists).to.have.lengthOf(1)
105 expect(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin') 102 expect(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin')
106 expect(videoBlacklists[0].video.name).to.equal(server2Videos[0].name) 103 expect(videoBlacklists[0].video.name).to.equal(server2Videos[0].name)
@@ -163,7 +160,7 @@ describe('Official plugin auto-block videos', function () {
163 160
164 await check(servers[0], video.uuid, false) 161 await check(servers[0], video.uuid, false)
165 162
166 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video.uuid) 163 await servers[0].blacklistCommand.remove({ videoId: video.uuid })
167 164
168 await check(servers[0], video.uuid, true) 165 await check(servers[0], video.uuid, true)
169 166