diff options
author | Wicklow <123956049+wickloww@users.noreply.github.com> | 2023-03-31 07:12:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-31 09:12:21 +0200 |
commit | 05a60d85997c108d39bcfb14f1ffd4c74f8b1e93 (patch) | |
tree | 5041a95ef945620a17f25ba934064b41f6bb00b7 /server/tests/api/check-params/live.ts | |
parent | ebd61437c1ec92bea9772924c7051cb00d71f778 (diff) | |
download | PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.gz PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.zst PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.zip |
Feature/Add replay privacy (#5692)
* Add replay settings feature
* Fix replay settings behaviour
* Fix tests
* Fix tests
* Fix tests
* Update openapi doc and fix tests
* Add tests and fix code
* Models correction
* Add migration and update controller and middleware
* Add check params tests
* Fix video live middleware
* Updated code based on review comments
Diffstat (limited to 'server/tests/api/check-params/live.ts')
-rw-r--r-- | server/tests/api/check-params/live.ts | 47 |
1 files changed, 45 insertions, 2 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 () { |