2018-11-14 16:32:12 +01:00
|
|
|
/* tslint:disable:no-unused-expression */
|
|
|
|
|
|
|
|
import 'mocha'
|
|
|
|
|
|
|
|
import {
|
2019-02-21 15:44:12 +01:00
|
|
|
closeAllSequelize,
|
2018-11-14 16:32:12 +01:00
|
|
|
createUser,
|
|
|
|
doubleFollow,
|
|
|
|
flushAndRunMultipleServers,
|
|
|
|
flushTests,
|
|
|
|
getVideosListSort,
|
|
|
|
killallServers,
|
|
|
|
ServerInfo,
|
|
|
|
setAccessTokensToServers,
|
2018-12-07 16:09:57 +01:00
|
|
|
setActorField,
|
|
|
|
setVideoField,
|
2018-11-14 16:32:12 +01:00
|
|
|
uploadVideo,
|
2018-12-07 16:09:57 +01:00
|
|
|
userLogin,
|
|
|
|
waitJobs
|
2019-04-15 15:26:15 +02:00
|
|
|
} from '../../../../shared/extra-utils'
|
2018-11-14 16:32:12 +01:00
|
|
|
import * as chai from 'chai'
|
|
|
|
import { Video } from '../../../../shared/models/videos'
|
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('Test ActivityPub fetcher', function () {
|
|
|
|
let servers: ServerInfo[]
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
|
|
|
servers = await flushAndRunMultipleServers(3)
|
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
|
|
|
const user = { username: 'user1', password: 'password' }
|
|
|
|
for (const server of servers) {
|
2019-04-15 10:49:46 +02:00
|
|
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
2018-11-14 16:32:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const userAccessToken = await userLogin(servers[0], user)
|
|
|
|
|
|
|
|
await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' })
|
|
|
|
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
|
|
|
|
const badVideoUUID = res.body.video.uuid
|
|
|
|
await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
|
|
|
|
|
|
|
|
await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1')
|
|
|
|
await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should add only the video with a valid actor URL', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await getVideosListSort(servers[0].url, 'createdAt')
|
|
|
|
expect(res.body.total).to.equal(3)
|
|
|
|
|
|
|
|
const data: Video[] = res.body.data
|
|
|
|
expect(data[0].name).to.equal('video root')
|
|
|
|
expect(data[1].name).to.equal('bad video root')
|
|
|
|
expect(data[2].name).to.equal('video user')
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await getVideosListSort(servers[1].url, 'createdAt')
|
|
|
|
expect(res.body.total).to.equal(1)
|
|
|
|
|
|
|
|
const data: Video[] = res.body.data
|
|
|
|
expect(data[0].name).to.equal('video root')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
killallServers(servers)
|
|
|
|
|
2019-02-21 15:44:12 +01:00
|
|
|
await closeAllSequelize(servers)
|
2018-11-14 16:32:12 +01:00
|
|
|
})
|
|
|
|
})
|