2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-11-14 09:32:12 -06:00
|
|
|
|
2022-08-17 08:44:32 -05:00
|
|
|
import { expect } from 'chai'
|
2023-04-21 08:00:01 -05:00
|
|
|
import { SQLCommand } from '@server/tests/shared'
|
2021-12-17 04:58:15 -06:00
|
|
|
import {
|
|
|
|
cleanupTests,
|
|
|
|
createMultipleServers,
|
|
|
|
doubleFollow,
|
|
|
|
PeerTubeServer,
|
|
|
|
setAccessTokensToServers,
|
|
|
|
waitJobs
|
|
|
|
} from '@shared/server-commands'
|
2018-11-14 09:32:12 -06:00
|
|
|
|
|
|
|
describe('Test ActivityPub fetcher', function () {
|
2021-07-16 02:47:51 -05:00
|
|
|
let servers: PeerTubeServer[]
|
2023-04-21 08:00:01 -05:00
|
|
|
let sqlCommandServer1: SQLCommand
|
2018-11-14 09:32:12 -06:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
2021-07-16 02:47:51 -05:00
|
|
|
servers = await createMultipleServers(3)
|
2018-11-14 09:32:12 -06:00
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
|
|
|
const user = { username: 'user1', password: 'password' }
|
|
|
|
for (const server of servers) {
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.users.create({ username: user.username, password: user.password })
|
2018-11-14 09:32:12 -06:00
|
|
|
}
|
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
const userAccessToken = await servers[0].login.getAccessToken(user)
|
2018-11-14 09:32:12 -06:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].videos.upload({ attributes: { name: 'video root' } })
|
|
|
|
const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } })
|
|
|
|
await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } })
|
2018-11-14 09:32:12 -06:00
|
|
|
|
2023-04-21 08:00:01 -05:00
|
|
|
sqlCommandServer1 = new SQLCommand(servers[0])
|
|
|
|
|
2019-04-26 01:50:52 -05:00
|
|
|
{
|
2022-12-09 04:14:47 -06:00
|
|
|
const to = servers[0].url + '/accounts/user1'
|
|
|
|
const value = servers[1].url + '/accounts/user1'
|
2023-04-21 08:00:01 -05:00
|
|
|
await sqlCommandServer1.setActorField(to, 'url', value)
|
2019-04-26 01:50:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-12-09 04:14:47 -06:00
|
|
|
const value = servers[2].url + '/videos/watch/' + uuid
|
2023-04-21 08:00:01 -05:00
|
|
|
await sqlCommandServer1.setVideoField(uuid, 'url', value)
|
2019-04-26 01:50:52 -05:00
|
|
|
}
|
2018-11-14 09:32:12 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
const { total, data } = await servers[0].videos.list({ sort: 'createdAt' })
|
2018-11-14 09:32:12 -06:00
|
|
|
|
2021-07-15 03:02:54 -05:00
|
|
|
expect(total).to.equal(3)
|
2018-11-14 09:32:12 -06:00
|
|
|
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')
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
const { total, data } = await servers[1].videos.list({ sort: 'createdAt' })
|
2018-11-14 09:32:12 -06:00
|
|
|
|
2021-07-15 03:02:54 -05:00
|
|
|
expect(total).to.equal(1)
|
2018-11-14 09:32:12 -06:00
|
|
|
expect(data[0].name).to.equal('video root')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
2019-07-29 04:59:29 -05:00
|
|
|
this.timeout(20000)
|
2019-04-26 01:50:52 -05:00
|
|
|
|
2023-04-21 08:00:01 -05:00
|
|
|
await sqlCommandServer1.cleanup()
|
2019-04-26 01:50:52 -05:00
|
|
|
await cleanupTests(servers)
|
2018-11-14 09:32:12 -06:00
|
|
|
})
|
|
|
|
})
|