]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/activitypub/fetch.ts
Fix s3 mock cleanup
[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 2
86347717 3import { expect } from 'chai'
d102de1b 4import { SQLCommand } from '@server/tests/shared'
c55e3d72
C
5import {
6 cleanupTests,
7 createMultipleServers,
8 doubleFollow,
9 PeerTubeServer,
10 setAccessTokensToServers,
11 waitJobs
12} from '@shared/server-commands'
a130f33c 13
a130f33c 14describe('Test ActivityPub fetcher', function () {
254d3579 15 let servers: PeerTubeServer[]
d102de1b 16 let sqlCommandServer1: SQLCommand
a130f33c
C
17
18 // ---------------------------------------------------------------
19
20 before(async function () {
21 this.timeout(60000)
22
254d3579 23 servers = await createMultipleServers(3)
a130f33c
C
24
25 // Get the access tokens
26 await setAccessTokensToServers(servers)
27
28 const user = { username: 'user1', password: 'password' }
29 for (const server of servers) {
89d241a7 30 await server.users.create({ username: user.username, password: user.password })
a130f33c
C
31 }
32
89d241a7 33 const userAccessToken = await servers[0].login.getAccessToken(user)
a130f33c 34
89d241a7
C
35 await servers[0].videos.upload({ attributes: { name: 'video root' } })
36 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } })
37 await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } })
a130f33c 38
d102de1b
C
39 sqlCommandServer1 = new SQLCommand(servers[0])
40
48f07b4a 41 {
2732eeff
C
42 const to = servers[0].url + '/accounts/user1'
43 const value = servers[1].url + '/accounts/user1'
d102de1b 44 await sqlCommandServer1.setActorField(to, 'url', value)
48f07b4a
C
45 }
46
47 {
2732eeff 48 const value = servers[2].url + '/videos/watch/' + uuid
d102de1b 49 await sqlCommandServer1.setVideoField(uuid, 'url', value)
48f07b4a 50 }
a130f33c
C
51 })
52
53 it('Should add only the video with a valid actor URL', async function () {
54 this.timeout(60000)
55
56 await doubleFollow(servers[0], servers[1])
57 await waitJobs(servers)
58
59 {
89d241a7 60 const { total, data } = await servers[0].videos.list({ sort: 'createdAt' })
a130f33c 61
d23dd9fb 62 expect(total).to.equal(3)
a130f33c
C
63 expect(data[0].name).to.equal('video root')
64 expect(data[1].name).to.equal('bad video root')
65 expect(data[2].name).to.equal('video user')
66 }
67
68 {
89d241a7 69 const { total, data } = await servers[1].videos.list({ sort: 'createdAt' })
a130f33c 70
d23dd9fb 71 expect(total).to.equal(1)
a130f33c
C
72 expect(data[0].name).to.equal('video root')
73 }
74 })
75
76 after(async function () {
2284f202 77 this.timeout(20000)
48f07b4a 78
d102de1b 79 await sqlCommandServer1.cleanup()
48f07b4a 80 await cleanupTests(servers)
a130f33c
C
81 })
82})