]>
Commit | Line | Data |
---|---|---|
1 | /* tslint:disable:no-unused-expression */ | |
2 | ||
3 | import 'mocha' | |
4 | ||
5 | import { | |
6 | closeAllSequelize, | |
7 | createUser, | |
8 | doubleFollow, | |
9 | flushAndRunMultipleServers, | |
10 | flushTests, | |
11 | getVideosListSort, | |
12 | killallServers, | |
13 | ServerInfo, | |
14 | setAccessTokensToServers, | |
15 | setActorField, | |
16 | setVideoField, | |
17 | uploadVideo, | |
18 | userLogin, | |
19 | waitJobs | |
20 | } from '../../../../shared/extra-utils' | |
21 | import * as chai from 'chai' | |
22 | import { Video } from '../../../../shared/models/videos' | |
23 | ||
24 | const expect = chai.expect | |
25 | ||
26 | describe('Test ActivityPub fetcher', function () { | |
27 | let servers: ServerInfo[] | |
28 | ||
29 | // --------------------------------------------------------------- | |
30 | ||
31 | before(async function () { | |
32 | this.timeout(60000) | |
33 | ||
34 | servers = await flushAndRunMultipleServers(3) | |
35 | ||
36 | // Get the access tokens | |
37 | await setAccessTokensToServers(servers) | |
38 | ||
39 | const user = { username: 'user1', password: 'password' } | |
40 | for (const server of servers) { | |
41 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | |
42 | } | |
43 | ||
44 | const userAccessToken = await userLogin(servers[0], user) | |
45 | ||
46 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' }) | |
47 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' }) | |
48 | const badVideoUUID = res.body.video.uuid | |
49 | await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' }) | |
50 | ||
51 | await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1') | |
52 | await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID) | |
53 | }) | |
54 | ||
55 | it('Should add only the video with a valid actor URL', async function () { | |
56 | this.timeout(60000) | |
57 | ||
58 | await doubleFollow(servers[0], servers[1]) | |
59 | await waitJobs(servers) | |
60 | ||
61 | { | |
62 | const res = await getVideosListSort(servers[0].url, 'createdAt') | |
63 | expect(res.body.total).to.equal(3) | |
64 | ||
65 | const data: Video[] = res.body.data | |
66 | expect(data[0].name).to.equal('video root') | |
67 | expect(data[1].name).to.equal('bad video root') | |
68 | expect(data[2].name).to.equal('video user') | |
69 | } | |
70 | ||
71 | { | |
72 | const res = await getVideosListSort(servers[1].url, 'createdAt') | |
73 | expect(res.body.total).to.equal(1) | |
74 | ||
75 | const data: Video[] = res.body.data | |
76 | expect(data[0].name).to.equal('video root') | |
77 | } | |
78 | }) | |
79 | ||
80 | after(async function () { | |
81 | killallServers(servers) | |
82 | ||
83 | await closeAllSequelize(servers) | |
84 | ||
85 | // Keep the logs if the test failed | |
86 | if (this['ok']) { | |
87 | await flushTests() | |
88 | } | |
89 | }) | |
90 | }) |