]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/video-blacklist.js
1 /* eslint-disable no-unused-expressions */
5 const chai
= require('chai')
6 const each
= require('async/each')
7 const expect
= chai
.expect
8 const series
= require('async/series')
10 const loginUtils
= require('../utils/login')
11 const podsUtils
= require('../utils/pods')
12 const serversUtils
= require('../utils/servers')
13 const videosUtils
= require('../utils/videos')
14 const videoBlacklistsUtils
= require('../utils/video-blacklists')
16 describe('Test video blacklists', function () {
19 before(function (done
) {
25 serversUtils
.flushAndRunMultipleServers(2, function (serversRun
) {
30 // Get the access tokens
32 each(servers
, function (server
, callbackEach
) {
33 loginUtils
.loginAndGetAccessToken(server
, function (err
, accessToken
) {
34 if (err
) return callbackEach(err
)
36 server
.accessToken
= accessToken
41 // Pod 1 makes friend with pod 2
43 const server
= servers
[0]
44 podsUtils
.makeFriends(server
.url
, server
.accessToken
, next
)
46 // Upload a video on pod 2
48 const videoAttributes
= {
49 name: 'my super name for pod 2',
50 description: 'my super description for pod 2'
52 videosUtils
.uploadVideo(servers
[1].url
, servers
[1].accessToken
, videoAttributes
, next
)
54 // Wait videos propagation
56 setTimeout(next
, 22000)
59 videosUtils
.getVideosList(servers
[0].url
, function (err
, res
) {
62 const videos
= res
.body
.data
64 expect(videos
.length
).to
.equal(1)
66 servers
[0].remoteVideo
= videos
.find(function (video
) { return video
.name
=== 'my super name for pod 2' })
74 it('Should blacklist a remote video on pod 1', function (done
) {
75 videoBlacklistsUtils
.addVideoToBlacklist(servers
[0].url
, servers
[0].accessToken
, servers
[0].remoteVideo
.id
, done
)
78 it('Should not have the video blacklisted in videos list on pod 1', function (done
) {
79 videosUtils
.getVideosList(servers
[0].url
, function (err
, res
) {
82 expect(res
.body
.total
).to
.equal(0)
83 expect(res
.body
.data
).to
.be
.an('array')
84 expect(res
.body
.data
.length
).to
.equal(0)
90 it('Should not have the video blacklisted in videos search on pod 1', function (done
) {
91 videosUtils
.searchVideo(servers
[0].url
, 'name', function (err
, res
) {
94 expect(res
.body
.total
).to
.equal(0)
95 expect(res
.body
.data
).to
.be
.an('array')
96 expect(res
.body
.data
.length
).to
.equal(0)
102 it('Should have the blacklisted video in videos list on pod 2', function (done
) {
103 videosUtils
.getVideosList(servers
[1].url
, function (err
, res
) {
106 expect(res
.body
.total
).to
.equal(1)
107 expect(res
.body
.data
).to
.be
.an('array')
108 expect(res
.body
.data
.length
).to
.equal(1)
114 it('Should have the video blacklisted in videos search on pod 2', function (done
) {
115 videosUtils
.searchVideo(servers
[1].url
, 'name', function (err
, res
) {
118 expect(res
.body
.total
).to
.equal(1)
119 expect(res
.body
.data
).to
.be
.an('array')
120 expect(res
.body
.data
.length
).to
.equal(1)
126 after(function (done
) {
127 servers
.forEach(function (server
) {
128 process
.kill(-server
.app
.pid
)
131 // Keep the logs if the test failed
133 serversUtils
.flushTests(done
)