From e3d15a6a9aed97a004d9dac1b7a6499d794e080a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 11:17:55 +0200 Subject: Introduce blacklist command --- server/tests/api/check-params/video-blacklist.ts | 47 +++---- server/tests/api/live/live-save-replay.ts | 5 +- server/tests/api/live/live.ts | 3 +- server/tests/api/moderation/video-blacklist.ts | 144 ++++++++------------- .../api/notifications/moderation-notifications.ts | 12 +- server/tests/api/server/email.ts | 6 +- server/tests/api/users/users.ts | 3 +- server/tests/api/videos/video-playlists.ts | 6 +- server/tests/external-plugins/auto-block-videos.ts | 11 +- 9 files changed, 92 insertions(+), 145 deletions(-) (limited to 'server/tests') 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 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' - +import { expect } from 'chai' +import { HttpStatusCode } from '@shared/core-utils' import { + BlacklistCommand, + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination, cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, - getBlacklistedVideosList, getVideo, getVideoWithToken, makePostBodyRequest, makePutBodyRequest, - removeVideoFromBlacklist, ServerInfo, setAccessTokensToServers, uploadVideo, userLogin, waitJobs -} from '../../../../shared/extra-utils' -import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination -} from '../../../../shared/extra-utils/requests/check-api-params' -import { VideoBlacklistType, VideoDetails } from '../../../../shared/models/videos' -import { expect } from 'chai' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +} from '@shared/extra-utils' +import { VideoBlacklistType, VideoDetails } from '@shared/models' describe('Test video blacklist API validators', function () { let servers: ServerInfo[] @@ -34,6 +30,7 @@ describe('Test video blacklist API validators', function () { let remoteVideoUUID: string let userAccessToken1 = '' let userAccessToken2 = '' + let command: BlacklistCommand // --------------------------------------------------------------- @@ -75,6 +72,8 @@ describe('Test video blacklist API validators', function () { } await waitJobs(servers) + + command = servers[0].blacklistCommand }) describe('When adding a video in blacklist', function () { @@ -234,25 +233,26 @@ describe('Test video blacklist API validators', function () { }) describe('When removing a video in blacklist', function () { + it('Should fail with a non authenticated user', async function () { - await removeVideoFromBlacklist(servers[0].url, 'fake token', servers[0].video.uuid, HttpStatusCode.UNAUTHORIZED_401) + await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should fail with a non admin user', async function () { - await removeVideoFromBlacklist(servers[0].url, userAccessToken2, servers[0].video.uuid, HttpStatusCode.FORBIDDEN_403) + await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should fail with an incorrect id', async function () { - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400) + await command.remove({ videoId: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should fail with a not blacklisted video', async function () { // The video was not added to the blacklist so it should fail - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, notBlacklistedVideoId, HttpStatusCode.NOT_FOUND_404) + await command.remove({ videoId: notBlacklistedVideoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) it('Should succeed with the correct params', async function () { - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, servers[0].video.uuid, HttpStatusCode.NO_CONTENT_204) + await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) }) @@ -260,11 +260,11 @@ describe('Test video blacklist API validators', function () { const basePath = '/api/v1/videos/blacklist/' it('Should fail with a non authenticated user', async function () { - await getBlacklistedVideosList({ url: servers[0].url, token: 'fake token', specialStatus: HttpStatusCode.UNAUTHORIZED_401 }) + await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should fail with a non admin user', async function () { - await getBlacklistedVideosList({ url: servers[0].url, token: userAccessToken2, specialStatus: HttpStatusCode.FORBIDDEN_403 }) + await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should fail with a bad start pagination', async function () { @@ -280,16 +280,11 @@ describe('Test video blacklist API validators', function () { }) it('Should fail with an invalid type', async function () { - await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - type: 0, - specialStatus: HttpStatusCode.BAD_REQUEST_400 - }) + await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should succeed with the correct parameters', async function () { - await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlacklistType.MANUAL }) + await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL }) }) }) 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' import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { - addVideoToBlacklist, checkLiveCleanup, cleanupTests, ConfigCommand, @@ -172,7 +171,7 @@ describe('Save replay setting', function () { await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) await Promise.all([ - addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true), + servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), testFfmpegStreamError(ffmpegCommand, true) ]) @@ -280,7 +279,7 @@ describe('Save replay setting', function () { await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) await Promise.all([ - addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true), + servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), testFfmpegStreamError(ffmpegCommand, true) ]) 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- import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { - addVideoToBlacklist, buildServerDirectory, checkLiveCleanup, checkLiveSegmentHash, @@ -347,7 +346,7 @@ describe('Test live', function () { liveVideo = await createLiveWrapper() - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideo.uuid) + await servers[0].blacklistCommand.add({ videoId: liveVideo.uuid }) const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 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' import * as chai from 'chai' import { orderBy } from 'lodash' import { - addVideoToBlacklist, + BlacklistCommand, cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, - getBlacklistedVideosList, getMyUserInformation, getMyVideos, getVideosList, killallServers, - removeVideoFromBlacklist, reRunServer, ServerInfo, setAccessTokensToServers, updateVideo, - updateVideoBlacklist, uploadVideo, userLogin, waitJobs @@ -32,13 +29,14 @@ const expect = chai.expect describe('Test video blacklist', function () { let servers: ServerInfo[] = [] let videoId: number + let command: BlacklistCommand async function blacklistVideosOnServer (server: ServerInfo) { const res = await getVideosList(server.url) const videos = res.body.data for (const video of videos) { - await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') + await server.blacklistCommand.add({ videoId: video.id, reason: 'super reason' }) } } @@ -61,6 +59,8 @@ describe('Test video blacklist', function () { // Wait videos propagation, server 2 has transcoding enabled await waitJobs(servers) + command = servers[0].blacklistCommand + // Blacklist the two videos on server 1 await blacklistVideosOnServer(servers[0]) }) @@ -77,7 +77,7 @@ describe('Test video blacklist', function () { } { - const body = await servers[0].searchCommand.searchVideos({ search: 'name' }) + const body = await servers[0].searchCommand.searchVideos({ search: 'video' }) expect(body.total).to.equal(0) expect(body.data).to.be.an('array') @@ -95,7 +95,7 @@ describe('Test video blacklist', function () { } { - const body = await servers[1].searchCommand.searchVideos({ search: 'name' }) + const body = await servers[1].searchCommand.searchVideos({ search: 'video' }) expect(body.total).to.equal(2) expect(body.data).to.be.an('array') @@ -106,11 +106,10 @@ describe('Test video blacklist', function () { describe('When listing manually blacklisted videos', function () { it('Should display all the blacklisted videos', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken }) - - expect(res.body.total).to.equal(2) + const body = await command.list() + expect(body.total).to.equal(2) - const blacklistedVideos = res.body.data + const blacklistedVideos = body.data expect(blacklistedVideos).to.be.an('array') expect(blacklistedVideos.length).to.equal(2) @@ -121,79 +120,66 @@ describe('Test video blacklist', function () { }) it('Should display all the blacklisted videos when applying manual type filter', async function () { - const res = await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - type: VideoBlacklistType.MANUAL - }) + const body = await command.list({ type: VideoBlacklistType.MANUAL }) + expect(body.total).to.equal(2) - expect(res.body.total).to.equal(2) - - const blacklistedVideos = res.body.data + const blacklistedVideos = body.data expect(blacklistedVideos).to.be.an('array') expect(blacklistedVideos.length).to.equal(2) }) it('Should display nothing when applying automatic type filter', async function () { - const res = await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED - }) + const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) + expect(body.total).to.equal(0) - expect(res.body.total).to.equal(0) - - const blacklistedVideos = res.body.data + const blacklistedVideos = body.data expect(blacklistedVideos).to.be.an('array') expect(blacklistedVideos.length).to.equal(0) }) it('Should get the correct sort when sorting by descending id', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-id' }) - expect(res.body.total).to.equal(2) + const body = await command.list({ sort: '-id' }) + expect(body.total).to.equal(2) - const blacklistedVideos = res.body.data + const blacklistedVideos = body.data expect(blacklistedVideos).to.be.an('array') expect(blacklistedVideos.length).to.equal(2) - const result = orderBy(res.body.data, [ 'id' ], [ 'desc' ]) - + const result = orderBy(body.data, [ 'id' ], [ 'desc' ]) expect(blacklistedVideos).to.deep.equal(result) }) it('Should get the correct sort when sorting by descending video name', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) - expect(res.body.total).to.equal(2) + const body = await command.list({ sort: '-name' }) + expect(body.total).to.equal(2) - const blacklistedVideos = res.body.data + const blacklistedVideos = body.data expect(blacklistedVideos).to.be.an('array') expect(blacklistedVideos.length).to.equal(2) - const result = orderBy(res.body.data, [ 'name' ], [ 'desc' ]) - + const result = orderBy(body.data, [ 'name' ], [ 'desc' ]) expect(blacklistedVideos).to.deep.equal(result) }) it('Should get the correct sort when sorting by ascending creation date', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) - expect(res.body.total).to.equal(2) + const body = await command.list({ sort: 'createdAt' }) + expect(body.total).to.equal(2) - const blacklistedVideos = res.body.data + const blacklistedVideos = body.data expect(blacklistedVideos).to.be.an('array') expect(blacklistedVideos.length).to.equal(2) - const result = orderBy(res.body.data, [ 'createdAt' ]) - + const result = orderBy(body.data, [ 'createdAt' ]) expect(blacklistedVideos).to.deep.equal(result) }) }) describe('When updating blacklisted videos', function () { it('Should change the reason', async function () { - await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') + await command.update({ videoId, reason: 'my super reason updated' }) - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) - const video = res.body.data.find(b => b.video.id === videoId) + const body = await command.list({ sort: '-name' }) + const video = body.data.find(b => b.video.id === videoId) expect(video.reason).to.equal('my super reason updated') }) @@ -228,12 +214,12 @@ describe('Test video blacklist', function () { it('Should remove a video from the blacklist on server 1', async function () { // Get one video in the blacklist - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) - videoToRemove = res.body.data[0] - blacklist = res.body.data.slice(1) + const body = await command.list({ sort: '-name' }) + videoToRemove = body.data[0] + blacklist = body.data.slice(1) // Remove it - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.video.id) + await command.remove({ videoId: videoToRemove.video.id }) }) it('Should have the ex-blacklisted video in videos list on server 1', async function () { @@ -249,10 +235,10 @@ describe('Test video blacklist', function () { }) it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) - expect(res.body.total).to.equal(1) + const body = await command.list({ sort: '-name' }) + expect(body.total).to.equal(1) - const videos = res.body.data + const videos = body.data expect(videos).to.be.an('array') expect(videos.length).to.equal(1) expect(videos).to.deep.equal(blacklist) @@ -281,7 +267,7 @@ describe('Test video blacklist', function () { it('Should blacklist video 3 and keep it federated', async function () { this.timeout(10000) - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video3UUID, 'super reason', false) + await command.add({ videoId: video3UUID, reason: 'super reason', unfederate: false }) await waitJobs(servers) @@ -299,7 +285,7 @@ describe('Test video blacklist', function () { it('Should unfederate the video', async function () { this.timeout(10000) - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video4UUID, 'super reason', true) + await command.add({ videoId: video4UUID, reason: 'super reason', unfederate: true }) await waitJobs(servers) @@ -323,9 +309,9 @@ describe('Test video blacklist', function () { }) it('Should have the correct video blacklist unfederate attribute', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) + const body = await command.list({ sort: 'createdAt' }) - const blacklistedVideos: VideoBlacklist[] = res.body.data + const blacklistedVideos = body.data const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) const video4Blacklisted = blacklistedVideos.find(b => b.video.uuid === video4UUID) @@ -336,7 +322,7 @@ describe('Test video blacklist', function () { it('Should remove the video from blacklist and refederate the video', async function () { this.timeout(10000) - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video4UUID) + await command.remove({ videoId: video4UUID }) await waitJobs(servers) @@ -407,14 +393,9 @@ describe('Test video blacklist', function () { it('Should auto blacklist a video on upload', async function () { await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' }) - const res = await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED - }) - - expect(res.body.total).to.equal(1) - expect(res.body.data[0].video.name).to.equal('blacklisted') + const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) + expect(body.total).to.equal(1) + expect(body.data[0].video.name).to.equal('blacklisted') }) it('Should auto blacklist a video on URL import', async function () { @@ -427,15 +408,9 @@ describe('Test video blacklist', function () { } await importVideo(servers[0].url, userWithoutFlag, attributes) - const res = await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - sort: 'createdAt', - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED - }) - - expect(res.body.total).to.equal(2) - expect(res.body.data[1].video.name).to.equal('URL import') + const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) + expect(body.total).to.equal(2) + expect(body.data[1].video.name).to.equal('URL import') }) it('Should auto blacklist a video on torrent import', async function () { @@ -446,27 +421,16 @@ describe('Test video blacklist', function () { } await importVideo(servers[0].url, userWithoutFlag, attributes) - const res = await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - sort: 'createdAt', - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED - }) - - expect(res.body.total).to.equal(3) - expect(res.body.data[2].video.name).to.equal('Torrent import') + const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) + expect(body.total).to.equal(3) + expect(body.data[2].video.name).to.equal('Torrent import') }) it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () { await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' }) - const res = await getBlacklistedVideosList({ - url: servers[0].url, - token: servers[0].accessToken, - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED - }) - - expect(res.body.total).to.equal(3) + const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) + expect(body.total).to.equal(3) }) }) 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' import { buildUUID } from '@server/helpers/uuid' import { addVideoCommentThread, - addVideoToBlacklist, checkAbuseStateChange, checkAutoInstanceFollowing, CheckerBaseParams, @@ -28,7 +27,6 @@ import { MockSmtpServer, prepareNotificationsTest, registerUser, - removeVideoFromBlacklist, ServerInfo, uploadVideo, wait, @@ -297,7 +295,7 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const uuid = resVideo.body.video.uuid - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.add({ videoId: uuid }) await waitJobs(servers) await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist') @@ -310,10 +308,10 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const uuid = resVideo.body.video.uuid - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.add({ videoId: uuid }) await waitJobs(servers) - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.remove({ videoId: uuid }) await waitJobs(servers) await wait(500) @@ -517,7 +515,7 @@ describe('Test moderation notifications', function () { it('Should send video published and unblacklist after video unblacklisted', async function () { this.timeout(40000) - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoUUID) + await servers[0].blacklistCommand.remove({ videoId: videoUUID }) await waitJobs(servers) @@ -554,7 +552,7 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) const uuid = resVideo.body.video.uuid - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.remove({ videoId: uuid }) await waitJobs(servers) 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' import * as chai from 'chai' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { - addVideoToBlacklist, askResetPassword, askSendVerifyEmail, blockUser, cleanupTests, createUser, flushAndRunServer, - removeVideoFromBlacklist, resetPassword, ServerInfo, setAccessTokensToServers, @@ -248,7 +246,7 @@ describe('Test emails', function () { this.timeout(10000) const reason = 'my super reason' - await addVideoToBlacklist(server.url, server.accessToken, videoUserUUID, reason) + await server.blacklistCommand.add({ videoId: videoUserUUID, reason }) await waitJobs(server) expect(emails).to.have.lengthOf(6) @@ -266,7 +264,7 @@ describe('Test emails', function () { it('Should send the notification email', async function () { this.timeout(10000) - await removeVideoFromBlacklist(server.url, server.accessToken, videoUserUUID) + await server.blacklistCommand.remove({ videoId: videoUserUUID }) await waitJobs(server) 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 { createUser, deleteMe, flushAndRunServer, - getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, @@ -808,7 +807,7 @@ describe('Test users', function () { describe('Video blacklists', function () { it('Should be able to list video blacklist by a moderator', async function () { - await getBlacklistedVideosList({ url: server.url, token: accessTokenUser }) + await server.blacklistCommand.list({ token: accessTokenUser }) }) }) 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' import { addVideoChannel, addVideoInPlaylist, - addVideoToBlacklist, checkPlaylistFilesWereRemoved, cleanupTests, createUser, @@ -28,7 +27,6 @@ import { getVideoPlaylistsList, getVideoPlaylistWithToken, removeUser, - removeVideoFromBlacklist, removeVideoFromPlaylist, reorderVideosPlaylist, ServerInfo, @@ -728,7 +726,7 @@ describe('Test video playlists', function () { const position = 1 { - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video1, 'reason', true) + await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -738,7 +736,7 @@ describe('Test video playlists', function () { } { - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video1) + await servers[0].blacklistCommand.remove({ videoId: video1 }) await waitJobs(servers) 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 @@ import 'mocha' import { expect } from 'chai' -import { Video, VideoBlacklist } from '@shared/models' +import { Video } from '@shared/models' import { doubleFollow, - getBlacklistedVideosList, getVideosList, MockBlocklist, - removeVideoFromBlacklist, setAccessTokensToServers, uploadVideoAndGetId, wait @@ -97,10 +95,9 @@ describe('Official plugin auto-block videos', function () { }) it('Should have video in blacklists', async function () { - const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken }) - - const videoBlacklists = res.body.data as VideoBlacklist[] + const body = await servers[0].blacklistCommand.list() + const videoBlacklists = body.data expect(videoBlacklists).to.have.lengthOf(1) expect(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin') expect(videoBlacklists[0].video.name).to.equal(server2Videos[0].name) @@ -163,7 +160,7 @@ describe('Official plugin auto-block videos', function () { await check(servers[0], video.uuid, false) - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video.uuid) + await servers[0].blacklistCommand.remove({ videoId: video.uuid }) await check(servers[0], video.uuid, true) -- cgit v1.2.3