2017-09-04 21:21:47 +02:00
|
|
|
/* tslint:disable:no-unused-expression */
|
|
|
|
|
|
|
|
import * as chai from 'chai'
|
2017-11-17 12:05:59 +01:00
|
|
|
import 'mocha'
|
2017-09-04 21:21:47 +02:00
|
|
|
import {
|
2017-11-17 12:05:59 +01:00
|
|
|
addVideoToBlacklist,
|
|
|
|
flushAndRunMultipleServers,
|
2017-09-04 21:21:47 +02:00
|
|
|
getVideosList,
|
2017-11-17 12:05:59 +01:00
|
|
|
killallServers,
|
2017-09-04 21:21:47 +02:00
|
|
|
searchVideo,
|
2017-11-17 12:05:59 +01:00
|
|
|
ServerInfo,
|
|
|
|
setAccessTokensToServers,
|
2018-06-13 10:06:50 +02:00
|
|
|
uploadVideo
|
2017-12-28 13:59:22 +01:00
|
|
|
} from '../../utils/index'
|
|
|
|
import { doubleFollow } from '../../utils/server/follows'
|
2018-06-13 10:06:50 +02:00
|
|
|
import { waitJobs } from '../../utils/server/jobs'
|
2017-11-17 12:05:59 +01:00
|
|
|
|
|
|
|
const expect = chai.expect
|
2017-09-04 21:21:47 +02:00
|
|
|
|
|
|
|
describe('Test video blacklists', function () {
|
|
|
|
let servers: ServerInfo[] = []
|
|
|
|
|
|
|
|
before(async function () {
|
2017-11-17 15:42:12 +01:00
|
|
|
this.timeout(50000)
|
2017-09-04 21:21:47 +02:00
|
|
|
|
|
|
|
// Run servers
|
|
|
|
servers = await flushAndRunMultipleServers(2)
|
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
// Server 1 and server 2 follow each other
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
2017-09-04 21:21:47 +02:00
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
// Upload a video on server 2
|
2017-09-04 21:21:47 +02:00
|
|
|
const videoAttributes = {
|
2017-11-17 12:05:59 +01:00
|
|
|
name: 'my super name for server 2',
|
|
|
|
description: 'my super description for server 2'
|
2017-09-04 21:21:47 +02:00
|
|
|
}
|
|
|
|
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
|
|
|
|
2017-11-17 15:42:12 +01:00
|
|
|
// Wait videos propagation, server 2 has transcoding enabled
|
2018-06-13 10:06:50 +02:00
|
|
|
await waitJobs(servers)
|
2017-09-04 21:21:47 +02:00
|
|
|
|
|
|
|
const res = await getVideosList(servers[0].url)
|
|
|
|
const videos = res.body.data
|
|
|
|
|
|
|
|
expect(videos.length).to.equal(1)
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2')
|
2017-09-04 21:21:47 +02:00
|
|
|
})
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
it('Should blacklist a remote video on server 1', async function () {
|
2017-09-04 21:21:47 +02:00
|
|
|
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
|
|
|
|
})
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
it('Should not have the video blacklisted in videos list on server 1', async function () {
|
2017-09-04 21:21:47 +02:00
|
|
|
const res = await getVideosList(servers[0].url)
|
|
|
|
|
|
|
|
expect(res.body.total).to.equal(0)
|
|
|
|
expect(res.body.data).to.be.an('array')
|
|
|
|
expect(res.body.data.length).to.equal(0)
|
|
|
|
})
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
it('Should not have the video blacklisted in videos search on server 1', async function () {
|
2017-09-04 21:21:47 +02:00
|
|
|
const res = await searchVideo(servers[0].url, 'name')
|
|
|
|
|
|
|
|
expect(res.body.total).to.equal(0)
|
|
|
|
expect(res.body.data).to.be.an('array')
|
|
|
|
expect(res.body.data.length).to.equal(0)
|
|
|
|
})
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
it('Should have the blacklisted video in videos list on server 2', async function () {
|
2017-09-04 21:21:47 +02:00
|
|
|
const res = await getVideosList(servers[1].url)
|
|
|
|
|
|
|
|
expect(res.body.total).to.equal(1)
|
|
|
|
expect(res.body.data).to.be.an('array')
|
|
|
|
expect(res.body.data.length).to.equal(1)
|
|
|
|
})
|
|
|
|
|
2017-11-17 12:05:59 +01:00
|
|
|
it('Should have the video blacklisted in videos search on server 2', async function () {
|
2017-09-04 21:21:47 +02:00
|
|
|
const res = await searchVideo(servers[1].url, 'name')
|
|
|
|
|
|
|
|
expect(res.body.total).to.equal(1)
|
|
|
|
expect(res.body.data).to.be.an('array')
|
|
|
|
expect(res.body.data.length).to.equal(1)
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
killallServers(servers)
|
|
|
|
})
|
|
|
|
})
|