aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-11 13:30:51 +0200
committerChocobozzz <me@florianbigard.com>2022-10-11 13:30:51 +0200
commitcea2fd90ddb3bf57c2fed77128938d12d4c2be6b (patch)
tree667da2c84456849cd4dacf990bc4b02ed14d5861 /server/tests
parent9d4c60dccc8e7e777ad139a82e9f61feda9d21fc (diff)
parenta6b26afc561703cc343f8962906734324b8c2d0c (diff)
downloadPeerTube-cea2fd90ddb3bf57c2fed77128938d12d4c2be6b.tar.gz
PeerTube-cea2fd90ddb3bf57c2fed77128938d12d4c2be6b.tar.zst
PeerTube-cea2fd90ddb3bf57c2fed77128938d12d4c2be6b.zip
Merge branch 'release/4.3.0' into develop
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/follows-moderation.ts360
-rw-r--r--server/tests/api/users/user-subscriptions.ts857
2 files changed, 633 insertions, 584 deletions
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts
index deeaac85a..45e56518a 100644
--- a/server/tests/api/server/follows-moderation.ts
+++ b/server/tests/api/server/follows-moderation.ts
@@ -96,247 +96,273 @@ describe('Test follows moderation', function () {
96 commands = servers.map(s => s.follows) 96 commands = servers.map(s => s.follows)
97 }) 97 })
98 98
99 it('Should have server 1 following server 2', async function () { 99 describe('Default behaviour', function () {
100 this.timeout(30000)
101 100
102 await commands[0].follow({ hosts: [ servers[1].url ] }) 101 it('Should have server 1 following server 2', async function () {
102 this.timeout(30000)
103 103
104 await waitJobs(servers) 104 await commands[0].follow({ hosts: [ servers[1].url ] })
105 })
106 105
107 it('Should have correct follows', async function () { 106 await waitJobs(servers)
108 await checkServer1And2HasFollowers(servers) 107 })
109 })
110 108
111 it('Should remove follower on server 2', async function () { 109 it('Should have correct follows', async function () {
112 this.timeout(10000) 110 await checkServer1And2HasFollowers(servers)
111 })
113 112
114 await commands[1].removeFollower({ follower: servers[0] }) 113 it('Should remove follower on server 2', async function () {
114 this.timeout(10000)
115 115
116 await waitJobs(servers) 116 await commands[1].removeFollower({ follower: servers[0] })
117 })
118 117
119 it('Should not not have follows anymore', async function () { 118 await waitJobs(servers)
120 await checkNoFollowers(servers) 119 })
120
121 it('Should not not have follows anymore', async function () {
122 await checkNoFollowers(servers)
123 })
121 }) 124 })
122 125
123 it('Should disable followers on server 2', async function () { 126 describe('Disabled/Enabled followers', function () {
124 this.timeout(10000)
125 127
126 const subConfig = { 128 it('Should disable followers on server 2', async function () {
127 followers: { 129 this.timeout(10000)
128 instance: { 130
129 enabled: false, 131 const subConfig = {
130 manualApproval: false 132 followers: {
133 instance: {
134 enabled: false,
135 manualApproval: false
136 }
131 } 137 }
132 } 138 }
133 }
134 139
135 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) 140 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
136 141
137 await commands[0].follow({ hosts: [ servers[1].url ] }) 142 await commands[0].follow({ hosts: [ servers[1].url ] })
138 await waitJobs(servers) 143 await waitJobs(servers)
139 144
140 await checkNoFollowers(servers) 145 await checkNoFollowers(servers)
141 }) 146 })
142 147
143 it('Should re enable followers on server 2', async function () { 148 it('Should re enable followers on server 2', async function () {
144 this.timeout(10000) 149 this.timeout(10000)
145 150
146 const subConfig = { 151 const subConfig = {
147 followers: { 152 followers: {
148 instance: { 153 instance: {
149 enabled: true, 154 enabled: true,
150 manualApproval: false 155 manualApproval: false
156 }
151 } 157 }
152 } 158 }
153 }
154 159
155 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) 160 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
156 161
157 await commands[0].follow({ hosts: [ servers[1].url ] }) 162 await commands[0].follow({ hosts: [ servers[1].url ] })
158 await waitJobs(servers) 163 await waitJobs(servers)
159 164
160 await checkServer1And2HasFollowers(servers) 165 await checkServer1And2HasFollowers(servers)
166 })
161 }) 167 })
162 168
163 it('Should manually approve followers', async function () { 169 describe('Manual approbation', function () {
164 this.timeout(20000) 170
171 it('Should manually approve followers', async function () {
172 this.timeout(20000)
165 173
166 await commands[0].unfollow({ target: servers[1] }) 174 await commands[0].unfollow({ target: servers[1] })
167 await waitJobs(servers) 175 await waitJobs(servers)
168 176
169 const subConfig = { 177 const subConfig = {
170 followers: { 178 followers: {
171 instance: { 179 instance: {
172 enabled: true, 180 enabled: true,
173 manualApproval: true 181 manualApproval: true
182 }
174 } 183 }
175 } 184 }
176 }
177
178 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
179 await servers[2].config.updateCustomSubConfig({ newConfig: subConfig })
180
181 await commands[0].follow({ hosts: [ servers[1].url ] })
182 await waitJobs(servers)
183
184 await checkServer1And2HasFollowers(servers, 'pending')
185 })
186
187 it('Should accept a follower', async function () {
188 this.timeout(10000)
189 185
190 await commands[1].acceptFollower({ follower: 'peertube@' + servers[0].host }) 186 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
191 await waitJobs(servers) 187 await servers[2].config.updateCustomSubConfig({ newConfig: subConfig })
192 188
193 await checkServer1And2HasFollowers(servers) 189 await commands[0].follow({ hosts: [ servers[1].url ] })
194 }) 190 await waitJobs(servers)
195 191
196 it('Should reject another follower', async function () { 192 await checkServer1And2HasFollowers(servers, 'pending')
197 this.timeout(20000) 193 })
198 194
199 await commands[0].follow({ hosts: [ servers[2].url ] }) 195 it('Should accept a follower', async function () {
200 await waitJobs(servers) 196 this.timeout(10000)
201 197
202 { 198 await commands[1].acceptFollower({ follower: 'peertube@' + servers[0].host })
203 const body = await commands[0].getFollowings() 199 await waitJobs(servers)
204 expect(body.total).to.equal(2)
205 }
206 200
207 { 201 await checkServer1And2HasFollowers(servers)
208 const body = await commands[1].getFollowers() 202 })
209 expect(body.total).to.equal(1)
210 }
211 203
212 { 204 it('Should reject another follower', async function () {
213 const body = await commands[2].getFollowers() 205 this.timeout(20000)
214 expect(body.total).to.equal(1)
215 }
216 206
217 await commands[2].rejectFollower({ follower: 'peertube@' + servers[0].host }) 207 await commands[0].follow({ hosts: [ servers[2].url ] })
218 await waitJobs(servers) 208 await waitJobs(servers)
219 209
220 { // server 1
221 { 210 {
222 const { data } = await commands[0].getFollowings({ state: 'accepted' }) 211 const body = await commands[0].getFollowings()
223 expect(data).to.have.lengthOf(1) 212 expect(body.total).to.equal(2)
224 } 213 }
225 214
226 { 215 {
227 const { data } = await commands[0].getFollowings({ state: 'rejected' }) 216 const body = await commands[1].getFollowers()
228 expect(data).to.have.lengthOf(1) 217 expect(body.total).to.equal(1)
229 expectStartWith(data[0].following.url, servers[2].url)
230 } 218 }
231 }
232 219
233 { // server 3
234 { 220 {
235 const { data } = await commands[2].getFollowers({ state: 'accepted' }) 221 const body = await commands[2].getFollowers()
236 expect(data).to.have.lengthOf(0) 222 expect(body.total).to.equal(1)
237 } 223 }
238 224
239 { 225 await commands[2].rejectFollower({ follower: 'peertube@' + servers[0].host })
240 const { data } = await commands[2].getFollowers({ state: 'rejected' }) 226 await waitJobs(servers)
241 expect(data).to.have.lengthOf(1) 227
242 expectStartWith(data[0].follower.url, servers[0].url) 228 { // server 1
229 {
230 const { data } = await commands[0].getFollowings({ state: 'accepted' })
231 expect(data).to.have.lengthOf(1)
232 }
233
234 {
235 const { data } = await commands[0].getFollowings({ state: 'rejected' })
236 expect(data).to.have.lengthOf(1)
237 expectStartWith(data[0].following.url, servers[2].url)
238 }
243 } 239 }
244 } 240
241 { // server 3
242 {
243 const { data } = await commands[2].getFollowers({ state: 'accepted' })
244 expect(data).to.have.lengthOf(0)
245 }
246
247 {
248 const { data } = await commands[2].getFollowers({ state: 'rejected' })
249 expect(data).to.have.lengthOf(1)
250 expectStartWith(data[0].follower.url, servers[0].url)
251 }
252 }
253 })
254
255 it('Should still auto accept channel followers', async function () {
256 await commands[0].follow({ handles: [ 'root_channel@' + servers[1].host ] })
257
258 await waitJobs(servers)
259
260 const body = await commands[0].getFollowings()
261 const follow = body.data[0]
262 expect(follow.following.name).to.equal('root_channel')
263 expect(follow.state).to.equal('accepted')
264 })
245 }) 265 })
246 266
247 it('Should not change the follow on refollow with and without auto accept', async function () { 267 describe('Accept/reject state', function () {
248 const run = async () => { 268
249 await commands[0].follow({ hosts: [ servers[2].url ] }) 269 it('Should not change the follow on refollow with and without auto accept', async function () {
270 const run = async () => {
271 await commands[0].follow({ hosts: [ servers[2].url ] })
272 await waitJobs(servers)
273
274 await checkFollows({
275 follower: servers[0],
276 followerState: 'rejected',
277 following: servers[2],
278 followingState: 'rejected'
279 })
280 }
281
282 await servers[2].config.updateExistingSubConfig({ newConfig: { followers: { instance: { manualApproval: false } } } })
283 await run()
284
285 await servers[2].config.updateExistingSubConfig({ newConfig: { followers: { instance: { manualApproval: true } } } })
286 await run()
287 })
288
289 it('Should not change the rejected status on unfollow', async function () {
290 await commands[0].unfollow({ target: servers[2] })
250 await waitJobs(servers) 291 await waitJobs(servers)
251 292
252 await checkFollows({ 293 await checkFollows({
253 follower: servers[0], 294 follower: servers[0],
254 followerState: 'rejected', 295 followerState: 'deleted',
255 following: servers[2], 296 following: servers[2],
256 followingState: 'rejected' 297 followingState: 'rejected'
257 }) 298 })
258 }
259
260 await servers[2].config.updateExistingSubConfig({ newConfig: { followers: { instance: { manualApproval: false } } } })
261 await run()
262
263 await servers[2].config.updateExistingSubConfig({ newConfig: { followers: { instance: { manualApproval: true } } } })
264 await run()
265 })
266
267 it('Should not change the rejected status on unfollow', async function () {
268 await commands[0].unfollow({ target: servers[2] })
269 await waitJobs(servers)
270
271 await checkFollows({
272 follower: servers[0],
273 followerState: 'deleted',
274 following: servers[2],
275 followingState: 'rejected'
276 }) 299 })
277 })
278 300
279 it('Should delete the follower and add again the follower', async function () { 301 it('Should delete the follower and add again the follower', async function () {
280 await commands[2].removeFollower({ follower: servers[0] }) 302 await commands[2].removeFollower({ follower: servers[0] })
281 await waitJobs(servers) 303 await waitJobs(servers)
282 304
283 await commands[0].follow({ hosts: [ servers[2].url ] }) 305 await commands[0].follow({ hosts: [ servers[2].url ] })
284 await waitJobs(servers) 306 await waitJobs(servers)
285 307
286 await checkFollows({ 308 await checkFollows({
287 follower: servers[0], 309 follower: servers[0],
288 followerState: 'pending', 310 followerState: 'pending',
289 following: servers[2], 311 following: servers[2],
290 followingState: 'pending' 312 followingState: 'pending'
313 })
291 }) 314 })
292 })
293 315
294 it('Should be able to reject a previously accepted follower', async function () { 316 it('Should be able to reject a previously accepted follower', async function () {
295 await commands[1].rejectFollower({ follower: 'peertube@' + servers[0].host }) 317 await commands[1].rejectFollower({ follower: 'peertube@' + servers[0].host })
296 await waitJobs(servers) 318 await waitJobs(servers)
297 319
298 await checkFollows({ 320 await checkFollows({
299 follower: servers[0], 321 follower: servers[0],
300 followerState: 'rejected', 322 followerState: 'rejected',
301 following: servers[1], 323 following: servers[1],
302 followingState: 'rejected' 324 followingState: 'rejected'
325 })
303 }) 326 })
304 })
305 327
306 it('Should be able to re accept a previously rejected follower', async function () { 328 it('Should be able to re accept a previously rejected follower', async function () {
307 await commands[1].acceptFollower({ follower: 'peertube@' + servers[0].host }) 329 await commands[1].acceptFollower({ follower: 'peertube@' + servers[0].host })
308 await waitJobs(servers) 330 await waitJobs(servers)
309 331
310 await checkFollows({ 332 await checkFollows({
311 follower: servers[0], 333 follower: servers[0],
312 followerState: 'accepted', 334 followerState: 'accepted',
313 following: servers[1], 335 following: servers[1],
314 followingState: 'accepted' 336 followingState: 'accepted'
337 })
315 }) 338 })
316 }) 339 })
317 340
318 it('Should ignore follow requests of muted servers', async function () { 341 describe('Muted servers', function () {
319 await servers[1].blocklist.addToServerBlocklist({ server: servers[0].host })
320 342
321 await commands[0].unfollow({ target: servers[1] }) 343 it('Should ignore follow requests of muted servers', async function () {
344 await servers[1].blocklist.addToServerBlocklist({ server: servers[0].host })
322 345
323 await waitJobs(servers) 346 await commands[0].unfollow({ target: servers[1] })
324 347
325 await checkFollows({ 348 await waitJobs(servers)
326 follower: servers[0], 349
327 followerState: 'deleted', 350 await checkFollows({
328 following: servers[1], 351 follower: servers[0],
329 followingState: 'deleted' 352 followerState: 'deleted',
330 }) 353 following: servers[1],
354 followingState: 'deleted'
355 })
331 356
332 await commands[0].follow({ hosts: [ servers[1].host ] }) 357 await commands[0].follow({ hosts: [ servers[1].host ] })
333 await waitJobs(servers) 358 await waitJobs(servers)
334 359
335 await checkFollows({ 360 await checkFollows({
336 follower: servers[0], 361 follower: servers[0],
337 followerState: 'rejected', 362 followerState: 'rejected',
338 following: servers[1], 363 following: servers[1],
339 followingState: 'deleted' 364 followingState: 'deleted'
365 })
340 }) 366 })
341 }) 367 })
342 368
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 894a49f98..fbeca7d67 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -53,310 +53,292 @@ describe('Test users subscriptions', function () {
53 command = servers[0].subscriptions 53 command = servers[0].subscriptions
54 }) 54 })
55 55
56 it('Should display videos of server 2 on server 1', async function () { 56 describe('Destinction between server videos and user videos', function () {
57 const { total } = await servers[0].videos.list() 57 it('Should display videos of server 2 on server 1', async function () {
58 const { total } = await servers[0].videos.list()
58 59
59 expect(total).to.equal(4) 60 expect(total).to.equal(4)
60 }) 61 })
61 62
62 it('User of server 1 should follow user of server 3 and root of server 1', async function () { 63 it('User of server 1 should follow user of server 3 and root of server 1', async function () {
63 this.timeout(60000) 64 this.timeout(60000)
64 65
65 await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) 66 await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port })
66 await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) 67 await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
67 68
68 await waitJobs(servers) 69 await waitJobs(servers)
69 70
70 const attributes = { name: 'video server 3 added after follow' } 71 const attributes = { name: 'video server 3 added after follow' }
71 const { uuid } = await servers[2].videos.upload({ token: users[2].accessToken, attributes }) 72 const { uuid } = await servers[2].videos.upload({ token: users[2].accessToken, attributes })
72 video3UUID = uuid 73 video3UUID = uuid
73 74
74 await waitJobs(servers) 75 await waitJobs(servers)
75 }) 76 })
76 77
77 it('Should not display videos of server 3 on server 1', async function () { 78 it('Should not display videos of server 3 on server 1', async function () {
78 const { total, data } = await servers[0].videos.list() 79 const { total, data } = await servers[0].videos.list()
79 expect(total).to.equal(4) 80 expect(total).to.equal(4)
80 81
81 for (const video of data) { 82 for (const video of data) {
82 expect(video.name).to.not.contain('1-3') 83 expect(video.name).to.not.contain('1-3')
83 expect(video.name).to.not.contain('2-3') 84 expect(video.name).to.not.contain('2-3')
84 expect(video.name).to.not.contain('video server 3 added after follow') 85 expect(video.name).to.not.contain('video server 3 added after follow')
85 } 86 }
87 })
86 }) 88 })
87 89
88 it('Should list subscriptions', async function () { 90 describe('Subscription endpoints', function () {
89 {
90 const body = await command.list()
91 expect(body.total).to.equal(0)
92 expect(body.data).to.be.an('array')
93 expect(body.data).to.have.lengthOf(0)
94 }
95 91
96 { 92 it('Should list subscriptions', async function () {
97 const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) 93 {
98 expect(body.total).to.equal(2) 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 }
99 99
100 const subscriptions = body.data 100 {
101 expect(subscriptions).to.be.an('array') 101 const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' })
102 expect(subscriptions).to.have.lengthOf(2) 102 expect(body.total).to.equal(2)
103 103
104 expect(subscriptions[0].name).to.equal('user3_channel') 104 const subscriptions = body.data
105 expect(subscriptions[1].name).to.equal('root_channel') 105 expect(subscriptions).to.be.an('array')
106 } 106 expect(subscriptions).to.have.lengthOf(2)
107 })
108
109 it('Should get subscription', async function () {
110 {
111 const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port })
112 107
113 expect(videoChannel.name).to.equal('user3_channel') 108 expect(subscriptions[0].name).to.equal('user3_channel')
114 expect(videoChannel.host).to.equal('localhost:' + servers[2].port) 109 expect(subscriptions[1].name).to.equal('root_channel')
115 expect(videoChannel.displayName).to.equal('Main user3 channel') 110 }
116 expect(videoChannel.followingCount).to.equal(0) 111 })
117 expect(videoChannel.followersCount).to.equal(1)
118 }
119 112
120 { 113 it('Should get subscription', async function () {
121 const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) 114 {
115 const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port })
122 116
123 expect(videoChannel.name).to.equal('root_channel') 117 expect(videoChannel.name).to.equal('user3_channel')
124 expect(videoChannel.host).to.equal('localhost:' + servers[0].port) 118 expect(videoChannel.host).to.equal('localhost:' + servers[2].port)
125 expect(videoChannel.displayName).to.equal('Main root channel') 119 expect(videoChannel.displayName).to.equal('Main user3 channel')
126 expect(videoChannel.followingCount).to.equal(0) 120 expect(videoChannel.followingCount).to.equal(0)
127 expect(videoChannel.followersCount).to.equal(1) 121 expect(videoChannel.followersCount).to.equal(1)
128 } 122 }
129 })
130 123
131 it('Should return the existing subscriptions', async function () { 124 {
132 const uris = [ 125 const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port })
133 'user3_channel@localhost:' + servers[2].port,
134 'root2_channel@localhost:' + servers[0].port,
135 'root_channel@localhost:' + servers[0].port,
136 'user3_channel@localhost:' + servers[0].port
137 ]
138 126
139 const body = await command.exist({ token: users[0].accessToken, uris }) 127 expect(videoChannel.name).to.equal('root_channel')
128 expect(videoChannel.host).to.equal('localhost:' + servers[0].port)
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 = [
137 'user3_channel@localhost:' + servers[2].port,
138 'root2_channel@localhost:' + servers[0].port,
139 'root_channel@localhost:' + servers[0].port,
140 'user3_channel@localhost:' + servers[0].port
141 ]
142
143 const body = await command.exist({ token: users[0].accessToken, uris })
144
145 expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true
146 expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false
147 expect(body['root_channel@localhost:' + servers[0].port]).to.be.true
148 expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false
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 }
140 157
141 expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true 158 {
142 expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false 159 const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' })
143 expect(body['root_channel@localhost:' + servers[0].port]).to.be.true 160 expect(body.total).to.equal(0)
144 expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false 161 expect(body.data).to.have.lengthOf(0)
162 }
163 })
145 }) 164 })
146 165
147 it('Should search among subscriptions', async function () { 166 describe('Subscription videos', function () {
148 {
149 const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' })
150 expect(body.total).to.equal(1)
151 expect(body.data).to.have.lengthOf(1)
152 }
153 167
154 { 168 it('Should list subscription videos', async function () {
155 const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' }) 169 {
156 expect(body.total).to.equal(0) 170 const body = await command.listVideos()
157 expect(body.data).to.have.lengthOf(0) 171 expect(body.total).to.equal(0)
158 } 172 expect(body.data).to.be.an('array')
159 }) 173 expect(body.data).to.have.lengthOf(0)
160 174 }
161 it('Should list subscription videos', async function () {
162 {
163 const body = await command.listVideos()
164 expect(body.total).to.equal(0)
165 expect(body.data).to.be.an('array')
166 expect(body.data).to.have.lengthOf(0)
167 }
168 175
169 { 176 {
170 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) 177 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
171 expect(body.total).to.equal(3) 178 expect(body.total).to.equal(3)
172 179
173 const videos = body.data 180 const videos = body.data
174 expect(videos).to.be.an('array') 181 expect(videos).to.be.an('array')
175 expect(videos).to.have.lengthOf(3) 182 expect(videos).to.have.lengthOf(3)
176 183
177 expect(videos[0].name).to.equal('video 1-3') 184 expect(videos[0].name).to.equal('video 1-3')
178 expect(videos[1].name).to.equal('video 2-3') 185 expect(videos[1].name).to.equal('video 2-3')
179 expect(videos[2].name).to.equal('video server 3 added after follow') 186 expect(videos[2].name).to.equal('video server 3 added after follow')
180 } 187 }
181 }) 188 })
182 189
183 it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { 190 it('Should upload a video by root on server 1 and see it in the subscription videos', async function () {
184 this.timeout(60000) 191 this.timeout(60000)
185 192
186 const videoName = 'video server 1 added after follow' 193 const videoName = 'video server 1 added after follow'
187 await servers[0].videos.upload({ attributes: { name: videoName } }) 194 await servers[0].videos.upload({ attributes: { name: videoName } })
188 195
189 await waitJobs(servers) 196 await waitJobs(servers)
190 197
191 { 198 {
192 const body = await command.listVideos() 199 const body = await command.listVideos()
193 expect(body.total).to.equal(0) 200 expect(body.total).to.equal(0)
194 expect(body.data).to.be.an('array') 201 expect(body.data).to.be.an('array')
195 expect(body.data).to.have.lengthOf(0) 202 expect(body.data).to.have.lengthOf(0)
196 } 203 }
197 204
198 { 205 {
199 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) 206 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
200 expect(body.total).to.equal(4) 207 expect(body.total).to.equal(4)
201 208
202 const videos = body.data 209 const videos = body.data
203 expect(videos).to.be.an('array') 210 expect(videos).to.be.an('array')
204 expect(videos).to.have.lengthOf(4) 211 expect(videos).to.have.lengthOf(4)
205 212
206 expect(videos[0].name).to.equal('video 1-3') 213 expect(videos[0].name).to.equal('video 1-3')
207 expect(videos[1].name).to.equal('video 2-3') 214 expect(videos[1].name).to.equal('video 2-3')
208 expect(videos[2].name).to.equal('video server 3 added after follow') 215 expect(videos[2].name).to.equal('video server 3 added after follow')
209 expect(videos[3].name).to.equal('video server 1 added after follow') 216 expect(videos[3].name).to.equal('video server 1 added after follow')
210 } 217 }
211 218
212 { 219 {
213 const { data, total } = await servers[0].videos.list() 220 const { data, total } = await servers[0].videos.list()
214 expect(total).to.equal(5) 221 expect(total).to.equal(5)
215 222
216 for (const video of data) { 223 for (const video of data) {
217 expect(video.name).to.not.contain('1-3') 224 expect(video.name).to.not.contain('1-3')
218 expect(video.name).to.not.contain('2-3') 225 expect(video.name).to.not.contain('2-3')
219 expect(video.name).to.not.contain('video server 3 added after follow') 226 expect(video.name).to.not.contain('video server 3 added after follow')
227 }
220 } 228 }
221 } 229 })
222 })
223 230
224 it('Should have server 1 follow server 3 and display server 3 videos', async function () { 231 it('Should have server 1 following server 3 and display server 3 videos', async function () {
225 this.timeout(60000) 232 this.timeout(60000)
226 233
227 await servers[0].follows.follow({ hosts: [ servers[2].url ] }) 234 await servers[0].follows.follow({ hosts: [ servers[2].url ] })
228 235
229 await waitJobs(servers) 236 await waitJobs(servers)
230
231 const { data, total } = await servers[0].videos.list()
232 expect(total).to.equal(8)
233 237
234 const names = [ '1-3', '2-3', 'video server 3 added after follow' ] 238 const { data, total } = await servers[0].videos.list()
235 for (const name of names) { 239 expect(total).to.equal(8)
236 const video = data.find(v => v.name.includes(name))
237 expect(video).to.not.be.undefined
238 }
239 })
240 240
241 it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { 241 const names = [ '1-3', '2-3', 'video server 3 added after follow' ]
242 this.timeout(60000) 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 })
243 247
244 await servers[0].follows.unfollow({ target: servers[2] }) 248 it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
249 this.timeout(60000)
245 250
246 await waitJobs(servers) 251 await servers[0].follows.unfollow({ target: servers[2] })
247 252
248 const { total, data } = await servers[0].videos.list() 253 await waitJobs(servers)
249 expect(total).to.equal(5)
250 254
251 for (const video of data) { 255 const { total, data } = await servers[0].videos.list()
252 expect(video.name).to.not.contain('1-3') 256 expect(total).to.equal(5)
253 expect(video.name).to.not.contain('2-3')
254 expect(video.name).to.not.contain('video server 3 added after follow')
255 }
256 })
257 257
258 it('Should still list subscription videos', async function () { 258 for (const video of data) {
259 { 259 expect(video.name).to.not.contain('1-3')
260 const body = await command.listVideos() 260 expect(video.name).to.not.contain('2-3')
261 expect(body.total).to.equal(0) 261 expect(video.name).to.not.contain('video server 3 added after follow')
262 expect(body.data).to.be.an('array') 262 }
263 expect(body.data).to.have.lengthOf(0) 263 })
264 } 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 }
265 272
266 { 273 {
267 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) 274 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
268 expect(body.total).to.equal(4) 275 expect(body.total).to.equal(4)
269 276
270 const videos = body.data 277 const videos = body.data
271 expect(videos).to.be.an('array') 278 expect(videos).to.be.an('array')
272 expect(videos).to.have.lengthOf(4) 279 expect(videos).to.have.lengthOf(4)
273 280
274 expect(videos[0].name).to.equal('video 1-3') 281 expect(videos[0].name).to.equal('video 1-3')
275 expect(videos[1].name).to.equal('video 2-3') 282 expect(videos[1].name).to.equal('video 2-3')
276 expect(videos[2].name).to.equal('video server 3 added after follow') 283 expect(videos[2].name).to.equal('video server 3 added after follow')
277 expect(videos[3].name).to.equal('video server 1 added after follow') 284 expect(videos[3].name).to.equal('video server 1 added after follow')
278 } 285 }
286 })
279 }) 287 })
280 288
281 it('Should update a video of server 3 and see the updated video on server 1', async function () { 289 describe('Existing subscription video update', function () {
282 this.timeout(30000)
283
284 await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
285
286 await waitJobs(servers)
287 290
288 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) 291 it('Should update a video of server 3 and see the updated video on server 1', async function () {
289 expect(body.data[2].name).to.equal('video server 3 added after follow updated') 292 this.timeout(30000)
290 })
291 293
292 it('Should remove user of server 3 subscription', async function () { 294 await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
293 this.timeout(30000)
294 295
295 await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) 296 await waitJobs(servers)
296 297
297 await waitJobs(servers) 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 })
298 }) 301 })
299 302
300 it('Should not display its videos anymore', async function () { 303 describe('Subscription removal', function () {
301 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
302 expect(body.total).to.equal(1)
303 304
304 const videos = body.data 305 it('Should remove user of server 3 subscription', async function () {
305 expect(videos).to.be.an('array') 306 this.timeout(30000)
306 expect(videos).to.have.lengthOf(1)
307
308 expect(videos[0].name).to.equal('video server 1 added after follow')
309 })
310 307
311 it('Should remove the root subscription and not display the videos anymore', async function () { 308 await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port })
312 this.timeout(30000)
313 309
314 await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) 310 await waitJobs(servers)
311 })
315 312
316 await waitJobs(servers) 313 it('Should not display its videos anymore', async function () {
317 314 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
318 { 315 expect(body.total).to.equal(1)
319 const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' })
320 expect(body.total).to.equal(0)
321 316
322 const videos = body.data 317 const videos = body.data
323 expect(videos).to.be.an('array') 318 expect(videos).to.be.an('array')
324 expect(videos).to.have.lengthOf(0) 319 expect(videos).to.have.lengthOf(1)
325 }
326 })
327 320
328 it('Should correctly display public videos on server 1', async function () { 321 expect(videos[0].name).to.equal('video server 1 added after follow')
329 const { total, data } = await servers[0].videos.list() 322 })
330 expect(total).to.equal(5)
331 323
332 for (const video of data) { 324 it('Should remove the root subscription and not display the videos anymore', async function () {
333 expect(video.name).to.not.contain('1-3') 325 this.timeout(30000)
334 expect(video.name).to.not.contain('2-3')
335 expect(video.name).to.not.contain('video server 3 added after follow updated')
336 }
337 })
338 326
339 it('Should follow user of server 3 again', async function () { 327 await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port })
340 this.timeout(60000)
341 328
342 await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) 329 await waitJobs(servers)
343 330
344 await waitJobs(servers) 331 {
332 const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' })
333 expect(body.total).to.equal(0)
345 334
346 { 335 const videos = body.data
347 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) 336 expect(videos).to.be.an('array')
348 expect(body.total).to.equal(3) 337 expect(videos).to.have.lengthOf(0)
349 338 }
350 const videos = body.data 339 })
351 expect(videos).to.be.an('array')
352 expect(videos).to.have.lengthOf(3)
353
354 expect(videos[0].name).to.equal('video 1-3')
355 expect(videos[1].name).to.equal('video 2-3')
356 expect(videos[2].name).to.equal('video server 3 added after follow updated')
357 }
358 340
359 { 341 it('Should correctly display public videos on server 1', async function () {
360 const { total, data } = await servers[0].videos.list() 342 const { total, data } = await servers[0].videos.list()
361 expect(total).to.equal(5) 343 expect(total).to.equal(5)
362 344
@@ -365,213 +347,254 @@ describe('Test users subscriptions', function () {
365 expect(video.name).to.not.contain('2-3') 347 expect(video.name).to.not.contain('2-3')
366 expect(video.name).to.not.contain('video server 3 added after follow updated') 348 expect(video.name).to.not.contain('video server 3 added after follow updated')
367 } 349 }
368 } 350 })
369 }) 351 })
370 352
371 it('Should follow user channels of server 3 by root of server 3', async function () { 353 describe('Re-follow', function () {
372 this.timeout(60000)
373 354
374 await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } }) 355 it('Should follow user of server 3 again', async function () {
356 this.timeout(60000)
375 357
376 await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) 358 await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port })
377 await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@localhost:' + servers[2].port })
378 359
379 await waitJobs(servers) 360 await waitJobs(servers)
380 })
381 361
382 it('Should list user 3 followers', async function () { 362 {
383 { 363 const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
384 const { total, data } = await servers[2].accounts.listFollowers({ 364 expect(body.total).to.equal(3)
385 token: users[2].accessToken,
386 accountName: 'user3',
387 start: 0,
388 count: 5,
389 sort: 'createdAt'
390 })
391
392 expect(total).to.equal(3)
393 expect(data).to.have.lengthOf(3)
394
395 expect(data[0].following.host).to.equal(servers[2].host)
396 expect(data[0].following.name).to.equal('user3_channel')
397 expect(data[0].follower.host).to.equal(servers[0].host)
398 expect(data[0].follower.name).to.equal('user1')
399
400 expect(data[1].following.host).to.equal(servers[2].host)
401 expect(data[1].following.name).to.equal('user3_channel')
402 expect(data[1].follower.host).to.equal(servers[2].host)
403 expect(data[1].follower.name).to.equal('root')
404
405 expect(data[2].following.host).to.equal(servers[2].host)
406 expect(data[2].following.name).to.equal('user3_channel2')
407 expect(data[2].follower.host).to.equal(servers[2].host)
408 expect(data[2].follower.name).to.equal('root')
409 }
410 365
411 { 366 const videos = body.data
412 const { total, data } = await servers[2].accounts.listFollowers({ 367 expect(videos).to.be.an('array')
413 token: users[2].accessToken, 368 expect(videos).to.have.lengthOf(3)
414 accountName: 'user3',
415 start: 0,
416 count: 1,
417 sort: '-createdAt'
418 })
419
420 expect(total).to.equal(3)
421 expect(data).to.have.lengthOf(1)
422
423 expect(data[0].following.host).to.equal(servers[2].host)
424 expect(data[0].following.name).to.equal('user3_channel2')
425 expect(data[0].follower.host).to.equal(servers[2].host)
426 expect(data[0].follower.name).to.equal('root')
427 }
428 369
429 { 370 expect(videos[0].name).to.equal('video 1-3')
430 const { total, data } = await servers[2].accounts.listFollowers({ 371 expect(videos[1].name).to.equal('video 2-3')
431 token: users[2].accessToken, 372 expect(videos[2].name).to.equal('video server 3 added after follow updated')
432 accountName: 'user3', 373 }
433 start: 1,
434 count: 1,
435 sort: '-createdAt'
436 })
437
438 expect(total).to.equal(3)
439 expect(data).to.have.lengthOf(1)
440
441 expect(data[0].following.host).to.equal(servers[2].host)
442 expect(data[0].following.name).to.equal('user3_channel')
443 expect(data[0].follower.host).to.equal(servers[2].host)
444 expect(data[0].follower.name).to.equal('root')
445 }
446 374
447 { 375 {
448 const { total, data } = await servers[2].accounts.listFollowers({ 376 const { total, data } = await servers[0].videos.list()
449 token: users[2].accessToken, 377 expect(total).to.equal(5)
450 accountName: 'user3',
451 search: 'user1',
452 sort: '-createdAt'
453 })
454
455 expect(total).to.equal(1)
456 expect(data).to.have.lengthOf(1)
457
458 expect(data[0].following.host).to.equal(servers[2].host)
459 expect(data[0].following.name).to.equal('user3_channel')
460 expect(data[0].follower.host).to.equal(servers[0].host)
461 expect(data[0].follower.name).to.equal('user1')
462 }
463 })
464 378
465 it('Should list user3_channel followers', async function () { 379 for (const video of data) {
466 { 380 expect(video.name).to.not.contain('1-3')
467 const { total, data } = await servers[2].channels.listFollowers({ 381 expect(video.name).to.not.contain('2-3')
468 token: users[2].accessToken, 382 expect(video.name).to.not.contain('video server 3 added after follow updated')
469 channelName: 'user3_channel', 383 }
470 start: 0, 384 }
471 count: 5, 385 })
472 sort: 'createdAt'
473 })
474
475 expect(total).to.equal(2)
476 expect(data).to.have.lengthOf(2)
477
478 expect(data[0].following.host).to.equal(servers[2].host)
479 expect(data[0].following.name).to.equal('user3_channel')
480 expect(data[0].follower.host).to.equal(servers[0].host)
481 expect(data[0].follower.name).to.equal('user1')
482
483 expect(data[1].following.host).to.equal(servers[2].host)
484 expect(data[1].following.name).to.equal('user3_channel')
485 expect(data[1].follower.host).to.equal(servers[2].host)
486 expect(data[1].follower.name).to.equal('root')
487 }
488 386
489 { 387 it('Should follow user channels of server 3 by root of server 3', async function () {
490 const { total, data } = await servers[2].channels.listFollowers({ 388 this.timeout(60000)
491 token: users[2].accessToken,
492 channelName: 'user3_channel',
493 start: 0,
494 count: 1,
495 sort: '-createdAt'
496 })
497
498 expect(total).to.equal(2)
499 expect(data).to.have.lengthOf(1)
500
501 expect(data[0].following.host).to.equal(servers[2].host)
502 expect(data[0].following.name).to.equal('user3_channel')
503 expect(data[0].follower.host).to.equal(servers[2].host)
504 expect(data[0].follower.name).to.equal('root')
505 }
506 389
507 { 390 await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } })
508 const { total, data } = await servers[2].channels.listFollowers({
509 token: users[2].accessToken,
510 channelName: 'user3_channel',
511 start: 1,
512 count: 1,
513 sort: '-createdAt'
514 })
515
516 expect(total).to.equal(2)
517 expect(data).to.have.lengthOf(1)
518
519 expect(data[0].following.host).to.equal(servers[2].host)
520 expect(data[0].following.name).to.equal('user3_channel')
521 expect(data[0].follower.host).to.equal(servers[0].host)
522 expect(data[0].follower.name).to.equal('user1')
523 }
524 391
525 { 392 await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port })
526 const { total, data } = await servers[2].channels.listFollowers({ 393 await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@localhost:' + servers[2].port })
527 token: users[2].accessToken, 394
528 channelName: 'user3_channel', 395 await waitJobs(servers)
529 search: 'user1', 396 })
530 sort: '-createdAt'
531 })
532
533 expect(total).to.equal(1)
534 expect(data).to.have.lengthOf(1)
535
536 expect(data[0].following.host).to.equal(servers[2].host)
537 expect(data[0].following.name).to.equal('user3_channel')
538 expect(data[0].follower.host).to.equal(servers[0].host)
539 expect(data[0].follower.name).to.equal('user1')
540 }
541 }) 397 })
542 398
543 it('Should update video as internal and not see from remote server', async function () { 399 describe('Followers listing', function () {
544 this.timeout(30000) 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 }
545 429
546 await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) 430 {
547 await waitJobs(servers) 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 }
548 447
549 { 448 {
550 const { data } = await command.listVideos({ token: users[0].accessToken }) 449 const { total, data } = await servers[2].accounts.listFollowers({
551 expect(data.find(v => v.name === 'internal')).to.not.exist 450 token: users[2].accessToken,
552 } 451 accountName: 'user3',
553 }) 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 }
554 465
555 it('Should see internal from local user', async function () { 466 {
556 const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) 467 const { total, data } = await servers[2].accounts.listFollowers({
557 expect(data.find(v => v.name === 'internal')).to.exist 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 })
558 }) 561 })
559 562
560 it('Should update video as private and not see from anyone server', async function () { 563 describe('Subscription videos privacy', function () {
561 this.timeout(30000)
562 564
563 await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) 565 it('Should update video as internal and not see from remote server', async function () {
564 await waitJobs(servers) 566 this.timeout(30000)
565 567
566 { 568 await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } })
567 const { data } = await command.listVideos({ token: users[0].accessToken }) 569 await waitJobs(servers)
568 expect(data.find(v => v.name === 'private')).to.not.exist
569 }
570 570
571 { 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 () {
572 const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) 578 const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken })
573 expect(data.find(v => v.name === 'private')).to.not.exist 579 expect(data.find(v => v.name === 'internal')).to.exist
574 } 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 })
575 }) 598 })
576 599
577 after(async function () { 600 after(async function () {