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