]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/activitypub/fetch.ts
Allow to specify transcoding and import jobs concurrency
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / fetch.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
a130f33c
C
2
3import 'mocha'
4
5import {
48f07b4a 6 cleanupTests,
c8000975 7 closeAllSequelize,
a130f33c
C
8 createUser,
9 doubleFollow,
10 flushAndRunMultipleServers,
a130f33c 11 getVideosListSort,
a130f33c
C
12 ServerInfo,
13 setAccessTokensToServers,
2a8c5d0a
C
14 setActorField,
15 setVideoField,
a130f33c 16 uploadVideo,
2a8c5d0a
C
17 userLogin,
18 waitJobs
94565d52 19} from '../../../../shared/extra-utils'
a130f33c 20import * as chai from 'chai'
a130f33c
C
21import { Video } from '../../../../shared/models/videos'
22
23const expect = chai.expect
24
25describe('Test ActivityPub fetcher', function () {
26 let servers: ServerInfo[]
27
28 // ---------------------------------------------------------------
29
30 before(async function () {
31 this.timeout(60000)
32
33 servers = await flushAndRunMultipleServers(3)
34
35 // Get the access tokens
36 await setAccessTokensToServers(servers)
37
38 const user = { username: 'user1', password: 'password' }
39 for (const server of servers) {
1eddc9a7 40 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
a130f33c
C
41 }
42
43 const userAccessToken = await userLogin(servers[0], user)
44
45 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' })
46 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
47 const badVideoUUID = res.body.video.uuid
48 await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
49
48f07b4a
C
50 {
51 const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
52 const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
53 await setActorField(servers[0].internalServerNumber, to, 'url', value)
54 }
55
56 {
57 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID
58 await setVideoField(servers[0].internalServerNumber, badVideoUUID, 'url', value)
59 }
a130f33c
C
60 })
61
62 it('Should add only the video with a valid actor URL', async function () {
63 this.timeout(60000)
64
65 await doubleFollow(servers[0], servers[1])
66 await waitJobs(servers)
67
68 {
69 const res = await getVideosListSort(servers[0].url, 'createdAt')
70 expect(res.body.total).to.equal(3)
71
72 const data: Video[] = res.body.data
73 expect(data[0].name).to.equal('video root')
74 expect(data[1].name).to.equal('bad video root')
75 expect(data[2].name).to.equal('video user')
76 }
77
78 {
79 const res = await getVideosListSort(servers[1].url, 'createdAt')
80 expect(res.body.total).to.equal(1)
81
82 const data: Video[] = res.body.data
83 expect(data[0].name).to.equal('video root')
84 }
85 })
86
87 after(async function () {
2284f202 88 this.timeout(20000)
48f07b4a
C
89
90 await cleanupTests(servers)
a130f33c 91
c8000975 92 await closeAllSequelize(servers)
a130f33c
C
93 })
94})