From 1022e273092f539c0b77a5cf6411b06c74fd15e5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 1 Sep 2023 16:47:25 +0200 Subject: Fix live replay privacy change --- packages/tests/src/api/live/index.ts | 1 + packages/tests/src/api/live/live-privacy-update.ts | 83 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 packages/tests/src/api/live/live-privacy-update.ts (limited to 'packages/tests/src/api/live') diff --git a/packages/tests/src/api/live/index.ts b/packages/tests/src/api/live/index.ts index e61e6c611..bb5177d95 100644 --- a/packages/tests/src/api/live/index.ts +++ b/packages/tests/src/api/live/index.ts @@ -1,6 +1,7 @@ import './live-constraints.js' import './live-fast-restream.js' import './live-socket-messages.js' +import './live-privacy-update.js' import './live-permanent.js' import './live-rtmps.js' import './live-save-replay.js' diff --git a/packages/tests/src/api/live/live-privacy-update.ts b/packages/tests/src/api/live/live-privacy-update.ts new file mode 100644 index 000000000..ff12ff3e3 --- /dev/null +++ b/packages/tests/src/api/live/live-privacy-update.ts @@ -0,0 +1,83 @@ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ + +import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@peertube/peertube-models' +import { + cleanupTests, createSingleServer, makeRawRequest, + PeerTubeServer, + setAccessTokensToServers, + setDefaultVideoChannel, + stopFfmpeg, + waitJobs, + waitUntilLivePublishedOnAllServers, + waitUntilLiveReplacedByReplayOnAllServers +} from '@peertube/peertube-server-commands' + +async function testVideoFiles (server: PeerTubeServer, uuid: string) { + const video = await server.videos.getWithToken({ id: uuid }) + + const expectedStatus = HttpStatusCode.OK_200 + + await makeRawRequest({ url: video.streamingPlaylists[0].playlistUrl, token: server.accessToken, expectedStatus }) + await makeRawRequest({ url: video.streamingPlaylists[0].segmentsSha256Url, token: server.accessToken, expectedStatus }) +} + +describe('Live privacy update', function () { + let server: PeerTubeServer + + before(async function () { + this.timeout(120000) + + server = await createSingleServer(1) + + await setAccessTokensToServers([ server ]) + await setDefaultVideoChannel([ server ]) + + await server.config.enableMinimumTranscoding() + await server.config.enableLive({ allowReplay: true, transcoding: true, resolutions: 'min' }) + }) + + describe('Normal live', function () { + let uuid: string + + it('Should create a public live with private replay', async function () { + this.timeout(120000) + + const fields: LiveVideoCreate = { + name: 'live', + privacy: VideoPrivacy.PUBLIC, + permanentLive: false, + replaySettings: { privacy: VideoPrivacy.PRIVATE }, + saveReplay: true, + channelId: server.store.channel.id + } + + const video = await server.live.create({ fields }) + uuid = video.uuid + + const ffmpegCommand = await server.live.sendRTMPStreamInVideo({ videoId: uuid }) + await waitUntilLivePublishedOnAllServers([ server ], uuid) + await stopFfmpeg(ffmpegCommand) + + await waitUntilLiveReplacedByReplayOnAllServers([ server ], uuid) + await waitJobs([ server ]) + + await testVideoFiles(server, uuid) + }) + + it('Should update the replay to public and re-update it to private', async function () { + this.timeout(120000) + + await server.videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) + await waitJobs([ server ]) + await testVideoFiles(server, uuid) + + await server.videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PRIVATE } }) + await waitJobs([ server ]) + await testVideoFiles(server, uuid) + }) + }) + + after(async function () { + await cleanupTests([ server ]) + }) +}) -- cgit v1.2.3