mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Support reinjecting token in private m3u8 playlist
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { expect } from 'chai'
|
||||
import { basename } from 'path'
|
||||
import { expectStartWith } from '@server/tests/shared'
|
||||
import { checkVideoFileTokenReinjection, expectStartWith } from '@server/tests/shared'
|
||||
import { areScalewayObjectStorageTestsDisabled, getAllFiles, getHLS } from '@shared/core-utils'
|
||||
import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models'
|
||||
import {
|
||||
@@ -191,6 +191,20 @@ describe('Object storage for video static file privacy', function () {
|
||||
}
|
||||
})
|
||||
|
||||
it('Should reinject video file token', async function () {
|
||||
this.timeout(120000)
|
||||
|
||||
const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: privateVideoUUID })
|
||||
|
||||
await checkVideoFileTokenReinjection({
|
||||
server,
|
||||
videoUUID: privateVideoUUID,
|
||||
videoFileToken,
|
||||
resolutions: [ 240, 720 ],
|
||||
isLive: false
|
||||
})
|
||||
})
|
||||
|
||||
it('Should update public video to private', async function () {
|
||||
this.timeout(60000)
|
||||
|
||||
@@ -315,6 +329,26 @@ describe('Object storage for video static file privacy', function () {
|
||||
await checkLiveFiles(permanentLive, permanentLiveId)
|
||||
})
|
||||
|
||||
it('Should reinject video file token in permanent live', async function () {
|
||||
this.timeout(240000)
|
||||
|
||||
const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: permanentLive.rtmpUrl, streamKey: permanentLive.streamKey })
|
||||
await server.live.waitUntilPublished({ videoId: permanentLiveId })
|
||||
|
||||
const video = await server.videos.getWithToken({ id: permanentLiveId })
|
||||
const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: video.uuid })
|
||||
|
||||
await checkVideoFileTokenReinjection({
|
||||
server,
|
||||
videoUUID: permanentLiveId,
|
||||
videoFileToken,
|
||||
resolutions: [ 720 ],
|
||||
isLive: true
|
||||
})
|
||||
|
||||
await stopFfmpeg(ffmpegCommand)
|
||||
})
|
||||
|
||||
it('Should have created a replay of the normal live with a private static path', async function () {
|
||||
this.timeout(240000)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { expect } from 'chai'
|
||||
import { decode } from 'magnet-uri'
|
||||
import { expectStartWith } from '@server/tests/shared'
|
||||
import { checkVideoFileTokenReinjection, expectStartWith } from '@server/tests/shared'
|
||||
import { getAllFiles, wait } from '@shared/core-utils'
|
||||
import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models'
|
||||
import {
|
||||
@@ -248,6 +248,35 @@ describe('Test video static file privacy', function () {
|
||||
await checkVideoFiles({ id: uuid, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken, videoFileToken })
|
||||
})
|
||||
|
||||
it('Should reinject video file token', async function () {
|
||||
this.timeout(120000)
|
||||
|
||||
const { uuid } = await server.videos.quickUpload({ name: 'video', privacy: VideoPrivacy.PRIVATE })
|
||||
|
||||
const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: uuid })
|
||||
await waitJobs([ server ])
|
||||
|
||||
const video = await server.videos.getWithToken({ id: uuid })
|
||||
const hls = video.streamingPlaylists[0]
|
||||
|
||||
{
|
||||
const query = { videoFileToken }
|
||||
const { text } = await makeRawRequest({ url: hls.playlistUrl, query, expectedStatus: HttpStatusCode.OK_200 })
|
||||
|
||||
expect(text).to.not.include(videoFileToken)
|
||||
}
|
||||
|
||||
{
|
||||
await checkVideoFileTokenReinjection({
|
||||
server,
|
||||
videoUUID: uuid,
|
||||
videoFileToken,
|
||||
resolutions: [ 240, 720 ],
|
||||
isLive: false
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('Should be able to access a private video of another user with an admin OAuth token or file token', async function () {
|
||||
this.timeout(120000)
|
||||
|
||||
@@ -360,6 +389,36 @@ describe('Test video static file privacy', function () {
|
||||
await checkLiveFiles(permanentLive, permanentLiveId)
|
||||
})
|
||||
|
||||
it('Should reinject video file token on permanent live', async function () {
|
||||
this.timeout(240000)
|
||||
|
||||
const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: permanentLive.rtmpUrl, streamKey: permanentLive.streamKey })
|
||||
await server.live.waitUntilPublished({ videoId: permanentLiveId })
|
||||
|
||||
const video = await server.videos.getWithToken({ id: permanentLiveId })
|
||||
const videoFileToken = await server.videoToken.getVideoFileToken({ videoId: video.uuid })
|
||||
const hls = video.streamingPlaylists[0]
|
||||
|
||||
{
|
||||
const query = { videoFileToken }
|
||||
const { text } = await makeRawRequest({ url: hls.playlistUrl, query, expectedStatus: HttpStatusCode.OK_200 })
|
||||
|
||||
expect(text).to.not.include(videoFileToken)
|
||||
}
|
||||
|
||||
{
|
||||
await checkVideoFileTokenReinjection({
|
||||
server,
|
||||
videoUUID: permanentLiveId,
|
||||
videoFileToken,
|
||||
resolutions: [ 720 ],
|
||||
isLive: true
|
||||
})
|
||||
}
|
||||
|
||||
await stopFfmpeg(ffmpegCommand)
|
||||
})
|
||||
|
||||
it('Should have created a replay of the normal live with a private static path', async function () {
|
||||
this.timeout(240000)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user