]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
a130f33c C |
2 | |
3 | import 'mocha' | |
9293139f | 4 | import * as chai from 'chai' |
4c7e60bc | 5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' |
a130f33c C |
6 | |
7 | const expect = chai.expect | |
8 | ||
9 | describe('Test ActivityPub fetcher', function () { | |
254d3579 | 10 | let servers: PeerTubeServer[] |
a130f33c C |
11 | |
12 | // --------------------------------------------------------------- | |
13 | ||
14 | before(async function () { | |
15 | this.timeout(60000) | |
16 | ||
254d3579 | 17 | servers = await createMultipleServers(3) |
a130f33c C |
18 | |
19 | // Get the access tokens | |
20 | await setAccessTokensToServers(servers) | |
21 | ||
22 | const user = { username: 'user1', password: 'password' } | |
23 | for (const server of servers) { | |
89d241a7 | 24 | await server.users.create({ username: user.username, password: user.password }) |
a130f33c C |
25 | } |
26 | ||
89d241a7 | 27 | const userAccessToken = await servers[0].login.getAccessToken(user) |
a130f33c | 28 | |
89d241a7 C |
29 | await servers[0].videos.upload({ attributes: { name: 'video root' } }) |
30 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } }) | |
31 | await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } }) | |
a130f33c | 32 | |
48f07b4a C |
33 | { |
34 | const to = 'http://localhost:' + servers[0].port + '/accounts/user1' | |
35 | const value = 'http://localhost:' + servers[1].port + '/accounts/user1' | |
89d241a7 | 36 | await servers[0].sql.setActorField(to, 'url', value) |
48f07b4a C |
37 | } |
38 | ||
39 | { | |
d23dd9fb | 40 | const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid |
89d241a7 | 41 | await servers[0].sql.setVideoField(uuid, 'url', value) |
48f07b4a | 42 | } |
a130f33c C |
43 | }) |
44 | ||
45 | it('Should add only the video with a valid actor URL', async function () { | |
46 | this.timeout(60000) | |
47 | ||
48 | await doubleFollow(servers[0], servers[1]) | |
49 | await waitJobs(servers) | |
50 | ||
51 | { | |
89d241a7 | 52 | const { total, data } = await servers[0].videos.list({ sort: 'createdAt' }) |
a130f33c | 53 | |
d23dd9fb | 54 | expect(total).to.equal(3) |
a130f33c C |
55 | expect(data[0].name).to.equal('video root') |
56 | expect(data[1].name).to.equal('bad video root') | |
57 | expect(data[2].name).to.equal('video user') | |
58 | } | |
59 | ||
60 | { | |
89d241a7 | 61 | const { total, data } = await servers[1].videos.list({ sort: 'createdAt' }) |
a130f33c | 62 | |
d23dd9fb | 63 | expect(total).to.equal(1) |
a130f33c C |
64 | expect(data[0].name).to.equal('video root') |
65 | } | |
66 | }) | |
67 | ||
68 | after(async function () { | |
2284f202 | 69 | this.timeout(20000) |
48f07b4a C |
70 | |
71 | await cleanupTests(servers) | |
a130f33c C |
72 | }) |
73 | }) |