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