]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import { | |
6 | cleanupTests, | |
7 | createMultipleServers, | |
8 | doubleFollow, | |
9 | PeerTubeServer, | |
10 | setAccessTokensToServers, | |
11 | waitJobs | |
12 | } from '@shared/server-commands' | |
13 | ||
14 | const expect = chai.expect | |
15 | ||
16 | describe('Test ActivityPub fetcher', function () { | |
17 | let servers: PeerTubeServer[] | |
18 | ||
19 | // --------------------------------------------------------------- | |
20 | ||
21 | before(async function () { | |
22 | this.timeout(60000) | |
23 | ||
24 | servers = await createMultipleServers(3) | |
25 | ||
26 | // Get the access tokens | |
27 | await setAccessTokensToServers(servers) | |
28 | ||
29 | const user = { username: 'user1', password: 'password' } | |
30 | for (const server of servers) { | |
31 | await server.users.create({ username: user.username, password: user.password }) | |
32 | } | |
33 | ||
34 | const userAccessToken = await servers[0].login.getAccessToken(user) | |
35 | ||
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' } }) | |
39 | ||
40 | { | |
41 | const to = 'http://localhost:' + servers[0].port + '/accounts/user1' | |
42 | const value = 'http://localhost:' + servers[1].port + '/accounts/user1' | |
43 | await servers[0].sql.setActorField(to, 'url', value) | |
44 | } | |
45 | ||
46 | { | |
47 | const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid | |
48 | await servers[0].sql.setVideoField(uuid, 'url', value) | |
49 | } | |
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 | { | |
59 | const { total, data } = await servers[0].videos.list({ sort: 'createdAt' }) | |
60 | ||
61 | expect(total).to.equal(3) | |
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 | { | |
68 | const { total, data } = await servers[1].videos.list({ sort: 'createdAt' }) | |
69 | ||
70 | expect(total).to.equal(1) | |
71 | expect(data[0].name).to.equal('video root') | |
72 | } | |
73 | }) | |
74 | ||
75 | after(async function () { | |
76 | this.timeout(20000) | |
77 | ||
78 | await cleanupTests(servers) | |
79 | }) | |
80 | }) |