aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-12-02 14:47:21 +0100
committerChocobozzz <me@florianbigard.com>2022-12-02 15:25:20 +0100
commit71e3e879c0616882ee82a0e44f8c2e5ee9698a3e (patch)
tree14452d26d240eb6d44178b76fc2dabda4cfc9428 /server/tests/api/videos
parent04509c43254dc232c61681ac4bb98e09fd126115 (diff)
downloadPeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.gz
PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.zst
PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.zip
Support reinjecting token in private m3u8 playlist
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-static-file-privacy.ts61
1 files changed, 60 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-static-file-privacy.ts b/server/tests/api/videos/video-static-file-privacy.ts
index eaaed5aad..ef0774b41 100644
--- a/server/tests/api/videos/video-static-file-privacy.ts
+++ b/server/tests/api/videos/video-static-file-privacy.ts
@@ -2,7 +2,7 @@
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { decode } from 'magnet-uri' 4import { decode } from 'magnet-uri'
5import { expectStartWith } from '@server/tests/shared' 5import { checkVideoFileTokenReinjection, expectStartWith } from '@server/tests/shared'
6import { getAllFiles, wait } from '@shared/core-utils' 6import { getAllFiles, wait } from '@shared/core-utils'
7import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' 7import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models'
8import { 8import {
@@ -248,6 +248,35 @@ describe('Test video static file privacy', function () {
248 await checkVideoFiles({ id: uuid, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken, videoFileToken }) 248 await checkVideoFiles({ id: uuid, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken, videoFileToken })
249 }) 249 })
250 250
251 it('Should reinject video file token', async function () {
252 this.timeout(120000)
253
254 const { uuid } = await server.videos.quickUpload({ name: 'video', privacy: VideoPrivacy.PRIVATE })
255
256 const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: uuid })
257 await waitJobs([ server ])
258
259 const video = await server.videos.getWithToken({ id: uuid })
260 const hls = video.streamingPlaylists[0]
261
262 {
263 const query = { videoFileToken }
264 const { text } = await makeRawRequest({ url: hls.playlistUrl, query, expectedStatus: HttpStatusCode.OK_200 })
265
266 expect(text).to.not.include(videoFileToken)
267 }
268
269 {
270 await checkVideoFileTokenReinjection({
271 server,
272 videoUUID: uuid,
273 videoFileToken,
274 resolutions: [ 240, 720 ],
275 isLive: false
276 })
277 }
278 })
279
251 it('Should be able to access a private video of another user with an admin OAuth token or file token', async function () { 280 it('Should be able to access a private video of another user with an admin OAuth token or file token', async function () {
252 this.timeout(120000) 281 this.timeout(120000)
253 282
@@ -360,6 +389,36 @@ describe('Test video static file privacy', function () {
360 await checkLiveFiles(permanentLive, permanentLiveId) 389 await checkLiveFiles(permanentLive, permanentLiveId)
361 }) 390 })
362 391
392 it('Should reinject video file token on permanent live', async function () {
393 this.timeout(240000)
394
395 const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: permanentLive.rtmpUrl, streamKey: permanentLive.streamKey })
396 await server.live.waitUntilPublished({ videoId: permanentLiveId })
397
398 const video = await server.videos.getWithToken({ id: permanentLiveId })
399 const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: video.uuid })
400 const hls = video.streamingPlaylists[0]
401
402 {
403 const query = { videoFileToken }
404 const { text } = await makeRawRequest({ url: hls.playlistUrl, query, expectedStatus: HttpStatusCode.OK_200 })
405
406 expect(text).to.not.include(videoFileToken)
407 }
408
409 {
410 await checkVideoFileTokenReinjection({
411 server,
412 videoUUID: permanentLiveId,
413 videoFileToken,
414 resolutions: [ 720 ],
415 isLive: true
416 })
417 }
418
419 await stopFfmpeg(ffmpegCommand)
420 })
421
363 it('Should have created a replay of the normal live with a private static path', async function () { 422 it('Should have created a replay of the normal live with a private static path', async function () {
364 this.timeout(240000) 423 this.timeout(240000)
365 424