]>
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' |
a130f33c | 5 | import { |
48f07b4a | 6 | cleanupTests, |
a130f33c C |
7 | createUser, |
8 | doubleFollow, | |
9 | flushAndRunMultipleServers, | |
a130f33c | 10 | getVideosListSort, |
a130f33c C |
11 | ServerInfo, |
12 | setAccessTokensToServers, | |
13 | uploadVideo, | |
2a8c5d0a | 14 | waitJobs |
94565d52 | 15 | } from '../../../../shared/extra-utils' |
a130f33c C |
16 | import { Video } from '../../../../shared/models/videos' |
17 | ||
18 | const expect = chai.expect | |
19 | ||
20 | describe('Test ActivityPub fetcher', function () { | |
21 | let servers: ServerInfo[] | |
22 | ||
23 | // --------------------------------------------------------------- | |
24 | ||
25 | before(async function () { | |
26 | this.timeout(60000) | |
27 | ||
28 | servers = await flushAndRunMultipleServers(3) | |
29 | ||
30 | // Get the access tokens | |
31 | await setAccessTokensToServers(servers) | |
32 | ||
33 | const user = { username: 'user1', password: 'password' } | |
34 | for (const server of servers) { | |
1eddc9a7 | 35 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
a130f33c C |
36 | } |
37 | ||
41d1d075 | 38 | const userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
a130f33c C |
39 | |
40 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' }) | |
41 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' }) | |
42 | const badVideoUUID = res.body.video.uuid | |
43 | await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' }) | |
44 | ||
48f07b4a C |
45 | { |
46 | const to = 'http://localhost:' + servers[0].port + '/accounts/user1' | |
47 | const value = 'http://localhost:' + servers[1].port + '/accounts/user1' | |
9293139f | 48 | await servers[0].sqlCommand.setActorField(to, 'url', value) |
48f07b4a C |
49 | } |
50 | ||
51 | { | |
52 | const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID | |
9293139f | 53 | await servers[0].sqlCommand.setVideoField(badVideoUUID, 'url', value) |
48f07b4a | 54 | } |
a130f33c C |
55 | }) |
56 | ||
57 | it('Should add only the video with a valid actor URL', async function () { | |
58 | this.timeout(60000) | |
59 | ||
60 | await doubleFollow(servers[0], servers[1]) | |
61 | await waitJobs(servers) | |
62 | ||
63 | { | |
64 | const res = await getVideosListSort(servers[0].url, 'createdAt') | |
65 | expect(res.body.total).to.equal(3) | |
66 | ||
67 | const data: Video[] = res.body.data | |
68 | expect(data[0].name).to.equal('video root') | |
69 | expect(data[1].name).to.equal('bad video root') | |
70 | expect(data[2].name).to.equal('video user') | |
71 | } | |
72 | ||
73 | { | |
74 | const res = await getVideosListSort(servers[1].url, 'createdAt') | |
75 | expect(res.body.total).to.equal(1) | |
76 | ||
77 | const data: Video[] = res.body.data | |
78 | expect(data[0].name).to.equal('video root') | |
79 | } | |
80 | }) | |
81 | ||
82 | after(async function () { | |
2284f202 | 83 | this.timeout(20000) |
48f07b4a C |
84 | |
85 | await cleanupTests(servers) | |
a130f33c C |
86 | }) |
87 | }) |