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