diff options
author | Chocobozzz <me@florianbigard.com> | 2022-12-02 14:47:21 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-12-02 15:25:20 +0100 |
commit | 71e3e879c0616882ee82a0e44f8c2e5ee9698a3e (patch) | |
tree | 14452d26d240eb6d44178b76fc2dabda4cfc9428 /server/tests/api | |
parent | 04509c43254dc232c61681ac4bb98e09fd126115 (diff) | |
download | PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.gz PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.zst PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.zip |
Support reinjecting token in private m3u8 playlist
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/object-storage/video-static-file-privacy.ts | 36 | ||||
-rw-r--r-- | server/tests/api/videos/video-static-file-privacy.ts | 61 |
2 files changed, 95 insertions, 2 deletions
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 62edd10ba..71ad35a43 100644 --- a/server/tests/api/object-storage/video-static-file-privacy.ts +++ b/server/tests/api/object-storage/video-static-file-privacy.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { basename } from 'path' | 4 | import { basename } from 'path' |
5 | import { expectStartWith } from '@server/tests/shared' | 5 | import { checkVideoFileTokenReinjection, expectStartWith } from '@server/tests/shared' |
6 | import { areScalewayObjectStorageTestsDisabled, getAllFiles, getHLS } from '@shared/core-utils' | 6 | import { areScalewayObjectStorageTestsDisabled, getAllFiles, getHLS } from '@shared/core-utils' |
7 | import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' | 7 | import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' |
8 | import { | 8 | import { |
@@ -191,6 +191,20 @@ describe('Object storage for video static file privacy', function () { | |||
191 | } | 191 | } |
192 | }) | 192 | }) |
193 | 193 | ||
194 | it('Should reinject video file token', async function () { | ||
195 | this.timeout(120000) | ||
196 | |||
197 | const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: privateVideoUUID }) | ||
198 | |||
199 | await checkVideoFileTokenReinjection({ | ||
200 | server, | ||
201 | videoUUID: privateVideoUUID, | ||
202 | videoFileToken, | ||
203 | resolutions: [ 240, 720 ], | ||
204 | isLive: false | ||
205 | }) | ||
206 | }) | ||
207 | |||
194 | it('Should update public video to private', async function () { | 208 | it('Should update public video to private', async function () { |
195 | this.timeout(60000) | 209 | this.timeout(60000) |
196 | 210 | ||
@@ -315,6 +329,26 @@ describe('Object storage for video static file privacy', function () { | |||
315 | await checkLiveFiles(permanentLive, permanentLiveId) | 329 | await checkLiveFiles(permanentLive, permanentLiveId) |
316 | }) | 330 | }) |
317 | 331 | ||
332 | it('Should reinject video file token in permanent live', async function () { | ||
333 | this.timeout(240000) | ||
334 | |||
335 | const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: permanentLive.rtmpUrl, streamKey: permanentLive.streamKey }) | ||
336 | await server.live.waitUntilPublished({ videoId: permanentLiveId }) | ||
337 | |||
338 | const video = await server.videos.getWithToken({ id: permanentLiveId }) | ||
339 | const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: video.uuid }) | ||
340 | |||
341 | await checkVideoFileTokenReinjection({ | ||
342 | server, | ||
343 | videoUUID: permanentLiveId, | ||
344 | videoFileToken, | ||
345 | resolutions: [ 720 ], | ||
346 | isLive: true | ||
347 | }) | ||
348 | |||
349 | await stopFfmpeg(ffmpegCommand) | ||
350 | }) | ||
351 | |||
318 | it('Should have created a replay of the normal live with a private static path', async function () { | 352 | it('Should have created a replay of the normal live with a private static path', async function () { |
319 | this.timeout(240000) | 353 | this.timeout(240000) |
320 | 354 | ||
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 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { decode } from 'magnet-uri' | 4 | import { decode } from 'magnet-uri' |
5 | import { expectStartWith } from '@server/tests/shared' | 5 | import { checkVideoFileTokenReinjection, expectStartWith } from '@server/tests/shared' |
6 | import { getAllFiles, wait } from '@shared/core-utils' | 6 | import { getAllFiles, wait } from '@shared/core-utils' |
7 | import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' | 7 | import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' |
8 | import { | 8 | import { |
@@ -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 | ||