aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/live.ts47
-rw-r--r--server/tests/api/live/live-constraints.ts6
-rw-r--r--server/tests/api/live/live-fast-restream.ts1
-rw-r--r--server/tests/api/live/live-save-replay.ts264
-rw-r--r--server/tests/api/live/live.ts13
-rw-r--r--server/tests/api/notifications/user-notifications.ts2
-rw-r--r--server/tests/api/object-storage/live.ts1
-rw-r--r--server/tests/api/object-storage/video-static-file-privacy.ts12
-rw-r--r--server/tests/api/videos/video-static-file-privacy.ts12
9 files changed, 272 insertions, 86 deletions
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 2eff9414b..81f10ed8e 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -83,6 +83,7 @@ describe('Test video lives API validator', function () {
83 privacy: VideoPrivacy.PUBLIC, 83 privacy: VideoPrivacy.PUBLIC,
84 channelId, 84 channelId,
85 saveReplay: false, 85 saveReplay: false,
86 replaySettings: undefined,
86 permanentLive: false, 87 permanentLive: false,
87 latencyMode: LiveVideoLatencyMode.DEFAULT 88 latencyMode: LiveVideoLatencyMode.DEFAULT
88 } 89 }
@@ -141,6 +142,12 @@ describe('Test video lives API validator', function () {
141 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 142 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
142 }) 143 })
143 144
145 it('Should fail with a bad privacy for replay settings', async function () {
146 const fields = { ...baseCorrectParams, replaySettings: { privacy: 5 } }
147
148 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
149 })
150
144 it('Should fail with another user channel', async function () { 151 it('Should fail with another user channel', async function () {
145 const user = { 152 const user = {
146 username: 'fake', 153 username: 'fake',
@@ -256,7 +263,7 @@ describe('Test video lives API validator', function () {
256 }) 263 })
257 264
258 it('Should forbid to save replay if not enabled by the admin', async function () { 265 it('Should forbid to save replay if not enabled by the admin', async function () {
259 const fields = { ...baseCorrectParams, saveReplay: true } 266 const fields = { ...baseCorrectParams, saveReplay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }
260 267
261 await server.config.updateCustomSubConfig({ 268 await server.config.updateCustomSubConfig({
262 newConfig: { 269 newConfig: {
@@ -277,7 +284,7 @@ describe('Test video lives API validator', function () {
277 }) 284 })
278 285
279 it('Should allow to save replay if enabled by the admin', async function () { 286 it('Should allow to save replay if enabled by the admin', async function () {
280 const fields = { ...baseCorrectParams, saveReplay: true } 287 const fields = { ...baseCorrectParams, saveReplay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }
281 288
282 await server.config.updateCustomSubConfig({ 289 await server.config.updateCustomSubConfig({
283 newConfig: { 290 newConfig: {
@@ -464,6 +471,39 @@ describe('Test video lives API validator', function () {
464 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 471 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
465 }) 472 })
466 473
474 it('Should fail with a bad privacy for replay settings', async function () {
475 const fields = { saveReplay: true, replaySettings: { privacy: 5 } }
476
477 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
478 })
479
480 it('Should fail with save replay enabled but without replay settings', async function () {
481 await server.config.updateCustomSubConfig({
482 newConfig: {
483 live: {
484 enabled: true,
485 allowReplay: true
486 }
487 }
488 })
489
490 const fields = { saveReplay: true }
491
492 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
493 })
494
495 it('Should fail with save replay disabled and replay settings', async function () {
496 const fields = { saveReplay: false, replaySettings: { privacy: VideoPrivacy.INTERNAL } }
497
498 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
499 })
500
501 it('Should fail with only replay settings when save replay is disabled', async function () {
502 const fields = { replaySettings: { privacy: VideoPrivacy.INTERNAL } }
503
504 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
505 })
506
467 it('Should fail to set latency if the server does not allow it', async function () { 507 it('Should fail to set latency if the server does not allow it', async function () {
468 const fields = { latencyMode: LiveVideoLatencyMode.HIGH_LATENCY } 508 const fields = { latencyMode: LiveVideoLatencyMode.HIGH_LATENCY }
469 509
@@ -474,6 +514,9 @@ describe('Test video lives API validator', function () {
474 await command.update({ videoId: video.id, fields: { saveReplay: false } }) 514 await command.update({ videoId: video.id, fields: { saveReplay: false } })
475 await command.update({ videoId: video.uuid, fields: { saveReplay: false } }) 515 await command.update({ videoId: video.uuid, fields: { saveReplay: false } })
476 await command.update({ videoId: video.shortUUID, fields: { saveReplay: false } }) 516 await command.update({ videoId: video.shortUUID, fields: { saveReplay: false } })
517
518 await command.update({ videoId: video.id, fields: { saveReplay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } } })
519
477 }) 520 })
478 521
479 it('Should fail to update replay status if replay is not allowed on the instance', async function () { 522 it('Should fail to update replay status if replay is not allowed on the instance', async function () {
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts
index c82585a9e..fabb8798d 100644
--- a/server/tests/api/live/live-constraints.ts
+++ b/server/tests/api/live/live-constraints.ts
@@ -24,10 +24,7 @@ describe('Test live constraints', function () {
24 let userAccessToken: string 24 let userAccessToken: string
25 let userChannelId: number 25 let userChannelId: number
26 26
27 async function createLiveWrapper (options: { 27 async function createLiveWrapper (options: { replay: boolean, permanent: boolean }) {
28 replay: boolean
29 permanent: boolean
30 }) {
31 const { replay, permanent } = options 28 const { replay, permanent } = options
32 29
33 const liveAttributes = { 30 const liveAttributes = {
@@ -35,6 +32,7 @@ describe('Test live constraints', function () {
35 channelId: userChannelId, 32 channelId: userChannelId,
36 privacy: VideoPrivacy.PUBLIC, 33 privacy: VideoPrivacy.PUBLIC,
37 saveReplay: replay, 34 saveReplay: replay,
35 replaySettings: options.replay ? { privacy: VideoPrivacy.PUBLIC } : undefined,
38 permanentLive: permanent 36 permanentLive: permanent
39 } 37 }
40 38
diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.ts
index 9e6d10dbd..4e30feaef 100644
--- a/server/tests/api/live/live-fast-restream.ts
+++ b/server/tests/api/live/live-fast-restream.ts
@@ -23,6 +23,7 @@ describe('Fast restream in live', function () {
23 privacy: VideoPrivacy.PUBLIC, 23 privacy: VideoPrivacy.PUBLIC,
24 name: 'my super live', 24 name: 'my super live',
25 saveReplay: options.replay, 25 saveReplay: options.replay,
26 replaySettings: options.replay ? { privacy: VideoPrivacy.PUBLIC } : undefined,
26 permanentLive: options.permanent 27 permanentLive: options.permanent
27 } 28 }
28 29
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 8f17b4566..3a9a84f7e 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -27,7 +27,7 @@ describe('Save replay setting', function () {
27 let liveVideoUUID: string 27 let liveVideoUUID: string
28 let ffmpegCommand: FfmpegCommand 28 let ffmpegCommand: FfmpegCommand
29 29
30 async function createLiveWrapper (options: { permanent: boolean, replay: boolean }) { 30 async function createLiveWrapper (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) {
31 if (liveVideoUUID) { 31 if (liveVideoUUID) {
32 try { 32 try {
33 await servers[0].videos.remove({ id: liveVideoUUID }) 33 await servers[0].videos.remove({ id: liveVideoUUID })
@@ -40,6 +40,7 @@ describe('Save replay setting', function () {
40 privacy: VideoPrivacy.PUBLIC, 40 privacy: VideoPrivacy.PUBLIC,
41 name: 'my super live', 41 name: 'my super live',
42 saveReplay: options.replay, 42 saveReplay: options.replay,
43 replaySettings: options.replaySettings,
43 permanentLive: options.permanent 44 permanentLive: options.permanent
44 } 45 }
45 46
@@ -47,7 +48,7 @@ describe('Save replay setting', function () {
47 return uuid 48 return uuid
48 } 49 }
49 50
50 async function publishLive (options: { permanent: boolean, replay: boolean }) { 51 async function publishLive (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) {
51 liveVideoUUID = await createLiveWrapper(options) 52 liveVideoUUID = await createLiveWrapper(options)
52 53
53 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 54 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
@@ -61,7 +62,7 @@ describe('Save replay setting', function () {
61 return { ffmpegCommand, liveDetails } 62 return { ffmpegCommand, liveDetails }
62 } 63 }
63 64
64 async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean }) { 65 async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) {
65 const { ffmpegCommand, liveDetails } = await publishLive(options) 66 const { ffmpegCommand, liveDetails } = await publishLive(options)
66 67
67 await Promise.all([ 68 await Promise.all([
@@ -76,7 +77,7 @@ describe('Save replay setting', function () {
76 return { liveDetails } 77 return { liveDetails }
77 } 78 }
78 79
79 async function publishLiveAndBlacklist (options: { permanent: boolean, replay: boolean }) { 80 async function publishLiveAndBlacklist (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) {
80 const { ffmpegCommand, liveDetails } = await publishLive(options) 81 const { ffmpegCommand, liveDetails } = await publishLive(options)
81 82
82 await Promise.all([ 83 await Promise.all([
@@ -112,6 +113,13 @@ describe('Save replay setting', function () {
112 } 113 }
113 } 114 }
114 115
116 async function checkVideoPrivacy (videoId: string, privacy: VideoPrivacy) {
117 for (const server of servers) {
118 const video = await server.videos.get({ id: videoId })
119 expect(video.privacy.id).to.equal(privacy)
120 }
121 }
122
115 before(async function () { 123 before(async function () {
116 this.timeout(120000) 124 this.timeout(120000)
117 125
@@ -247,12 +255,13 @@ describe('Save replay setting', function () {
247 it('Should correctly create and federate the "waiting for stream" live', async function () { 255 it('Should correctly create and federate the "waiting for stream" live', async function () {
248 this.timeout(20000) 256 this.timeout(20000)
249 257
250 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true }) 258 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } })
251 259
252 await waitJobs(servers) 260 await waitJobs(servers)
253 261
254 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) 262 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
255 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) 263 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
264 await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC)
256 }) 265 })
257 266
258 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 267 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
@@ -265,6 +274,7 @@ describe('Save replay setting', function () {
265 274
266 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 275 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
267 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) 276 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
277 await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC)
268 }) 278 })
269 279
270 it('Should correctly have saved the live and federated it after the streaming', async function () { 280 it('Should correctly have saved the live and federated it after the streaming', async function () {
@@ -274,6 +284,8 @@ describe('Save replay setting', function () {
274 expect(session.endDate).to.not.exist 284 expect(session.endDate).to.not.exist
275 expect(session.endingProcessed).to.be.false 285 expect(session.endingProcessed).to.be.false
276 expect(session.saveReplay).to.be.true 286 expect(session.saveReplay).to.be.true
287 expect(session.replaySettings).to.exist
288 expect(session.replaySettings.privacy).to.equal(VideoPrivacy.UNLISTED)
277 289
278 await stopFfmpeg(ffmpegCommand) 290 await stopFfmpeg(ffmpegCommand)
279 291
@@ -281,8 +293,9 @@ describe('Save replay setting', function () {
281 await waitJobs(servers) 293 await waitJobs(servers)
282 294
283 // Live has been transcoded 295 // Live has been transcoded
284 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 296 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
285 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) 297 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
298 await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.UNLISTED)
286 }) 299 })
287 300
288 it('Should find the replay live session', async function () { 301 it('Should find the replay live session', async function () {
@@ -296,6 +309,8 @@ describe('Save replay setting', function () {
296 expect(session.error).to.not.exist 309 expect(session.error).to.not.exist
297 expect(session.saveReplay).to.be.true 310 expect(session.saveReplay).to.be.true
298 expect(session.endingProcessed).to.be.true 311 expect(session.endingProcessed).to.be.true
312 expect(session.replaySettings).to.exist
313 expect(session.replaySettings.privacy).to.equal(VideoPrivacy.UNLISTED)
299 314
300 expect(session.replayVideo).to.exist 315 expect(session.replayVideo).to.exist
301 expect(session.replayVideo.id).to.exist 316 expect(session.replayVideo.id).to.exist
@@ -306,13 +321,14 @@ describe('Save replay setting', function () {
306 it('Should update the saved live and correctly federate the updated attributes', async function () { 321 it('Should update the saved live and correctly federate the updated attributes', async function () {
307 this.timeout(30000) 322 this.timeout(30000)
308 323
309 await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated' } }) 324 await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated', privacy: VideoPrivacy.PUBLIC } })
310 await waitJobs(servers) 325 await waitJobs(servers)
311 326
312 for (const server of servers) { 327 for (const server of servers) {
313 const video = await server.videos.get({ id: liveVideoUUID }) 328 const video = await server.videos.get({ id: liveVideoUUID })
314 expect(video.name).to.equal('video updated') 329 expect(video.name).to.equal('video updated')
315 expect(video.isLive).to.be.false 330 expect(video.isLive).to.be.false
331 expect(video.privacy.id).to.equal(VideoPrivacy.PUBLIC)
316 } 332 }
317 }) 333 })
318 334
@@ -323,7 +339,7 @@ describe('Save replay setting', function () {
323 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { 339 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
324 this.timeout(120000) 340 this.timeout(120000)
325 341
326 await publishLiveAndBlacklist({ permanent: false, replay: true }) 342 await publishLiveAndBlacklist({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } })
327 343
328 await checkVideosExist(liveVideoUUID, false) 344 await checkVideosExist(liveVideoUUID, false)
329 345
@@ -338,7 +354,7 @@ describe('Save replay setting', function () {
338 it('Should correctly terminate the stream on delete and delete the video', async function () { 354 it('Should correctly terminate the stream on delete and delete the video', async function () {
339 this.timeout(40000) 355 this.timeout(40000)
340 356
341 await publishLiveAndDelete({ permanent: false, replay: true }) 357 await publishLiveAndDelete({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } })
342 358
343 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) 359 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
344 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) 360 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false })
@@ -348,103 +364,201 @@ describe('Save replay setting', function () {
348 describe('With save replay enabled on permanent live', function () { 364 describe('With save replay enabled on permanent live', function () {
349 let lastReplayUUID: string 365 let lastReplayUUID: string
350 366
351 it('Should correctly create and federate the "waiting for stream" live', async function () { 367 describe('With a first live and its replay', function () {
352 this.timeout(20000)
353 368
354 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true }) 369 it('Should correctly create and federate the "waiting for stream" live', async function () {
370 this.timeout(20000)
355 371
356 await waitJobs(servers) 372 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } })
357 373
358 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200) 374 await waitJobs(servers)
359 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
360 })
361 375
362 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 376 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
363 this.timeout(20000) 377 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
378 await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC)
379 })
364 380
365 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 381 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
366 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 382 this.timeout(20000)
367 383
368 await waitJobs(servers) 384 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
385 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
369 386
370 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 387 await waitJobs(servers)
371 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
372 })
373 388
374 it('Should correctly have saved the live and federated it after the streaming', async function () { 389 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
375 this.timeout(30000) 390 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
391 await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC)
392 })
376 393
377 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) 394 it('Should correctly have saved the live and federated it after the streaming', async function () {
395 this.timeout(30000)
378 396
379 await stopFfmpeg(ffmpegCommand) 397 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
380 398
381 await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID) 399 await stopFfmpeg(ffmpegCommand)
382 await waitJobs(servers)
383 400
384 const video = await findExternalSavedVideo(servers[0], liveDetails) 401 await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID)
385 expect(video).to.exist 402 await waitJobs(servers)
386 403
387 for (const server of servers) { 404 const video = await findExternalSavedVideo(servers[0], liveDetails)
388 await server.videos.get({ id: video.uuid }) 405 expect(video).to.exist
389 }
390 406
391 lastReplayUUID = video.uuid 407 for (const server of servers) {
392 }) 408 await server.videos.get({ id: video.uuid })
409 }
393 410
394 it('Should have appropriate ended session and replay live session', async function () { 411 lastReplayUUID = video.uuid
395 const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID }) 412 })
396 expect(total).to.equal(1)
397 expect(data).to.have.lengthOf(1)
398 413
399 const sessionFromLive = data[0] 414 it('Should have appropriate ended session and replay live session', async function () {
400 const sessionFromReplay = await servers[0].live.getReplaySession({ videoId: lastReplayUUID }) 415 const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID })
416 expect(total).to.equal(1)
417 expect(data).to.have.lengthOf(1)
401 418
402 for (const session of [ sessionFromLive, sessionFromReplay ]) { 419 const sessionFromLive = data[0]
403 expect(session.startDate).to.exist 420 const sessionFromReplay = await servers[0].live.getReplaySession({ videoId: lastReplayUUID })
404 expect(session.endDate).to.exist
405 421
406 expect(session.error).to.not.exist 422 for (const session of [ sessionFromLive, sessionFromReplay ]) {
423 expect(session.startDate).to.exist
424 expect(session.endDate).to.exist
407 425
408 expect(session.replayVideo).to.exist 426 expect(session.replaySettings).to.exist
409 expect(session.replayVideo.id).to.exist 427 expect(session.replaySettings.privacy).to.equal(VideoPrivacy.UNLISTED)
410 expect(session.replayVideo.shortUUID).to.exist
411 expect(session.replayVideo.uuid).to.equal(lastReplayUUID)
412 }
413 })
414 428
415 it('Should have cleaned up the live files', async function () { 429 expect(session.error).to.not.exist
416 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) 430
431 expect(session.replayVideo).to.exist
432 expect(session.replayVideo.id).to.exist
433 expect(session.replayVideo.shortUUID).to.exist
434 expect(session.replayVideo.uuid).to.equal(lastReplayUUID)
435 }
436 })
437
438 it('Should have the first live replay with correct settings', async function () {
439 await checkVideosExist(lastReplayUUID, false, HttpStatusCode.OK_200)
440 await checkVideoState(lastReplayUUID, VideoState.PUBLISHED)
441 await checkVideoPrivacy(lastReplayUUID, VideoPrivacy.UNLISTED)
442 })
417 }) 443 })
418 444
419 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { 445 describe('With a second live and its replay', function () {
420 this.timeout(120000) 446 it('Should update the replay settings', async function () {
447 await servers[0].live.update(
448 { videoId: liveVideoUUID, fields: { replaySettings: { privacy: VideoPrivacy.PUBLIC } } })
449 await waitJobs(servers)
450 const live = await servers[0].live.get({ videoId: liveVideoUUID })
421 451
422 await servers[0].videos.remove({ id: lastReplayUUID }) 452 expect(live.saveReplay).to.be.true
423 const { liveDetails } = await publishLiveAndBlacklist({ permanent: true, replay: true }) 453 expect(live.replaySettings).to.exist
454 expect(live.replaySettings.privacy).to.equal(VideoPrivacy.PUBLIC)
424 455
425 const replay = await findExternalSavedVideo(servers[0], liveDetails) 456 })
426 expect(replay).to.exist
427 457
428 for (const videoId of [ liveVideoUUID, replay.uuid ]) { 458 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
429 await checkVideosExist(videoId, false) 459 this.timeout(20000)
430 460
431 await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 461 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
432 await servers[1].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 462 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
433 }
434 463
435 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) 464 await waitJobs(servers)
436 })
437 465
438 it('Should correctly terminate the stream on delete and not save the video', async function () { 466 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
439 this.timeout(40000) 467 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
468 await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.PUBLIC)
469 })
440 470
441 const { liveDetails } = await publishLiveAndDelete({ permanent: true, replay: true }) 471 it('Should correctly have saved the live and federated it after the streaming', async function () {
472 this.timeout(30000)
473 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
442 474
443 const replay = await findExternalSavedVideo(servers[0], liveDetails) 475 await stopFfmpeg(ffmpegCommand)
444 expect(replay).to.not.exist
445 476
446 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) 477 await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID)
447 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) 478 await waitJobs(servers)
479
480 const video = await findExternalSavedVideo(servers[0], liveDetails)
481 expect(video).to.exist
482
483 for (const server of servers) {
484 await server.videos.get({ id: video.uuid })
485 }
486
487 lastReplayUUID = video.uuid
488 })
489
490 it('Should have appropriate ended session and replay live session', async function () {
491 const { data, total } = await servers[0].live.listSessions({ videoId: liveVideoUUID })
492 expect(total).to.equal(2)
493 expect(data).to.have.lengthOf(2)
494
495 const sessionFromLive = data[1]
496 const sessionFromReplay = await servers[0].live.getReplaySession({ videoId: lastReplayUUID })
497
498 for (const session of [ sessionFromLive, sessionFromReplay ]) {
499 expect(session.startDate).to.exist
500 expect(session.endDate).to.exist
501
502 expect(session.replaySettings).to.exist
503 expect(session.replaySettings.privacy).to.equal(VideoPrivacy.PUBLIC)
504
505 expect(session.error).to.not.exist
506
507 expect(session.replayVideo).to.exist
508 expect(session.replayVideo.id).to.exist
509 expect(session.replayVideo.shortUUID).to.exist
510 expect(session.replayVideo.uuid).to.equal(lastReplayUUID)
511 }
512 })
513
514 it('Should have the first live replay with correct settings', async function () {
515 await checkVideosExist(lastReplayUUID, true, HttpStatusCode.OK_200)
516 await checkVideoState(lastReplayUUID, VideoState.PUBLISHED)
517 await checkVideoPrivacy(lastReplayUUID, VideoPrivacy.PUBLIC)
518 })
519
520 it('Should have cleaned up the live files', async function () {
521 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false })
522 })
523
524 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
525 this.timeout(120000)
526
527 await servers[0].videos.remove({ id: lastReplayUUID })
528 const { liveDetails } = await publishLiveAndBlacklist({
529 permanent: true,
530 replay: true,
531 replaySettings: { privacy: VideoPrivacy.PUBLIC }
532 })
533
534 const replay = await findExternalSavedVideo(servers[0], liveDetails)
535 expect(replay).to.exist
536
537 for (const videoId of [ liveVideoUUID, replay.uuid ]) {
538 await checkVideosExist(videoId, false)
539
540 await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
541 await servers[1].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
542 }
543
544 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false })
545 })
546
547 it('Should correctly terminate the stream on delete and not save the video', async function () {
548 this.timeout(40000)
549
550 const { liveDetails } = await publishLiveAndDelete({
551 permanent: true,
552 replay: true,
553 replaySettings: { privacy: VideoPrivacy.PUBLIC }
554 })
555
556 const replay = await findExternalSavedVideo(servers[0], liveDetails)
557 expect(replay).to.not.exist
558
559 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
560 await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false })
561 })
448 }) 562 })
449 }) 563 })
450 564
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 003cc934f..ceb606af1 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -87,6 +87,7 @@ describe('Test live', function () {
87 commentsEnabled: false, 87 commentsEnabled: false,
88 downloadEnabled: false, 88 downloadEnabled: false,
89 saveReplay: true, 89 saveReplay: true,
90 replaySettings: { privacy: VideoPrivacy.PUBLIC },
90 latencyMode: LiveVideoLatencyMode.SMALL_LATENCY, 91 latencyMode: LiveVideoLatencyMode.SMALL_LATENCY,
91 privacy: VideoPrivacy.PUBLIC, 92 privacy: VideoPrivacy.PUBLIC,
92 previewfile: 'video_short1-preview.webm.jpg', 93 previewfile: 'video_short1-preview.webm.jpg',
@@ -128,6 +129,9 @@ describe('Test live', function () {
128 if (server.url === servers[0].url) { 129 if (server.url === servers[0].url) {
129 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live') 130 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
130 expect(live.streamKey).to.not.be.empty 131 expect(live.streamKey).to.not.be.empty
132
133 expect(live.replaySettings).to.exist
134 expect(live.replaySettings.privacy).to.equal(VideoPrivacy.PUBLIC)
131 } else { 135 } else {
132 expect(live.rtmpUrl).to.not.exist 136 expect(live.rtmpUrl).to.not.exist
133 expect(live.streamKey).to.not.exist 137 expect(live.streamKey).to.not.exist
@@ -196,6 +200,7 @@ describe('Test live', function () {
196 } 200 }
197 201
198 expect(live.saveReplay).to.be.false 202 expect(live.saveReplay).to.be.false
203 expect(live.replaySettings).to.not.exist
199 expect(live.latencyMode).to.equal(LiveVideoLatencyMode.DEFAULT) 204 expect(live.latencyMode).to.equal(LiveVideoLatencyMode.DEFAULT)
200 } 205 }
201 }) 206 })
@@ -366,7 +371,10 @@ describe('Test live', function () {
366 name: 'live video', 371 name: 'live video',
367 channelId: servers[0].store.channel.id, 372 channelId: servers[0].store.channel.id,
368 privacy: VideoPrivacy.PUBLIC, 373 privacy: VideoPrivacy.PUBLIC,
369 saveReplay 374 saveReplay,
375 replaySettings: saveReplay
376 ? { privacy: VideoPrivacy.PUBLIC }
377 : undefined
370 } 378 }
371 379
372 const { uuid } = await commands[0].create({ fields: liveAttributes }) 380 const { uuid } = await commands[0].create({ fields: liveAttributes })
@@ -670,6 +678,9 @@ describe('Test live', function () {
670 channelId: servers[0].store.channel.id, 678 channelId: servers[0].store.channel.id,
671 privacy: VideoPrivacy.PUBLIC, 679 privacy: VideoPrivacy.PUBLIC,
672 saveReplay: options.saveReplay, 680 saveReplay: options.saveReplay,
681 replaySettings: options.saveReplay
682 ? { privacy: VideoPrivacy.PUBLIC }
683 : undefined,
673 permanentLive: options.permanent 684 permanentLive: options.permanent
674 } 685 }
675 686
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index f945cb6a8..7a8a234c2 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -342,6 +342,7 @@ describe('Test user notifications', function () {
342 privacy: VideoPrivacy.PUBLIC, 342 privacy: VideoPrivacy.PUBLIC,
343 channelId: servers[1].store.channel.id, 343 channelId: servers[1].store.channel.id,
344 saveReplay: true, 344 saveReplay: true,
345 replaySettings: { privacy: VideoPrivacy.PUBLIC },
345 permanentLive: false 346 permanentLive: false
346 } 347 }
347 }) 348 })
@@ -367,6 +368,7 @@ describe('Test user notifications', function () {
367 privacy: VideoPrivacy.PUBLIC, 368 privacy: VideoPrivacy.PUBLIC,
368 channelId: servers[1].store.channel.id, 369 channelId: servers[1].store.channel.id,
369 saveReplay: true, 370 saveReplay: true,
371 replaySettings: { privacy: VideoPrivacy.PUBLIC },
370 permanentLive: true 372 permanentLive: true
371 } 373 }
372 }) 374 })
diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts
index 2a3fc4779..588e0a8d7 100644
--- a/server/tests/api/object-storage/live.ts
+++ b/server/tests/api/object-storage/live.ts
@@ -27,6 +27,7 @@ async function createLive (server: PeerTubeServer, permanent: boolean) {
27 privacy: VideoPrivacy.PUBLIC, 27 privacy: VideoPrivacy.PUBLIC,
28 name: 'my super live', 28 name: 'my super live',
29 saveReplay: true, 29 saveReplay: true,
30 replaySettings: { privacy: VideoPrivacy.PUBLIC },
30 permanentLive: permanent 31 permanentLive: permanent
31 } 32 }
32 33
diff --git a/server/tests/api/object-storage/video-static-file-privacy.ts b/server/tests/api/object-storage/video-static-file-privacy.ts
index 869d437d5..930c88543 100644
--- a/server/tests/api/object-storage/video-static-file-privacy.ts
+++ b/server/tests/api/object-storage/video-static-file-privacy.ts
@@ -305,13 +305,21 @@ describe('Object storage for video static file privacy', function () {
305 }) 305 })
306 306
307 { 307 {
308 const { video, live } = await server.live.quickCreate({ saveReplay: true, permanentLive: false, privacy: VideoPrivacy.PRIVATE }) 308 const { video, live } = await server.live.quickCreate({
309 saveReplay: true,
310 permanentLive: false,
311 privacy: VideoPrivacy.PRIVATE
312 })
309 normalLiveId = video.uuid 313 normalLiveId = video.uuid
310 normalLive = live 314 normalLive = live
311 } 315 }
312 316
313 { 317 {
314 const { video, live } = await server.live.quickCreate({ saveReplay: true, permanentLive: true, privacy: VideoPrivacy.PRIVATE }) 318 const { video, live } = await server.live.quickCreate({
319 saveReplay: true,
320 permanentLive: true,
321 privacy: VideoPrivacy.PRIVATE
322 })
315 permanentLiveId = video.uuid 323 permanentLiveId = video.uuid
316 permanentLive = live 324 permanentLive = live
317 } 325 }
diff --git a/server/tests/api/videos/video-static-file-privacy.ts b/server/tests/api/videos/video-static-file-privacy.ts
index 16530884e..2dcfbbc57 100644
--- a/server/tests/api/videos/video-static-file-privacy.ts
+++ b/server/tests/api/videos/video-static-file-privacy.ts
@@ -364,13 +364,21 @@ describe('Test video static file privacy', function () {
364 }) 364 })
365 365
366 { 366 {
367 const { video, live } = await server.live.quickCreate({ saveReplay: true, permanentLive: false, privacy: VideoPrivacy.PRIVATE }) 367 const { video, live } = await server.live.quickCreate({
368 saveReplay: true,
369 permanentLive: false,
370 privacy: VideoPrivacy.PRIVATE
371 })
368 normalLiveId = video.uuid 372 normalLiveId = video.uuid
369 normalLive = live 373 normalLive = live
370 } 374 }
371 375
372 { 376 {
373 const { video, live } = await server.live.quickCreate({ saveReplay: true, permanentLive: true, privacy: VideoPrivacy.PRIVATE }) 377 const { video, live } = await server.live.quickCreate({
378 saveReplay: true,
379 permanentLive: true,
380 privacy: VideoPrivacy.PRIVATE
381 })
374 permanentLiveId = video.uuid 382 permanentLiveId = video.uuid
375 permanentLive = live 383 permanentLive = live
376 } 384 }