]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
06a05d5f | 2 | |
86347717 | 3 | import { expect } from 'chai' |
6def7d34 | 4 | import { VideoPrivacy } from '@shared/models' |
9639bd17 | 5 | import { |
7c3b7976 | 6 | cleanupTests, |
254d3579 | 7 | createMultipleServers, |
4c7e60bc | 8 | doubleFollow, |
254d3579 | 9 | PeerTubeServer, |
c3d29f69 | 10 | setAccessTokensToServers, |
d0800f76 | 11 | setDefaultAccountAvatar, |
12 | setDefaultChannelAvatar, | |
2c27e704 | 13 | SubscriptionsCommand, |
c3d29f69 | 14 | waitJobs |
bf54587a | 15 | } from '@shared/server-commands' |
06a05d5f | 16 | |
06a05d5f | 17 | describe('Test users subscriptions', function () { |
254d3579 | 18 | let servers: PeerTubeServer[] = [] |
8a19bee1 | 19 | const users: { accessToken: string }[] = [] |
f6eebcb3 | 20 | let video3UUID: string |
06a05d5f | 21 | |
2c27e704 C |
22 | let command: SubscriptionsCommand |
23 | ||
06a05d5f | 24 | before(async function () { |
87c0f718 | 25 | this.timeout(240000) |
06a05d5f | 26 | |
254d3579 | 27 | servers = await createMultipleServers(3) |
06a05d5f C |
28 | |
29 | // Get the access tokens | |
30 | await setAccessTokensToServers(servers) | |
d0800f76 | 31 | await setDefaultChannelAvatar(servers) |
32 | await setDefaultAccountAvatar(servers) | |
06a05d5f C |
33 | |
34 | // Server 1 and server 2 follow each other | |
35 | await doubleFollow(servers[0], servers[1]) | |
36 | ||
6def7d34 C |
37 | for (const server of servers) { |
38 | const user = { username: 'user' + server.serverNumber, password: 'password' } | |
39 | await server.users.create({ username: user.username, password: user.password }) | |
06a05d5f | 40 | |
6def7d34 C |
41 | const accessToken = await server.login.getAccessToken(user) |
42 | users.push({ accessToken }) | |
06a05d5f | 43 | |
6def7d34 C |
44 | const videoName1 = 'video 1-' + server.serverNumber |
45 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) | |
06a05d5f | 46 | |
6def7d34 C |
47 | const videoName2 = 'video 2-' + server.serverNumber |
48 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) | |
06a05d5f C |
49 | } |
50 | ||
51 | await waitJobs(servers) | |
2c27e704 | 52 | |
89d241a7 | 53 | command = servers[0].subscriptions |
06a05d5f C |
54 | }) |
55 | ||
a6b26afc C |
56 | describe('Destinction between server videos and user videos', function () { |
57 | it('Should display videos of server 2 on server 1', async function () { | |
58 | const { total } = await servers[0].videos.list() | |
06a05d5f | 59 | |
a6b26afc C |
60 | expect(total).to.equal(4) |
61 | }) | |
06a05d5f | 62 | |
a6b26afc C |
63 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { |
64 | this.timeout(60000) | |
06a05d5f | 65 | |
2732eeff C |
66 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@' + servers[2].host }) |
67 | await command.add({ token: users[0].accessToken, targetUri: 'root_channel@' + servers[0].host }) | |
06a05d5f | 68 | |
a6b26afc | 69 | await waitJobs(servers) |
06a05d5f | 70 | |
a6b26afc C |
71 | const attributes = { name: 'video server 3 added after follow' } |
72 | const { uuid } = await servers[2].videos.upload({ token: users[2].accessToken, attributes }) | |
73 | video3UUID = uuid | |
06a05d5f | 74 | |
a6b26afc C |
75 | await waitJobs(servers) |
76 | }) | |
06a05d5f | 77 | |
a6b26afc C |
78 | it('Should not display videos of server 3 on server 1', async function () { |
79 | const { total, data } = await servers[0].videos.list() | |
80 | expect(total).to.equal(4) | |
06a05d5f | 81 | |
a6b26afc C |
82 | for (const video of data) { |
83 | expect(video.name).to.not.contain('1-3') | |
84 | expect(video.name).to.not.contain('2-3') | |
85 | expect(video.name).to.not.contain('video server 3 added after follow') | |
86 | } | |
87 | }) | |
06a05d5f C |
88 | }) |
89 | ||
a6b26afc | 90 | describe('Subscription endpoints', function () { |
06a05d5f | 91 | |
a6b26afc C |
92 | it('Should list subscriptions', async function () { |
93 | { | |
94 | const body = await command.list() | |
95 | expect(body.total).to.equal(0) | |
96 | expect(body.data).to.be.an('array') | |
97 | expect(body.data).to.have.lengthOf(0) | |
98 | } | |
06a05d5f | 99 | |
a6b26afc C |
100 | { |
101 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) | |
102 | expect(body.total).to.equal(2) | |
06a05d5f | 103 | |
a6b26afc C |
104 | const subscriptions = body.data |
105 | expect(subscriptions).to.be.an('array') | |
106 | expect(subscriptions).to.have.lengthOf(2) | |
99492dbc | 107 | |
a6b26afc C |
108 | expect(subscriptions[0].name).to.equal('user3_channel') |
109 | expect(subscriptions[1].name).to.equal('root_channel') | |
110 | } | |
111 | }) | |
99492dbc | 112 | |
a6b26afc C |
113 | it('Should get subscription', async function () { |
114 | { | |
2732eeff | 115 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@' + servers[2].host }) |
99492dbc | 116 | |
a6b26afc | 117 | expect(videoChannel.name).to.equal('user3_channel') |
2732eeff | 118 | expect(videoChannel.host).to.equal(servers[2].host) |
a6b26afc C |
119 | expect(videoChannel.displayName).to.equal('Main user3 channel') |
120 | expect(videoChannel.followingCount).to.equal(0) | |
121 | expect(videoChannel.followersCount).to.equal(1) | |
122 | } | |
99492dbc | 123 | |
a6b26afc | 124 | { |
2732eeff | 125 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@' + servers[0].host }) |
f37dc0dd | 126 | |
a6b26afc | 127 | expect(videoChannel.name).to.equal('root_channel') |
2732eeff | 128 | expect(videoChannel.host).to.equal(servers[0].host) |
a6b26afc C |
129 | expect(videoChannel.displayName).to.equal('Main root channel') |
130 | expect(videoChannel.followingCount).to.equal(0) | |
131 | expect(videoChannel.followersCount).to.equal(1) | |
132 | } | |
133 | }) | |
134 | ||
135 | it('Should return the existing subscriptions', async function () { | |
136 | const uris = [ | |
2732eeff C |
137 | 'user3_channel@' + servers[2].host, |
138 | 'root2_channel@' + servers[0].host, | |
139 | 'root_channel@' + servers[0].host, | |
140 | 'user3_channel@' + servers[0].host | |
a6b26afc C |
141 | ] |
142 | ||
143 | const body = await command.exist({ token: users[0].accessToken, uris }) | |
144 | ||
2732eeff C |
145 | expect(body['user3_channel@' + servers[2].host]).to.be.true |
146 | expect(body['root2_channel@' + servers[0].host]).to.be.false | |
147 | expect(body['root_channel@' + servers[0].host]).to.be.true | |
148 | expect(body['user3_channel@' + servers[0].host]).to.be.false | |
a6b26afc C |
149 | }) |
150 | ||
151 | it('Should search among subscriptions', async function () { | |
152 | { | |
153 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' }) | |
154 | expect(body.total).to.equal(1) | |
155 | expect(body.data).to.have.lengthOf(1) | |
156 | } | |
f37dc0dd | 157 | |
a6b26afc C |
158 | { |
159 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' }) | |
160 | expect(body.total).to.equal(0) | |
161 | expect(body.data).to.have.lengthOf(0) | |
162 | } | |
163 | }) | |
f37dc0dd C |
164 | }) |
165 | ||
a6b26afc | 166 | describe('Subscription videos', function () { |
7b390964 | 167 | |
a6b26afc C |
168 | it('Should list subscription videos', async function () { |
169 | { | |
170 | const body = await command.listVideos() | |
171 | expect(body.total).to.equal(0) | |
172 | expect(body.data).to.be.an('array') | |
173 | expect(body.data).to.have.lengthOf(0) | |
174 | } | |
06a05d5f | 175 | |
a6b26afc C |
176 | { |
177 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | |
178 | expect(body.total).to.equal(3) | |
06a05d5f | 179 | |
a6b26afc C |
180 | const videos = body.data |
181 | expect(videos).to.be.an('array') | |
182 | expect(videos).to.have.lengthOf(3) | |
06a05d5f | 183 | |
a6b26afc C |
184 | expect(videos[0].name).to.equal('video 1-3') |
185 | expect(videos[1].name).to.equal('video 2-3') | |
186 | expect(videos[2].name).to.equal('video server 3 added after follow') | |
187 | } | |
188 | }) | |
06a05d5f | 189 | |
a6b26afc C |
190 | it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { |
191 | this.timeout(60000) | |
06a05d5f | 192 | |
a6b26afc C |
193 | const videoName = 'video server 1 added after follow' |
194 | await servers[0].videos.upload({ attributes: { name: videoName } }) | |
06a05d5f | 195 | |
a6b26afc | 196 | await waitJobs(servers) |
06a05d5f | 197 | |
a6b26afc C |
198 | { |
199 | const body = await command.listVideos() | |
200 | expect(body.total).to.equal(0) | |
201 | expect(body.data).to.be.an('array') | |
202 | expect(body.data).to.have.lengthOf(0) | |
203 | } | |
06a05d5f | 204 | |
a6b26afc C |
205 | { |
206 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | |
207 | expect(body.total).to.equal(4) | |
06a05d5f | 208 | |
a6b26afc C |
209 | const videos = body.data |
210 | expect(videos).to.be.an('array') | |
211 | expect(videos).to.have.lengthOf(4) | |
06a05d5f | 212 | |
a6b26afc C |
213 | expect(videos[0].name).to.equal('video 1-3') |
214 | expect(videos[1].name).to.equal('video 2-3') | |
215 | expect(videos[2].name).to.equal('video server 3 added after follow') | |
216 | expect(videos[3].name).to.equal('video server 1 added after follow') | |
217 | } | |
06a05d5f | 218 | |
a6b26afc C |
219 | { |
220 | const { data, total } = await servers[0].videos.list() | |
221 | expect(total).to.equal(5) | |
06a05d5f | 222 | |
a6b26afc C |
223 | for (const video of data) { |
224 | expect(video.name).to.not.contain('1-3') | |
225 | expect(video.name).to.not.contain('2-3') | |
226 | expect(video.name).to.not.contain('video server 3 added after follow') | |
227 | } | |
06a05d5f | 228 | } |
a6b26afc | 229 | }) |
06a05d5f | 230 | |
a6b26afc C |
231 | it('Should have server 1 following server 3 and display server 3 videos', async function () { |
232 | this.timeout(60000) | |
06a05d5f | 233 | |
a6b26afc | 234 | await servers[0].follows.follow({ hosts: [ servers[2].url ] }) |
06a05d5f | 235 | |
a6b26afc | 236 | await waitJobs(servers) |
06a05d5f | 237 | |
a6b26afc C |
238 | const { data, total } = await servers[0].videos.list() |
239 | expect(total).to.equal(8) | |
06a05d5f | 240 | |
a6b26afc C |
241 | const names = [ '1-3', '2-3', 'video server 3 added after follow' ] |
242 | for (const name of names) { | |
243 | const video = data.find(v => v.name.includes(name)) | |
244 | expect(video).to.not.be.undefined | |
245 | } | |
246 | }) | |
06a05d5f | 247 | |
a6b26afc C |
248 | it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { |
249 | this.timeout(60000) | |
06a05d5f | 250 | |
a6b26afc | 251 | await servers[0].follows.unfollow({ target: servers[2] }) |
06a05d5f | 252 | |
a6b26afc | 253 | await waitJobs(servers) |
06a05d5f | 254 | |
a6b26afc C |
255 | const { total, data } = await servers[0].videos.list() |
256 | expect(total).to.equal(5) | |
06a05d5f | 257 | |
a6b26afc C |
258 | for (const video of data) { |
259 | expect(video.name).to.not.contain('1-3') | |
260 | expect(video.name).to.not.contain('2-3') | |
261 | expect(video.name).to.not.contain('video server 3 added after follow') | |
262 | } | |
263 | }) | |
264 | ||
265 | it('Should still list subscription videos', async function () { | |
266 | { | |
267 | const body = await command.listVideos() | |
268 | expect(body.total).to.equal(0) | |
269 | expect(body.data).to.be.an('array') | |
270 | expect(body.data).to.have.lengthOf(0) | |
271 | } | |
06a05d5f | 272 | |
a6b26afc C |
273 | { |
274 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | |
275 | expect(body.total).to.equal(4) | |
06a05d5f | 276 | |
a6b26afc C |
277 | const videos = body.data |
278 | expect(videos).to.be.an('array') | |
279 | expect(videos).to.have.lengthOf(4) | |
06a05d5f | 280 | |
a6b26afc C |
281 | expect(videos[0].name).to.equal('video 1-3') |
282 | expect(videos[1].name).to.equal('video 2-3') | |
283 | expect(videos[2].name).to.equal('video server 3 added after follow') | |
284 | expect(videos[3].name).to.equal('video server 1 added after follow') | |
285 | } | |
286 | }) | |
06a05d5f C |
287 | }) |
288 | ||
a6b26afc | 289 | describe('Existing subscription video update', function () { |
f6eebcb3 | 290 | |
a6b26afc C |
291 | it('Should update a video of server 3 and see the updated video on server 1', async function () { |
292 | this.timeout(30000) | |
f6eebcb3 | 293 | |
a6b26afc | 294 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) |
f6eebcb3 | 295 | |
a6b26afc | 296 | await waitJobs(servers) |
06a05d5f | 297 | |
a6b26afc C |
298 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
299 | expect(body.data[2].name).to.equal('video server 3 added after follow updated') | |
300 | }) | |
06a05d5f C |
301 | }) |
302 | ||
a6b26afc | 303 | describe('Subscription removal', function () { |
06a05d5f | 304 | |
a6b26afc C |
305 | it('Should remove user of server 3 subscription', async function () { |
306 | this.timeout(30000) | |
06a05d5f | 307 | |
2732eeff | 308 | await command.remove({ token: users[0].accessToken, uri: 'user3_channel@' + servers[2].host }) |
f6eebcb3 | 309 | |
a6b26afc C |
310 | await waitJobs(servers) |
311 | }) | |
06a05d5f | 312 | |
a6b26afc C |
313 | it('Should not display its videos anymore', async function () { |
314 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | |
315 | expect(body.total).to.equal(1) | |
06a05d5f | 316 | |
2c27e704 | 317 | const videos = body.data |
06a05d5f | 318 | expect(videos).to.be.an('array') |
a6b26afc | 319 | expect(videos).to.have.lengthOf(1) |
06a05d5f | 320 | |
a6b26afc C |
321 | expect(videos[0].name).to.equal('video server 1 added after follow') |
322 | }) | |
06a05d5f | 323 | |
a6b26afc C |
324 | it('Should remove the root subscription and not display the videos anymore', async function () { |
325 | this.timeout(30000) | |
06a05d5f | 326 | |
2732eeff | 327 | await command.remove({ token: users[0].accessToken, uri: 'root_channel@' + servers[0].host }) |
06a05d5f | 328 | |
a6b26afc | 329 | await waitJobs(servers) |
06a05d5f | 330 | |
a6b26afc C |
331 | { |
332 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) | |
333 | expect(body.total).to.equal(0) | |
06a05d5f | 334 | |
a6b26afc C |
335 | const videos = body.data |
336 | expect(videos).to.be.an('array') | |
337 | expect(videos).to.have.lengthOf(0) | |
338 | } | |
339 | }) | |
06a05d5f | 340 | |
a6b26afc | 341 | it('Should correctly display public videos on server 1', async function () { |
89d241a7 | 342 | const { total, data } = await servers[0].videos.list() |
d23dd9fb | 343 | expect(total).to.equal(5) |
06a05d5f | 344 | |
d23dd9fb | 345 | for (const video of data) { |
06a05d5f C |
346 | expect(video.name).to.not.contain('1-3') |
347 | expect(video.name).to.not.contain('2-3') | |
f6eebcb3 | 348 | expect(video.name).to.not.contain('video server 3 added after follow updated') |
06a05d5f | 349 | } |
a6b26afc | 350 | }) |
06a05d5f C |
351 | }) |
352 | ||
a6b26afc | 353 | describe('Re-follow', function () { |
4beda9e1 | 354 | |
a6b26afc C |
355 | it('Should follow user of server 3 again', async function () { |
356 | this.timeout(60000) | |
4beda9e1 | 357 | |
2732eeff | 358 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@' + servers[2].host }) |
4beda9e1 | 359 | |
a6b26afc | 360 | await waitJobs(servers) |
4beda9e1 | 361 | |
a6b26afc C |
362 | { |
363 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | |
364 | expect(body.total).to.equal(3) | |
4beda9e1 | 365 | |
a6b26afc C |
366 | const videos = body.data |
367 | expect(videos).to.be.an('array') | |
368 | expect(videos).to.have.lengthOf(3) | |
4beda9e1 | 369 | |
a6b26afc C |
370 | expect(videos[0].name).to.equal('video 1-3') |
371 | expect(videos[1].name).to.equal('video 2-3') | |
372 | expect(videos[2].name).to.equal('video server 3 added after follow updated') | |
373 | } | |
4beda9e1 | 374 | |
a6b26afc C |
375 | { |
376 | const { total, data } = await servers[0].videos.list() | |
377 | expect(total).to.equal(5) | |
4beda9e1 | 378 | |
a6b26afc C |
379 | for (const video of data) { |
380 | expect(video.name).to.not.contain('1-3') | |
381 | expect(video.name).to.not.contain('2-3') | |
382 | expect(video.name).to.not.contain('video server 3 added after follow updated') | |
383 | } | |
384 | } | |
385 | }) | |
4beda9e1 | 386 | |
a6b26afc C |
387 | it('Should follow user channels of server 3 by root of server 3', async function () { |
388 | this.timeout(60000) | |
4beda9e1 | 389 | |
a6b26afc | 390 | await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } }) |
4beda9e1 | 391 | |
2732eeff C |
392 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@' + servers[2].host }) |
393 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@' + servers[2].host }) | |
a6b26afc C |
394 | |
395 | await waitJobs(servers) | |
396 | }) | |
4beda9e1 C |
397 | }) |
398 | ||
a6b26afc C |
399 | describe('Followers listing', function () { |
400 | ||
401 | it('Should list user 3 followers', async function () { | |
402 | { | |
403 | const { total, data } = await servers[2].accounts.listFollowers({ | |
404 | token: users[2].accessToken, | |
405 | accountName: 'user3', | |
406 | start: 0, | |
407 | count: 5, | |
408 | sort: 'createdAt' | |
409 | }) | |
410 | ||
411 | expect(total).to.equal(3) | |
412 | expect(data).to.have.lengthOf(3) | |
413 | ||
414 | expect(data[0].following.host).to.equal(servers[2].host) | |
415 | expect(data[0].following.name).to.equal('user3_channel') | |
416 | expect(data[0].follower.host).to.equal(servers[0].host) | |
417 | expect(data[0].follower.name).to.equal('user1') | |
418 | ||
419 | expect(data[1].following.host).to.equal(servers[2].host) | |
420 | expect(data[1].following.name).to.equal('user3_channel') | |
421 | expect(data[1].follower.host).to.equal(servers[2].host) | |
422 | expect(data[1].follower.name).to.equal('root') | |
423 | ||
424 | expect(data[2].following.host).to.equal(servers[2].host) | |
425 | expect(data[2].following.name).to.equal('user3_channel2') | |
426 | expect(data[2].follower.host).to.equal(servers[2].host) | |
427 | expect(data[2].follower.name).to.equal('root') | |
428 | } | |
6def7d34 | 429 | |
a6b26afc C |
430 | { |
431 | const { total, data } = await servers[2].accounts.listFollowers({ | |
432 | token: users[2].accessToken, | |
433 | accountName: 'user3', | |
434 | start: 0, | |
435 | count: 1, | |
436 | sort: '-createdAt' | |
437 | }) | |
438 | ||
439 | expect(total).to.equal(3) | |
440 | expect(data).to.have.lengthOf(1) | |
441 | ||
442 | expect(data[0].following.host).to.equal(servers[2].host) | |
443 | expect(data[0].following.name).to.equal('user3_channel2') | |
444 | expect(data[0].follower.host).to.equal(servers[2].host) | |
445 | expect(data[0].follower.name).to.equal('root') | |
446 | } | |
6def7d34 | 447 | |
a6b26afc C |
448 | { |
449 | const { total, data } = await servers[2].accounts.listFollowers({ | |
450 | token: users[2].accessToken, | |
451 | accountName: 'user3', | |
452 | start: 1, | |
453 | count: 1, | |
454 | sort: '-createdAt' | |
455 | }) | |
456 | ||
457 | expect(total).to.equal(3) | |
458 | expect(data).to.have.lengthOf(1) | |
459 | ||
460 | expect(data[0].following.host).to.equal(servers[2].host) | |
461 | expect(data[0].following.name).to.equal('user3_channel') | |
462 | expect(data[0].follower.host).to.equal(servers[2].host) | |
463 | expect(data[0].follower.name).to.equal('root') | |
464 | } | |
6def7d34 | 465 | |
a6b26afc C |
466 | { |
467 | const { total, data } = await servers[2].accounts.listFollowers({ | |
468 | token: users[2].accessToken, | |
469 | accountName: 'user3', | |
470 | search: 'user1', | |
471 | sort: '-createdAt' | |
472 | }) | |
473 | ||
474 | expect(total).to.equal(1) | |
475 | expect(data).to.have.lengthOf(1) | |
476 | ||
477 | expect(data[0].following.host).to.equal(servers[2].host) | |
478 | expect(data[0].following.name).to.equal('user3_channel') | |
479 | expect(data[0].follower.host).to.equal(servers[0].host) | |
480 | expect(data[0].follower.name).to.equal('user1') | |
481 | } | |
482 | }) | |
483 | ||
484 | it('Should list user3_channel followers', async function () { | |
485 | { | |
486 | const { total, data } = await servers[2].channels.listFollowers({ | |
487 | token: users[2].accessToken, | |
488 | channelName: 'user3_channel', | |
489 | start: 0, | |
490 | count: 5, | |
491 | sort: 'createdAt' | |
492 | }) | |
493 | ||
494 | expect(total).to.equal(2) | |
495 | expect(data).to.have.lengthOf(2) | |
496 | ||
497 | expect(data[0].following.host).to.equal(servers[2].host) | |
498 | expect(data[0].following.name).to.equal('user3_channel') | |
499 | expect(data[0].follower.host).to.equal(servers[0].host) | |
500 | expect(data[0].follower.name).to.equal('user1') | |
501 | ||
502 | expect(data[1].following.host).to.equal(servers[2].host) | |
503 | expect(data[1].following.name).to.equal('user3_channel') | |
504 | expect(data[1].follower.host).to.equal(servers[2].host) | |
505 | expect(data[1].follower.name).to.equal('root') | |
506 | } | |
507 | ||
508 | { | |
509 | const { total, data } = await servers[2].channels.listFollowers({ | |
510 | token: users[2].accessToken, | |
511 | channelName: 'user3_channel', | |
512 | start: 0, | |
513 | count: 1, | |
514 | sort: '-createdAt' | |
515 | }) | |
516 | ||
517 | expect(total).to.equal(2) | |
518 | expect(data).to.have.lengthOf(1) | |
519 | ||
520 | expect(data[0].following.host).to.equal(servers[2].host) | |
521 | expect(data[0].following.name).to.equal('user3_channel') | |
522 | expect(data[0].follower.host).to.equal(servers[2].host) | |
523 | expect(data[0].follower.name).to.equal('root') | |
524 | } | |
525 | ||
526 | { | |
527 | const { total, data } = await servers[2].channels.listFollowers({ | |
528 | token: users[2].accessToken, | |
529 | channelName: 'user3_channel', | |
530 | start: 1, | |
531 | count: 1, | |
532 | sort: '-createdAt' | |
533 | }) | |
534 | ||
535 | expect(total).to.equal(2) | |
536 | expect(data).to.have.lengthOf(1) | |
537 | ||
538 | expect(data[0].following.host).to.equal(servers[2].host) | |
539 | expect(data[0].following.name).to.equal('user3_channel') | |
540 | expect(data[0].follower.host).to.equal(servers[0].host) | |
541 | expect(data[0].follower.name).to.equal('user1') | |
542 | } | |
543 | ||
544 | { | |
545 | const { total, data } = await servers[2].channels.listFollowers({ | |
546 | token: users[2].accessToken, | |
547 | channelName: 'user3_channel', | |
548 | search: 'user1', | |
549 | sort: '-createdAt' | |
550 | }) | |
551 | ||
552 | expect(total).to.equal(1) | |
553 | expect(data).to.have.lengthOf(1) | |
554 | ||
555 | expect(data[0].following.host).to.equal(servers[2].host) | |
556 | expect(data[0].following.name).to.equal('user3_channel') | |
557 | expect(data[0].follower.host).to.equal(servers[0].host) | |
558 | expect(data[0].follower.name).to.equal('user1') | |
559 | } | |
560 | }) | |
6def7d34 C |
561 | }) |
562 | ||
a6b26afc | 563 | describe('Subscription videos privacy', function () { |
6def7d34 | 564 | |
a6b26afc C |
565 | it('Should update video as internal and not see from remote server', async function () { |
566 | this.timeout(30000) | |
6def7d34 | 567 | |
a6b26afc C |
568 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) |
569 | await waitJobs(servers) | |
6def7d34 | 570 | |
a6b26afc C |
571 | { |
572 | const { data } = await command.listVideos({ token: users[0].accessToken }) | |
573 | expect(data.find(v => v.name === 'internal')).to.not.exist | |
574 | } | |
575 | }) | |
576 | ||
577 | it('Should see internal from local user', async function () { | |
6def7d34 | 578 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) |
a6b26afc C |
579 | expect(data.find(v => v.name === 'internal')).to.exist |
580 | }) | |
581 | ||
582 | it('Should update video as private and not see from anyone server', async function () { | |
583 | this.timeout(30000) | |
584 | ||
585 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) | |
586 | await waitJobs(servers) | |
587 | ||
588 | { | |
589 | const { data } = await command.listVideos({ token: users[0].accessToken }) | |
590 | expect(data.find(v => v.name === 'private')).to.not.exist | |
591 | } | |
592 | ||
593 | { | |
594 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | |
595 | expect(data.find(v => v.name === 'private')).to.not.exist | |
596 | } | |
597 | }) | |
6def7d34 C |
598 | }) |
599 | ||
7c3b7976 C |
600 | after(async function () { |
601 | await cleanupTests(servers) | |
06a05d5f C |
602 | }) |
603 | }) |