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