diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/activitypub/client.ts | 98 | ||||
-rw-r--r-- | server/tests/api/check-params/abuses.ts | 2 | ||||
-rw-r--r-- | server/tests/api/check-params/live.ts | 40 | ||||
-rw-r--r-- | server/tests/api/check-params/redundancy.ts | 38 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 12 | ||||
-rw-r--r-- | server/tests/api/check-params/video-blacklist.ts | 12 | ||||
-rw-r--r-- | server/tests/api/check-params/video-captions.ts | 38 | ||||
-rw-r--r-- | server/tests/api/check-params/video-comments.ts | 31 | ||||
-rw-r--r-- | server/tests/api/check-params/video-playlists.ts | 64 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 52 | ||||
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 30 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 10 | ||||
-rw-r--r-- | server/tests/api/server/handle-down.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 71 | ||||
-rw-r--r-- | server/tests/api/videos/video-privacy.ts | 351 |
15 files changed, 494 insertions, 357 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index b6c538e19..be94e219c 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts | |||
@@ -1,23 +1,65 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
9 | createVideoPlaylist, | ||
7 | doubleFollow, | 10 | doubleFollow, |
8 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
9 | makeActivityPubGetRequest, | 12 | makeActivityPubGetRequest, |
10 | ServerInfo, | 13 | ServerInfo, |
11 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
12 | uploadVideo | 15 | setDefaultVideoChannel, |
16 | uploadVideoAndGetId | ||
13 | } from '../../../../shared/extra-utils' | 17 | } from '../../../../shared/extra-utils' |
14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
15 | 18 | ||
16 | const expect = chai.expect | 19 | const expect = chai.expect |
17 | 20 | ||
18 | describe('Test activitypub', function () { | 21 | describe('Test activitypub', function () { |
19 | let servers: ServerInfo[] = [] | 22 | let servers: ServerInfo[] = [] |
20 | let videoUUID: string | 23 | let video: { id: number, uuid: string, shortUUID: string } |
24 | let playlist: { id: number, uuid: string, shortUUID: string } | ||
25 | |||
26 | async function testAccount (path: string) { | ||
27 | const res = await makeActivityPubGetRequest(servers[0].url, path) | ||
28 | const object = res.body | ||
29 | |||
30 | expect(object.type).to.equal('Person') | ||
31 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') | ||
32 | expect(object.name).to.equal('root') | ||
33 | expect(object.preferredUsername).to.equal('root') | ||
34 | } | ||
35 | |||
36 | async function testChannel (path: string) { | ||
37 | const res = await makeActivityPubGetRequest(servers[0].url, path) | ||
38 | const object = res.body | ||
39 | |||
40 | expect(object.type).to.equal('Group') | ||
41 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-channels/root_channel') | ||
42 | expect(object.name).to.equal('Main root channel') | ||
43 | expect(object.preferredUsername).to.equal('root_channel') | ||
44 | } | ||
45 | |||
46 | async function testVideo (path: string) { | ||
47 | const res = await makeActivityPubGetRequest(servers[0].url, path) | ||
48 | const object = res.body | ||
49 | |||
50 | expect(object.type).to.equal('Video') | ||
51 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) | ||
52 | expect(object.name).to.equal('video') | ||
53 | } | ||
54 | |||
55 | async function testPlaylist (path: string) { | ||
56 | const res = await makeActivityPubGetRequest(servers[0].url, path) | ||
57 | const object = res.body | ||
58 | |||
59 | expect(object.type).to.equal('Playlist') | ||
60 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-playlists/' + playlist.uuid) | ||
61 | expect(object.name).to.equal('playlist') | ||
62 | } | ||
21 | 63 | ||
22 | before(async function () { | 64 | before(async function () { |
23 | this.timeout(30000) | 65 | this.timeout(30000) |
@@ -25,38 +67,56 @@ describe('Test activitypub', function () { | |||
25 | servers = await flushAndRunMultipleServers(2) | 67 | servers = await flushAndRunMultipleServers(2) |
26 | 68 | ||
27 | await setAccessTokensToServers(servers) | 69 | await setAccessTokensToServers(servers) |
70 | await setDefaultVideoChannel(servers) | ||
28 | 71 | ||
29 | { | 72 | { |
30 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) | 73 | video = await uploadVideoAndGetId({ server: servers[0], videoName: 'video' }) |
31 | videoUUID = res.body.video.uuid | 74 | } |
75 | |||
76 | { | ||
77 | const playlistAttrs = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id } | ||
78 | const resCreate = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs }) | ||
79 | playlist = resCreate.body.videoPlaylist | ||
32 | } | 80 | } |
33 | 81 | ||
34 | await doubleFollow(servers[0], servers[1]) | 82 | await doubleFollow(servers[0], servers[1]) |
35 | }) | 83 | }) |
36 | 84 | ||
37 | it('Should return the account object', async function () { | 85 | it('Should return the account object', async function () { |
38 | const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root') | 86 | await testAccount('/accounts/root') |
39 | const object = res.body | 87 | await testAccount('/a/root') |
88 | }) | ||
40 | 89 | ||
41 | expect(object.type).to.equal('Person') | 90 | it('Should return the channel object', async function () { |
42 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') | 91 | await testChannel('/video-channels/root_channel') |
43 | expect(object.name).to.equal('root') | 92 | await testChannel('/c/root_channel') |
44 | expect(object.preferredUsername).to.equal('root') | ||
45 | }) | 93 | }) |
46 | 94 | ||
47 | it('Should return the video object', async function () { | 95 | it('Should return the video object', async function () { |
48 | const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID) | 96 | await testVideo('/videos/watch/' + video.id) |
49 | const object = res.body | 97 | await testVideo('/videos/watch/' + video.uuid) |
98 | await testVideo('/videos/watch/' + video.shortUUID) | ||
99 | await testVideo('/w/' + video.id) | ||
100 | await testVideo('/w/' + video.uuid) | ||
101 | await testVideo('/w/' + video.shortUUID) | ||
102 | }) | ||
50 | 103 | ||
51 | expect(object.type).to.equal('Video') | 104 | it('Should return the playlist object', async function () { |
52 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) | 105 | await testPlaylist('/video-playlists/' + playlist.id) |
53 | expect(object.name).to.equal('video') | 106 | await testPlaylist('/video-playlists/' + playlist.uuid) |
107 | await testPlaylist('/video-playlists/' + playlist.shortUUID) | ||
108 | await testPlaylist('/w/p/' + playlist.id) | ||
109 | await testPlaylist('/w/p/' + playlist.uuid) | ||
110 | await testPlaylist('/w/p/' + playlist.shortUUID) | ||
111 | await testPlaylist('/videos/watch/playlist/' + playlist.id) | ||
112 | await testPlaylist('/videos/watch/playlist/' + playlist.uuid) | ||
113 | await testPlaylist('/videos/watch/playlist/' + playlist.shortUUID) | ||
54 | }) | 114 | }) |
55 | 115 | ||
56 | it('Should redirect to the origin video object', async function () { | 116 | it('Should redirect to the origin video object', async function () { |
57 | const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302) | 117 | const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + video.uuid, HttpStatusCode.FOUND_302) |
58 | 118 | ||
59 | expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) | 119 | expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) |
60 | }) | 120 | }) |
61 | 121 | ||
62 | after(async function () { | 122 | after(async function () { |
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index 2aa09334c..2054776cc 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts | |||
@@ -258,7 +258,7 @@ describe('Test abuses API validators', function () { | |||
258 | }) | 258 | }) |
259 | 259 | ||
260 | it('Should succeed with the correct parameters (basic)', async function () { | 260 | it('Should succeed with the correct parameters (basic)', async function () { |
261 | const fields: AbuseCreate = { video: { id: server.video.id }, reason: 'my super reason' } | 261 | const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' } |
262 | 262 | ||
263 | const res = await makePostBodyRequest({ | 263 | const res = await makePostBodyRequest({ |
264 | url: server.url, | 264 | url: server.url, |
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 32233c9da..933d8abf2 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { LiveVideo, VideoPrivacy } from '@shared/models' | 5 | import { LiveVideo, VideoCreateResult, VideoPrivacy } from '@shared/models' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
7 | import { | 7 | import { |
8 | buildAbsoluteFixturePath, | 8 | buildAbsoluteFixturePath, |
@@ -31,7 +31,7 @@ describe('Test video lives API validator', function () { | |||
31 | let server: ServerInfo | 31 | let server: ServerInfo |
32 | let userAccessToken = '' | 32 | let userAccessToken = '' |
33 | let channelId: number | 33 | let channelId: number |
34 | let videoId: number | 34 | let video: VideoCreateResult |
35 | let videoIdNotLive: number | 35 | let videoIdNotLive: number |
36 | 36 | ||
37 | // --------------------------------------------------------------- | 37 | // --------------------------------------------------------------- |
@@ -230,7 +230,7 @@ describe('Test video lives API validator', function () { | |||
230 | statusCodeExpected: HttpStatusCode.OK_200 | 230 | statusCodeExpected: HttpStatusCode.OK_200 |
231 | }) | 231 | }) |
232 | 232 | ||
233 | videoId = res.body.video.id | 233 | video = res.body.video |
234 | }) | 234 | }) |
235 | 235 | ||
236 | it('Should forbid if live is disabled', async function () { | 236 | it('Should forbid if live is disabled', async function () { |
@@ -326,15 +326,15 @@ describe('Test video lives API validator', function () { | |||
326 | describe('When getting live information', function () { | 326 | describe('When getting live information', function () { |
327 | 327 | ||
328 | it('Should fail without access token', async function () { | 328 | it('Should fail without access token', async function () { |
329 | await getLive(server.url, '', videoId, HttpStatusCode.UNAUTHORIZED_401) | 329 | await getLive(server.url, '', video.id, HttpStatusCode.UNAUTHORIZED_401) |
330 | }) | 330 | }) |
331 | 331 | ||
332 | it('Should fail with a bad access token', async function () { | 332 | it('Should fail with a bad access token', async function () { |
333 | await getLive(server.url, 'toto', videoId, HttpStatusCode.UNAUTHORIZED_401) | 333 | await getLive(server.url, 'toto', video.id, HttpStatusCode.UNAUTHORIZED_401) |
334 | }) | 334 | }) |
335 | 335 | ||
336 | it('Should fail with access token of another user', async function () { | 336 | it('Should fail with access token of another user', async function () { |
337 | await getLive(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) | 337 | await getLive(server.url, userAccessToken, video.id, HttpStatusCode.FORBIDDEN_403) |
338 | }) | 338 | }) |
339 | 339 | ||
340 | it('Should fail with a bad video id', async function () { | 340 | it('Should fail with a bad video id', async function () { |
@@ -350,22 +350,23 @@ describe('Test video lives API validator', function () { | |||
350 | }) | 350 | }) |
351 | 351 | ||
352 | it('Should succeed with the correct params', async function () { | 352 | it('Should succeed with the correct params', async function () { |
353 | await getLive(server.url, server.accessToken, videoId) | 353 | await getLive(server.url, server.accessToken, video.id) |
354 | await getLive(server.url, server.accessToken, video.shortUUID) | ||
354 | }) | 355 | }) |
355 | }) | 356 | }) |
356 | 357 | ||
357 | describe('When updating live information', async function () { | 358 | describe('When updating live information', async function () { |
358 | 359 | ||
359 | it('Should fail without access token', async function () { | 360 | it('Should fail without access token', async function () { |
360 | await updateLive(server.url, '', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) | 361 | await updateLive(server.url, '', video.id, {}, HttpStatusCode.UNAUTHORIZED_401) |
361 | }) | 362 | }) |
362 | 363 | ||
363 | it('Should fail with a bad access token', async function () { | 364 | it('Should fail with a bad access token', async function () { |
364 | await updateLive(server.url, 'toto', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) | 365 | await updateLive(server.url, 'toto', video.id, {}, HttpStatusCode.UNAUTHORIZED_401) |
365 | }) | 366 | }) |
366 | 367 | ||
367 | it('Should fail with access token of another user', async function () { | 368 | it('Should fail with access token of another user', async function () { |
368 | await updateLive(server.url, userAccessToken, videoId, {}, HttpStatusCode.FORBIDDEN_403) | 369 | await updateLive(server.url, userAccessToken, video.id, {}, HttpStatusCode.FORBIDDEN_403) |
369 | }) | 370 | }) |
370 | 371 | ||
371 | it('Should fail with a bad video id', async function () { | 372 | it('Should fail with a bad video id', async function () { |
@@ -383,11 +384,12 @@ describe('Test video lives API validator', function () { | |||
383 | it('Should fail with save replay and permanent live set to true', async function () { | 384 | it('Should fail with save replay and permanent live set to true', async function () { |
384 | const fields = { saveReplay: true, permanentLive: true } | 385 | const fields = { saveReplay: true, permanentLive: true } |
385 | 386 | ||
386 | await updateLive(server.url, server.accessToken, videoId, fields, HttpStatusCode.BAD_REQUEST_400) | 387 | await updateLive(server.url, server.accessToken, video.id, fields, HttpStatusCode.BAD_REQUEST_400) |
387 | }) | 388 | }) |
388 | 389 | ||
389 | it('Should succeed with the correct params', async function () { | 390 | it('Should succeed with the correct params', async function () { |
390 | await updateLive(server.url, server.accessToken, videoId, { saveReplay: false }) | 391 | await updateLive(server.url, server.accessToken, video.id, { saveReplay: false }) |
392 | await updateLive(server.url, server.accessToken, video.shortUUID, { saveReplay: false }) | ||
391 | }) | 393 | }) |
392 | 394 | ||
393 | it('Should fail to update replay status if replay is not allowed on the instance', async function () { | 395 | it('Should fail to update replay status if replay is not allowed on the instance', async function () { |
@@ -398,19 +400,19 @@ describe('Test video lives API validator', function () { | |||
398 | } | 400 | } |
399 | }) | 401 | }) |
400 | 402 | ||
401 | await updateLive(server.url, server.accessToken, videoId, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403) | 403 | await updateLive(server.url, server.accessToken, video.id, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403) |
402 | }) | 404 | }) |
403 | 405 | ||
404 | it('Should fail to update a live if it has already started', async function () { | 406 | it('Should fail to update a live if it has already started', async function () { |
405 | this.timeout(40000) | 407 | this.timeout(40000) |
406 | 408 | ||
407 | const resLive = await getLive(server.url, server.accessToken, videoId) | 409 | const resLive = await getLive(server.url, server.accessToken, video.id) |
408 | const live: LiveVideo = resLive.body | 410 | const live: LiveVideo = resLive.body |
409 | 411 | ||
410 | const command = sendRTMPStream(live.rtmpUrl, live.streamKey) | 412 | const command = sendRTMPStream(live.rtmpUrl, live.streamKey) |
411 | 413 | ||
412 | await waitUntilLivePublished(server.url, server.accessToken, videoId) | 414 | await waitUntilLivePublished(server.url, server.accessToken, video.id) |
413 | await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400) | 415 | await updateLive(server.url, server.accessToken, video.id, {}, HttpStatusCode.BAD_REQUEST_400) |
414 | 416 | ||
415 | await stopFfmpeg(command) | 417 | await stopFfmpeg(command) |
416 | }) | 418 | }) |
@@ -418,14 +420,14 @@ describe('Test video lives API validator', function () { | |||
418 | it('Should fail to stream twice in the save live', async function () { | 420 | it('Should fail to stream twice in the save live', async function () { |
419 | this.timeout(40000) | 421 | this.timeout(40000) |
420 | 422 | ||
421 | const resLive = await getLive(server.url, server.accessToken, videoId) | 423 | const resLive = await getLive(server.url, server.accessToken, video.id) |
422 | const live: LiveVideo = resLive.body | 424 | const live: LiveVideo = resLive.body |
423 | 425 | ||
424 | const command = sendRTMPStream(live.rtmpUrl, live.streamKey) | 426 | const command = sendRTMPStream(live.rtmpUrl, live.streamKey) |
425 | 427 | ||
426 | await waitUntilLivePublished(server.url, server.accessToken, videoId) | 428 | await waitUntilLivePublished(server.url, server.accessToken, video.id) |
427 | 429 | ||
428 | await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true) | 430 | await runAndTestFfmpegStreamError(server.url, server.accessToken, video.id, true) |
429 | 431 | ||
430 | await stopFfmpeg(command) | 432 | await stopFfmpeg(command) |
431 | }) | 433 | }) |
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index 71be50a6f..dac6938de 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | import { VideoCreateResult } from '@shared/models' | |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 6 | import { |
6 | checkBadCountPagination, | 7 | checkBadCountPagination, |
7 | checkBadSortPagination, | 8 | checkBadSortPagination, |
@@ -9,20 +10,24 @@ import { | |||
9 | cleanupTests, | 10 | cleanupTests, |
10 | createUser, | 11 | createUser, |
11 | doubleFollow, | 12 | doubleFollow, |
12 | flushAndRunMultipleServers, makeDeleteRequest, | 13 | flushAndRunMultipleServers, |
13 | makeGetRequest, makePostBodyRequest, | 14 | getVideo, |
15 | makeDeleteRequest, | ||
16 | makeGetRequest, | ||
17 | makePostBodyRequest, | ||
14 | makePutBodyRequest, | 18 | makePutBodyRequest, |
15 | ServerInfo, | 19 | ServerInfo, |
16 | setAccessTokensToServers, uploadVideoAndGetId, | 20 | setAccessTokensToServers, |
17 | userLogin, waitJobs, getVideoIdFromUUID | 21 | uploadVideoAndGetId, |
22 | userLogin, | ||
23 | waitJobs | ||
18 | } from '../../../../shared/extra-utils' | 24 | } from '../../../../shared/extra-utils' |
19 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
20 | 25 | ||
21 | describe('Test server redundancy API validators', function () { | 26 | describe('Test server redundancy API validators', function () { |
22 | let servers: ServerInfo[] | 27 | let servers: ServerInfo[] |
23 | let userAccessToken = null | 28 | let userAccessToken = null |
24 | let videoIdLocal: number | 29 | let videoIdLocal: number |
25 | let videoIdRemote: number | 30 | let videoRemote: VideoCreateResult |
26 | 31 | ||
27 | // --------------------------------------------------------------- | 32 | // --------------------------------------------------------------- |
28 | 33 | ||
@@ -48,7 +53,8 @@ describe('Test server redundancy API validators', function () { | |||
48 | 53 | ||
49 | await waitJobs(servers) | 54 | await waitJobs(servers) |
50 | 55 | ||
51 | videoIdRemote = await getVideoIdFromUUID(servers[0].url, remoteUUID) | 56 | const resVideo = await getVideo(servers[0].url, remoteUUID) |
57 | videoRemote = resVideo.body | ||
52 | }) | 58 | }) |
53 | 59 | ||
54 | describe('When listing redundancies', function () { | 60 | describe('When listing redundancies', function () { |
@@ -131,7 +137,13 @@ describe('Test server redundancy API validators', function () { | |||
131 | }) | 137 | }) |
132 | 138 | ||
133 | it('Should succeed with the correct params', async function () { | 139 | it('Should succeed with the correct params', async function () { |
134 | await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) | 140 | await makePostBodyRequest({ |
141 | url, | ||
142 | path, | ||
143 | token, | ||
144 | fields: { videoId: videoRemote.shortUUID }, | ||
145 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | ||
146 | }) | ||
135 | }) | 147 | }) |
136 | 148 | ||
137 | it('Should fail if the video is already duplicated', async function () { | 149 | it('Should fail if the video is already duplicated', async function () { |
@@ -139,7 +151,13 @@ describe('Test server redundancy API validators', function () { | |||
139 | 151 | ||
140 | await waitJobs(servers) | 152 | await waitJobs(servers) |
141 | 153 | ||
142 | await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.CONFLICT_409 }) | 154 | await makePostBodyRequest({ |
155 | url, | ||
156 | path, | ||
157 | token, | ||
158 | fields: { videoId: videoRemote.uuid }, | ||
159 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | ||
160 | }) | ||
143 | }) | 161 | }) |
144 | }) | 162 | }) |
145 | 163 | ||
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 36482ee17..70a872ce5 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { User, UserRole } from '../../../../shared' | 5 | import { User, UserRole, VideoCreateResult } from '../../../../shared' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
7 | import { | 7 | import { |
8 | addVideoChannel, | 8 | addVideoChannel, |
@@ -45,7 +45,7 @@ describe('Test users API validators', function () { | |||
45 | let userId: number | 45 | let userId: number |
46 | let rootId: number | 46 | let rootId: number |
47 | let moderatorId: number | 47 | let moderatorId: number |
48 | let videoId: number | 48 | let video: VideoCreateResult |
49 | let server: ServerInfo | 49 | let server: ServerInfo |
50 | let serverWithRegistrationDisabled: ServerInfo | 50 | let serverWithRegistrationDisabled: ServerInfo |
51 | let userAccessToken = '' | 51 | let userAccessToken = '' |
@@ -126,7 +126,7 @@ describe('Test users API validators', function () { | |||
126 | 126 | ||
127 | { | 127 | { |
128 | const res = await uploadVideo(server.url, server.accessToken, {}) | 128 | const res = await uploadVideo(server.url, server.accessToken, {}) |
129 | videoId = res.body.video.id | 129 | video = res.body.video |
130 | } | 130 | } |
131 | 131 | ||
132 | { | 132 | { |
@@ -829,7 +829,7 @@ describe('Test users API validators', function () { | |||
829 | 829 | ||
830 | describe('When getting my video rating', function () { | 830 | describe('When getting my video rating', function () { |
831 | it('Should fail with a non authenticated user', async function () { | 831 | it('Should fail with a non authenticated user', async function () { |
832 | await getMyUserVideoRating(server.url, 'fake_token', videoId, HttpStatusCode.UNAUTHORIZED_401) | 832 | await getMyUserVideoRating(server.url, 'fake_token', video.id, HttpStatusCode.UNAUTHORIZED_401) |
833 | }) | 833 | }) |
834 | 834 | ||
835 | it('Should fail with an incorrect video uuid', async function () { | 835 | it('Should fail with an incorrect video uuid', async function () { |
@@ -841,7 +841,9 @@ describe('Test users API validators', function () { | |||
841 | }) | 841 | }) |
842 | 842 | ||
843 | it('Should succeed with the correct parameters', async function () { | 843 | it('Should succeed with the correct parameters', async function () { |
844 | await getMyUserVideoRating(server.url, server.accessToken, videoId) | 844 | await getMyUserVideoRating(server.url, server.accessToken, video.id) |
845 | await getMyUserVideoRating(server.url, server.accessToken, video.uuid) | ||
846 | await getMyUserVideoRating(server.url, server.accessToken, video.shortUUID) | ||
845 | }) | 847 | }) |
846 | }) | 848 | }) |
847 | 849 | ||
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 3d4837d58..ce7f5fa17 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -191,7 +191,7 @@ describe('Test video blacklist API validators', function () { | |||
191 | }) | 191 | }) |
192 | 192 | ||
193 | it('Should succeed with the correct params', async function () { | 193 | it('Should succeed with the correct params', async function () { |
194 | const path = basePath + servers[0].video.uuid + '/blacklist' | 194 | const path = basePath + servers[0].video.shortUUID + '/blacklist' |
195 | const fields = { reason: 'hello' } | 195 | const fields = { reason: 'hello' } |
196 | 196 | ||
197 | await makePutBodyRequest({ | 197 | await makePutBodyRequest({ |
@@ -222,10 +222,14 @@ describe('Test video blacklist API validators', function () { | |||
222 | }) | 222 | }) |
223 | 223 | ||
224 | it('Should succeed with an admin', async function () { | 224 | it('Should succeed with an admin', async function () { |
225 | const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, servers[0].video.uuid, HttpStatusCode.OK_200) | 225 | const video = servers[0].video |
226 | const video: VideoDetails = res.body | ||
227 | 226 | ||
228 | expect(video.blacklisted).to.be.true | 227 | for (const id of [ video.id, video.uuid, video.shortUUID ]) { |
228 | const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, id, HttpStatusCode.OK_200) | ||
229 | const video: VideoDetails = res.body | ||
230 | |||
231 | expect(video.blacklisted).to.be.true | ||
232 | } | ||
229 | }) | 233 | }) |
230 | }) | 234 | }) |
231 | 235 | ||
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 1ce2202d2..c0595c04d 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | import { VideoCreateResult } from '@shared/models' | |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
@@ -23,7 +23,7 @@ describe('Test video captions API validator', function () { | |||
23 | 23 | ||
24 | let server: ServerInfo | 24 | let server: ServerInfo |
25 | let userAccessToken: string | 25 | let userAccessToken: string |
26 | let videoUUID: string | 26 | let video: VideoCreateResult |
27 | 27 | ||
28 | // --------------------------------------------------------------- | 28 | // --------------------------------------------------------------- |
29 | 29 | ||
@@ -36,7 +36,7 @@ describe('Test video captions API validator', function () { | |||
36 | 36 | ||
37 | { | 37 | { |
38 | const res = await uploadVideo(server.url, server.accessToken, {}) | 38 | const res = await uploadVideo(server.url, server.accessToken, {}) |
39 | videoUUID = res.body.video.uuid | 39 | video = res.body.video |
40 | } | 40 | } |
41 | 41 | ||
42 | { | 42 | { |
@@ -79,7 +79,7 @@ describe('Test video captions API validator', function () { | |||
79 | }) | 79 | }) |
80 | 80 | ||
81 | it('Should fail with a missing language in path', async function () { | 81 | it('Should fail with a missing language in path', async function () { |
82 | const captionPath = path + videoUUID + '/captions' | 82 | const captionPath = path + video.uuid + '/captions' |
83 | await makeUploadRequest({ | 83 | await makeUploadRequest({ |
84 | method: 'PUT', | 84 | method: 'PUT', |
85 | url: server.url, | 85 | url: server.url, |
@@ -91,7 +91,7 @@ describe('Test video captions API validator', function () { | |||
91 | }) | 91 | }) |
92 | 92 | ||
93 | it('Should fail with an unknown language', async function () { | 93 | it('Should fail with an unknown language', async function () { |
94 | const captionPath = path + videoUUID + '/captions/15' | 94 | const captionPath = path + video.uuid + '/captions/15' |
95 | await makeUploadRequest({ | 95 | await makeUploadRequest({ |
96 | method: 'PUT', | 96 | method: 'PUT', |
97 | url: server.url, | 97 | url: server.url, |
@@ -103,7 +103,7 @@ describe('Test video captions API validator', function () { | |||
103 | }) | 103 | }) |
104 | 104 | ||
105 | it('Should fail without access token', async function () { | 105 | it('Should fail without access token', async function () { |
106 | const captionPath = path + videoUUID + '/captions/fr' | 106 | const captionPath = path + video.uuid + '/captions/fr' |
107 | await makeUploadRequest({ | 107 | await makeUploadRequest({ |
108 | method: 'PUT', | 108 | method: 'PUT', |
109 | url: server.url, | 109 | url: server.url, |
@@ -115,7 +115,7 @@ describe('Test video captions API validator', function () { | |||
115 | }) | 115 | }) |
116 | 116 | ||
117 | it('Should fail with a bad access token', async function () { | 117 | it('Should fail with a bad access token', async function () { |
118 | const captionPath = path + videoUUID + '/captions/fr' | 118 | const captionPath = path + video.uuid + '/captions/fr' |
119 | await makeUploadRequest({ | 119 | await makeUploadRequest({ |
120 | method: 'PUT', | 120 | method: 'PUT', |
121 | url: server.url, | 121 | url: server.url, |
@@ -133,7 +133,7 @@ describe('Test video captions API validator', function () { | |||
133 | // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt') | 133 | // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt') |
134 | // } | 134 | // } |
135 | // | 135 | // |
136 | // const captionPath = path + videoUUID + '/captions/fr' | 136 | // const captionPath = path + video.uuid + '/captions/fr' |
137 | // await makeUploadRequest({ | 137 | // await makeUploadRequest({ |
138 | // method: 'PUT', | 138 | // method: 'PUT', |
139 | // url: server.url, | 139 | // url: server.url, |
@@ -151,7 +151,7 @@ describe('Test video captions API validator', function () { | |||
151 | // url: server.url, | 151 | // url: server.url, |
152 | // accessToken: server.accessToken, | 152 | // accessToken: server.accessToken, |
153 | // language: 'zh', | 153 | // language: 'zh', |
154 | // videoId: videoUUID, | 154 | // videoId: video.uuid, |
155 | // fixture: 'subtitle-bad.txt', | 155 | // fixture: 'subtitle-bad.txt', |
156 | // mimeType: 'application/octet-stream', | 156 | // mimeType: 'application/octet-stream', |
157 | // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 157 | // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 |
@@ -163,7 +163,7 @@ describe('Test video captions API validator', function () { | |||
163 | url: server.url, | 163 | url: server.url, |
164 | accessToken: server.accessToken, | 164 | accessToken: server.accessToken, |
165 | language: 'zh', | 165 | language: 'zh', |
166 | videoId: videoUUID, | 166 | videoId: video.uuid, |
167 | fixture: 'subtitle-good.srt', | 167 | fixture: 'subtitle-good.srt', |
168 | mimeType: 'application/octet-stream' | 168 | mimeType: 'application/octet-stream' |
169 | }) | 169 | }) |
@@ -175,7 +175,7 @@ describe('Test video captions API validator', function () { | |||
175 | // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt') | 175 | // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt') |
176 | // } | 176 | // } |
177 | // | 177 | // |
178 | // const captionPath = path + videoUUID + '/captions/fr' | 178 | // const captionPath = path + video.uuid + '/captions/fr' |
179 | // await makeUploadRequest({ | 179 | // await makeUploadRequest({ |
180 | // method: 'PUT', | 180 | // method: 'PUT', |
181 | // url: server.url, | 181 | // url: server.url, |
@@ -188,7 +188,7 @@ describe('Test video captions API validator', function () { | |||
188 | // }) | 188 | // }) |
189 | 189 | ||
190 | it('Should success with the correct parameters', async function () { | 190 | it('Should success with the correct parameters', async function () { |
191 | const captionPath = path + videoUUID + '/captions/fr' | 191 | const captionPath = path + video.uuid + '/captions/fr' |
192 | await makeUploadRequest({ | 192 | await makeUploadRequest({ |
193 | method: 'PUT', | 193 | method: 'PUT', |
194 | url: server.url, | 194 | url: server.url, |
@@ -215,7 +215,7 @@ describe('Test video captions API validator', function () { | |||
215 | }) | 215 | }) |
216 | 216 | ||
217 | it('Should success with the correct parameters', async function () { | 217 | it('Should success with the correct parameters', async function () { |
218 | await makeGetRequest({ url: server.url, path: path + videoUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) | 218 | await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) |
219 | }) | 219 | }) |
220 | }) | 220 | }) |
221 | 221 | ||
@@ -246,27 +246,27 @@ describe('Test video captions API validator', function () { | |||
246 | }) | 246 | }) |
247 | 247 | ||
248 | it('Should fail with a missing language', async function () { | 248 | it('Should fail with a missing language', async function () { |
249 | const captionPath = path + videoUUID + '/captions' | 249 | const captionPath = path + video.shortUUID + '/captions' |
250 | await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) | 250 | await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) |
251 | }) | 251 | }) |
252 | 252 | ||
253 | it('Should fail with an unknown language', async function () { | 253 | it('Should fail with an unknown language', async function () { |
254 | const captionPath = path + videoUUID + '/captions/15' | 254 | const captionPath = path + video.shortUUID + '/captions/15' |
255 | await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) | 255 | await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) |
256 | }) | 256 | }) |
257 | 257 | ||
258 | it('Should fail without access token', async function () { | 258 | it('Should fail without access token', async function () { |
259 | const captionPath = path + videoUUID + '/captions/fr' | 259 | const captionPath = path + video.shortUUID + '/captions/fr' |
260 | await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 260 | await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
261 | }) | 261 | }) |
262 | 262 | ||
263 | it('Should fail with a bad access token', async function () { | 263 | it('Should fail with a bad access token', async function () { |
264 | const captionPath = path + videoUUID + '/captions/fr' | 264 | const captionPath = path + video.shortUUID + '/captions/fr' |
265 | await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 265 | await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
266 | }) | 266 | }) |
267 | 267 | ||
268 | it('Should fail with another user', async function () { | 268 | it('Should fail with another user', async function () { |
269 | const captionPath = path + videoUUID + '/captions/fr' | 269 | const captionPath = path + video.shortUUID + '/captions/fr' |
270 | await makeDeleteRequest({ | 270 | await makeDeleteRequest({ |
271 | url: server.url, | 271 | url: server.url, |
272 | path: captionPath, | 272 | path: captionPath, |
@@ -276,7 +276,7 @@ describe('Test video captions API validator', function () { | |||
276 | }) | 276 | }) |
277 | 277 | ||
278 | it('Should success with the correct parameters', async function () { | 278 | it('Should success with the correct parameters', async function () { |
279 | const captionPath = path + videoUUID + '/captions/fr' | 279 | const captionPath = path + video.shortUUID + '/captions/fr' |
280 | await makeDeleteRequest({ | 280 | await makeDeleteRequest({ |
281 | url: server.url, | 281 | url: server.url, |
282 | path: captionPath, | 282 | path: captionPath, |
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 659a10c41..a38420851 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -1,7 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { VideoCreateResult } from '@shared/models' | ||
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createUser, | 9 | createUser, |
@@ -20,7 +22,6 @@ import { | |||
20 | checkBadStartPagination | 22 | checkBadStartPagination |
21 | } from '../../../../shared/extra-utils/requests/check-api-params' | 23 | } from '../../../../shared/extra-utils/requests/check-api-params' |
22 | import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' | 24 | import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' |
23 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
24 | 25 | ||
25 | const expect = chai.expect | 26 | const expect = chai.expect |
26 | 27 | ||
@@ -28,7 +29,7 @@ describe('Test video comments API validator', function () { | |||
28 | let pathThread: string | 29 | let pathThread: string |
29 | let pathComment: string | 30 | let pathComment: string |
30 | let server: ServerInfo | 31 | let server: ServerInfo |
31 | let videoUUID: string | 32 | let video: VideoCreateResult |
32 | let userAccessToken: string | 33 | let userAccessToken: string |
33 | let userAccessToken2: string | 34 | let userAccessToken2: string |
34 | let commentId: number | 35 | let commentId: number |
@@ -44,14 +45,14 @@ describe('Test video comments API validator', function () { | |||
44 | 45 | ||
45 | { | 46 | { |
46 | const res = await uploadVideo(server.url, server.accessToken, {}) | 47 | const res = await uploadVideo(server.url, server.accessToken, {}) |
47 | videoUUID = res.body.video.uuid | 48 | video = res.body.video |
48 | pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' | 49 | pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' |
49 | } | 50 | } |
50 | 51 | ||
51 | { | 52 | { |
52 | const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, 'coucou') | 53 | const res = await addVideoCommentThread(server.url, server.accessToken, video.uuid, 'coucou') |
53 | commentId = res.body.comment.id | 54 | commentId = res.body.comment.id |
54 | pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId | 55 | pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId |
55 | } | 56 | } |
56 | 57 | ||
57 | { | 58 | { |
@@ -101,7 +102,7 @@ describe('Test video comments API validator', function () { | |||
101 | it('Should fail with an incorrect thread id', async function () { | 102 | it('Should fail with an incorrect thread id', async function () { |
102 | await makeGetRequest({ | 103 | await makeGetRequest({ |
103 | url: server.url, | 104 | url: server.url, |
104 | path: '/api/v1/videos/' + videoUUID + '/comment-threads/156', | 105 | path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', |
105 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 106 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 |
106 | }) | 107 | }) |
107 | }) | 108 | }) |
@@ -109,7 +110,7 @@ describe('Test video comments API validator', function () { | |||
109 | it('Should success with the correct params', async function () { | 110 | it('Should success with the correct params', async function () { |
110 | await makeGetRequest({ | 111 | await makeGetRequest({ |
111 | url: server.url, | 112 | url: server.url, |
112 | path: '/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId, | 113 | path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, |
113 | statusCodeExpected: HttpStatusCode.OK_200 | 114 | statusCodeExpected: HttpStatusCode.OK_200 |
114 | }) | 115 | }) |
115 | }) | 116 | }) |
@@ -225,7 +226,7 @@ describe('Test video comments API validator', function () { | |||
225 | }) | 226 | }) |
226 | 227 | ||
227 | it('Should fail with an incorrect comment', async function () { | 228 | it('Should fail with an incorrect comment', async function () { |
228 | const path = '/api/v1/videos/' + videoUUID + '/comments/124' | 229 | const path = '/api/v1/videos/' + video.uuid + '/comments/124' |
229 | const fields = { | 230 | const fields = { |
230 | text: 'super comment' | 231 | text: 'super comment' |
231 | } | 232 | } |
@@ -272,7 +273,7 @@ describe('Test video comments API validator', function () { | |||
272 | }) | 273 | }) |
273 | 274 | ||
274 | it('Should fail with an incorrect comment', async function () { | 275 | it('Should fail with an incorrect comment', async function () { |
275 | const path = '/api/v1/videos/' + videoUUID + '/comments/124' | 276 | const path = '/api/v1/videos/' + video.uuid + '/comments/124' |
276 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 277 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) |
277 | }) | 278 | }) |
278 | 279 | ||
@@ -280,11 +281,11 @@ describe('Test video comments API validator', function () { | |||
280 | let commentToDelete: number | 281 | let commentToDelete: number |
281 | 282 | ||
282 | { | 283 | { |
283 | const res = await addVideoCommentThread(server.url, userAccessToken, videoUUID, 'hello') | 284 | const res = await addVideoCommentThread(server.url, userAccessToken, video.uuid, 'hello') |
284 | commentToDelete = res.body.comment.id | 285 | commentToDelete = res.body.comment.id |
285 | } | 286 | } |
286 | 287 | ||
287 | const path = '/api/v1/videos/' + videoUUID + '/comments/' + commentToDelete | 288 | const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete |
288 | 289 | ||
289 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 290 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) |
290 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) | 291 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) |
@@ -323,8 +324,8 @@ describe('Test video comments API validator', function () { | |||
323 | describe('When a video has comments disabled', function () { | 324 | describe('When a video has comments disabled', function () { |
324 | before(async function () { | 325 | before(async function () { |
325 | const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) | 326 | const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) |
326 | videoUUID = res.body.video.uuid | 327 | video = res.body.video |
327 | pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' | 328 | pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' |
328 | }) | 329 | }) |
329 | 330 | ||
330 | it('Should return an empty thread list', async function () { | 331 | it('Should return an empty thread list', async function () { |
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index bbea88354..18253d11a 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -1,8 +1,13 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPlaylistType } from '@shared/models' | ||
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
4 | import { | 6 | import { |
5 | addVideoInPlaylist, | 7 | addVideoInPlaylist, |
8 | checkBadCountPagination, | ||
9 | checkBadSortPagination, | ||
10 | checkBadStartPagination, | ||
6 | cleanupTests, | 11 | cleanupTests, |
7 | createVideoPlaylist, | 12 | createVideoPlaylist, |
8 | deleteVideoPlaylist, | 13 | deleteVideoPlaylist, |
@@ -21,20 +26,14 @@ import { | |||
21 | updateVideoPlaylistElement, | 26 | updateVideoPlaylistElement, |
22 | uploadVideoAndGetId | 27 | uploadVideoAndGetId |
23 | } from '../../../../shared/extra-utils' | 28 | } from '../../../../shared/extra-utils' |
24 | import { | ||
25 | checkBadCountPagination, | ||
26 | checkBadSortPagination, | ||
27 | checkBadStartPagination | ||
28 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
29 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
30 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' | ||
31 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
32 | 29 | ||
33 | describe('Test video playlists API validator', function () { | 30 | describe('Test video playlists API validator', function () { |
34 | let server: ServerInfo | 31 | let server: ServerInfo |
35 | let userAccessToken: string | 32 | let userAccessToken: string |
36 | let playlistUUID: string | 33 | |
34 | let playlist: VideoPlaylistCreateResult | ||
37 | let privatePlaylistUUID: string | 35 | let privatePlaylistUUID: string |
36 | |||
38 | let watchLaterPlaylistId: number | 37 | let watchLaterPlaylistId: number |
39 | let videoId: number | 38 | let videoId: number |
40 | let playlistElementId: number | 39 | let playlistElementId: number |
@@ -67,7 +66,7 @@ describe('Test video playlists API validator', function () { | |||
67 | videoChannelId: server.videoChannel.id | 66 | videoChannelId: server.videoChannel.id |
68 | } | 67 | } |
69 | }) | 68 | }) |
70 | playlistUUID = res.body.videoPlaylist.uuid | 69 | playlist = res.body.videoPlaylist |
71 | } | 70 | } |
72 | 71 | ||
73 | { | 72 | { |
@@ -150,15 +149,15 @@ describe('Test video playlists API validator', function () { | |||
150 | const path = '/api/v1/video-playlists/' | 149 | const path = '/api/v1/video-playlists/' |
151 | 150 | ||
152 | it('Should fail with a bad start pagination', async function () { | 151 | it('Should fail with a bad start pagination', async function () { |
153 | await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken) | 152 | await checkBadStartPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken) |
154 | }) | 153 | }) |
155 | 154 | ||
156 | it('Should fail with a bad count pagination', async function () { | 155 | it('Should fail with a bad count pagination', async function () { |
157 | await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken) | 156 | await checkBadCountPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken) |
158 | }) | 157 | }) |
159 | 158 | ||
160 | it('Should success with the correct parameters', async function () { | 159 | it('Should success with the correct parameters', async function () { |
161 | await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) | 160 | await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) |
162 | }) | 161 | }) |
163 | }) | 162 | }) |
164 | 163 | ||
@@ -177,6 +176,7 @@ describe('Test video playlists API validator', function () { | |||
177 | token: server.accessToken, | 176 | token: server.accessToken, |
178 | playlistAttrs: { | 177 | playlistAttrs: { |
179 | displayName: 'super playlist', | 178 | displayName: 'super playlist', |
179 | videoChannelId: server.videoChannel.id, | ||
180 | privacy: VideoPlaylistPrivacy.UNLISTED | 180 | privacy: VideoPlaylistPrivacy.UNLISTED |
181 | } | 181 | } |
182 | }) | 182 | }) |
@@ -187,7 +187,7 @@ describe('Test video playlists API validator', function () { | |||
187 | }) | 187 | }) |
188 | 188 | ||
189 | it('Should succeed with the correct params', async function () { | 189 | it('Should succeed with the correct params', async function () { |
190 | await getVideoPlaylist(server.url, playlistUUID, HttpStatusCode.OK_200) | 190 | await getVideoPlaylist(server.url, playlist.uuid, HttpStatusCode.OK_200) |
191 | }) | 191 | }) |
192 | }) | 192 | }) |
193 | 193 | ||
@@ -213,7 +213,7 @@ describe('Test video playlists API validator', function () { | |||
213 | const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | 213 | const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
214 | 214 | ||
215 | await createVideoPlaylist(params) | 215 | await createVideoPlaylist(params) |
216 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 216 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
217 | }) | 217 | }) |
218 | 218 | ||
219 | it('Should fail without displayName', async function () { | 219 | it('Should fail without displayName', async function () { |
@@ -226,42 +226,42 @@ describe('Test video playlists API validator', function () { | |||
226 | const params = getBase({ displayName: 's'.repeat(300) }) | 226 | const params = getBase({ displayName: 's'.repeat(300) }) |
227 | 227 | ||
228 | await createVideoPlaylist(params) | 228 | await createVideoPlaylist(params) |
229 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 229 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
230 | }) | 230 | }) |
231 | 231 | ||
232 | it('Should fail with an incorrect description', async function () { | 232 | it('Should fail with an incorrect description', async function () { |
233 | const params = getBase({ description: 't' }) | 233 | const params = getBase({ description: 't' }) |
234 | 234 | ||
235 | await createVideoPlaylist(params) | 235 | await createVideoPlaylist(params) |
236 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 236 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
237 | }) | 237 | }) |
238 | 238 | ||
239 | it('Should fail with an incorrect privacy', async function () { | 239 | it('Should fail with an incorrect privacy', async function () { |
240 | const params = getBase({ privacy: 45 }) | 240 | const params = getBase({ privacy: 45 }) |
241 | 241 | ||
242 | await createVideoPlaylist(params) | 242 | await createVideoPlaylist(params) |
243 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 243 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
244 | }) | 244 | }) |
245 | 245 | ||
246 | it('Should fail with an unknown video channel id', async function () { | 246 | it('Should fail with an unknown video channel id', async function () { |
247 | const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | 247 | const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
248 | 248 | ||
249 | await createVideoPlaylist(params) | 249 | await createVideoPlaylist(params) |
250 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 250 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
251 | }) | 251 | }) |
252 | 252 | ||
253 | it('Should fail with an incorrect thumbnail file', async function () { | 253 | it('Should fail with an incorrect thumbnail file', async function () { |
254 | const params = getBase({ thumbnailfile: 'video_short.mp4' }) | 254 | const params = getBase({ thumbnailfile: 'video_short.mp4' }) |
255 | 255 | ||
256 | await createVideoPlaylist(params) | 256 | await createVideoPlaylist(params) |
257 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 257 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
258 | }) | 258 | }) |
259 | 259 | ||
260 | it('Should fail with a thumbnail file too big', async function () { | 260 | it('Should fail with a thumbnail file too big', async function () { |
261 | const params = getBase({ thumbnailfile: 'preview-big.png' }) | 261 | const params = getBase({ thumbnailfile: 'preview-big.png' }) |
262 | 262 | ||
263 | await createVideoPlaylist(params) | 263 | await createVideoPlaylist(params) |
264 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 264 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
265 | }) | 265 | }) |
266 | 266 | ||
267 | it('Should fail to set "public" a playlist not assigned to a channel', async function () { | 267 | it('Should fail to set "public" a playlist not assigned to a channel', async function () { |
@@ -272,8 +272,8 @@ describe('Test video playlists API validator', function () { | |||
272 | await createVideoPlaylist(params) | 272 | await createVideoPlaylist(params) |
273 | await createVideoPlaylist(params2) | 273 | await createVideoPlaylist(params2) |
274 | await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID)) | 274 | await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID)) |
275 | await updateVideoPlaylist(getUpdate(params2, playlistUUID)) | 275 | await updateVideoPlaylist(getUpdate(params2, playlist.shortUUID)) |
276 | await updateVideoPlaylist(getUpdate(params3, playlistUUID)) | 276 | await updateVideoPlaylist(getUpdate(params3, playlist.shortUUID)) |
277 | }) | 277 | }) |
278 | 278 | ||
279 | it('Should fail with an unknown playlist to update', async function () { | 279 | it('Should fail with an unknown playlist to update', async function () { |
@@ -286,7 +286,7 @@ describe('Test video playlists API validator', function () { | |||
286 | it('Should fail to update a playlist of another user', async function () { | 286 | it('Should fail to update a playlist of another user', async function () { |
287 | await updateVideoPlaylist(getUpdate( | 287 | await updateVideoPlaylist(getUpdate( |
288 | getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }), | 288 | getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }), |
289 | playlistUUID | 289 | playlist.shortUUID |
290 | )) | 290 | )) |
291 | }) | 291 | }) |
292 | 292 | ||
@@ -305,7 +305,7 @@ describe('Test video playlists API validator', function () { | |||
305 | 305 | ||
306 | { | 306 | { |
307 | const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 }) | 307 | const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 }) |
308 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 308 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
309 | } | 309 | } |
310 | }) | 310 | }) |
311 | }) | 311 | }) |
@@ -316,7 +316,7 @@ describe('Test video playlists API validator', function () { | |||
316 | expectedStatus: HttpStatusCode.BAD_REQUEST_400, | 316 | expectedStatus: HttpStatusCode.BAD_REQUEST_400, |
317 | url: server.url, | 317 | url: server.url, |
318 | token: server.accessToken, | 318 | token: server.accessToken, |
319 | playlistId: playlistUUID, | 319 | playlistId: playlist.id, |
320 | elementAttrs: Object.assign({ | 320 | elementAttrs: Object.assign({ |
321 | videoId, | 321 | videoId, |
322 | startTimestamp: 2, | 322 | startTimestamp: 2, |
@@ -381,7 +381,7 @@ describe('Test video playlists API validator', function () { | |||
381 | stopTimestamp: 2 | 381 | stopTimestamp: 2 |
382 | }, elementAttrs), | 382 | }, elementAttrs), |
383 | playlistElementId, | 383 | playlistElementId, |
384 | playlistId: playlistUUID, | 384 | playlistId: playlist.id, |
385 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 385 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
386 | }, wrapper) | 386 | }, wrapper) |
387 | } | 387 | } |
@@ -451,7 +451,7 @@ describe('Test video playlists API validator', function () { | |||
451 | return Object.assign({ | 451 | return Object.assign({ |
452 | url: server.url, | 452 | url: server.url, |
453 | token: server.accessToken, | 453 | token: server.accessToken, |
454 | playlistId: playlistUUID, | 454 | playlistId: playlist.shortUUID, |
455 | elementAttrs: Object.assign({ | 455 | elementAttrs: Object.assign({ |
456 | startPosition: 1, | 456 | startPosition: 1, |
457 | insertAfterPosition: 2, | 457 | insertAfterPosition: 2, |
@@ -469,7 +469,7 @@ describe('Test video playlists API validator', function () { | |||
469 | await addVideoInPlaylist({ | 469 | await addVideoInPlaylist({ |
470 | url: server.url, | 470 | url: server.url, |
471 | token: server.accessToken, | 471 | token: server.accessToken, |
472 | playlistId: playlistUUID, | 472 | playlistId: playlist.shortUUID, |
473 | elementAttrs: { videoId: id } | 473 | elementAttrs: { videoId: id } |
474 | }) | 474 | }) |
475 | } | 475 | } |
@@ -606,7 +606,7 @@ describe('Test video playlists API validator', function () { | |||
606 | url: server.url, | 606 | url: server.url, |
607 | token: server.accessToken, | 607 | token: server.accessToken, |
608 | playlistElementId, | 608 | playlistElementId, |
609 | playlistId: playlistUUID, | 609 | playlistId: playlist.uuid, |
610 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 610 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
611 | }, wrapper) | 611 | }, wrapper) |
612 | } | 612 | } |
@@ -662,7 +662,7 @@ describe('Test video playlists API validator', function () { | |||
662 | }) | 662 | }) |
663 | 663 | ||
664 | it('Should fail with a playlist of another user', async function () { | 664 | it('Should fail with a playlist of another user', async function () { |
665 | await deleteVideoPlaylist(server.url, userAccessToken, playlistUUID, HttpStatusCode.FORBIDDEN_403) | 665 | await deleteVideoPlaylist(server.url, userAccessToken, playlist.uuid, HttpStatusCode.FORBIDDEN_403) |
666 | }) | 666 | }) |
667 | 667 | ||
668 | it('Should fail with the watch later playlist', async function () { | 668 | it('Should fail with the watch later playlist', async function () { |
@@ -670,7 +670,7 @@ describe('Test video playlists API validator', function () { | |||
670 | }) | 670 | }) |
671 | 671 | ||
672 | it('Should succeed with the correct params', async function () { | 672 | it('Should succeed with the correct params', async function () { |
673 | await deleteVideoPlaylist(server.url, server.accessToken, playlistUUID) | 673 | await deleteVideoPlaylist(server.url, server.accessToken, playlist.uuid) |
674 | }) | 674 | }) |
675 | }) | 675 | }) |
676 | 676 | ||
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index a6eecb13a..4d7a9a23b 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -5,7 +5,7 @@ import * as chai from 'chai' | |||
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '@shared/core-utils' | 7 | import { randomInt } from '@shared/core-utils' |
8 | import { PeerTubeProblemDocument } from '@shared/models' | 8 | import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models' |
9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
10 | import { | 10 | import { |
11 | checkUploadVideoParam, | 11 | checkUploadVideoParam, |
@@ -42,7 +42,7 @@ describe('Test videos API validator', function () { | |||
42 | let accountName: string | 42 | let accountName: string |
43 | let channelId: number | 43 | let channelId: number |
44 | let channelName: string | 44 | let channelName: string |
45 | let videoId | 45 | let video: VideoCreateResult |
46 | 46 | ||
47 | // --------------------------------------------------------------- | 47 | // --------------------------------------------------------------- |
48 | 48 | ||
@@ -490,7 +490,7 @@ describe('Test videos API validator', function () { | |||
490 | 490 | ||
491 | before(async function () { | 491 | before(async function () { |
492 | const res = await getVideosList(server.url) | 492 | const res = await getVideosList(server.url) |
493 | videoId = res.body.data[0].uuid | 493 | video = res.body.data[0] |
494 | }) | 494 | }) |
495 | 495 | ||
496 | it('Should fail with nothing', async function () { | 496 | it('Should fail with nothing', async function () { |
@@ -518,79 +518,79 @@ describe('Test videos API validator', function () { | |||
518 | it('Should fail with a long name', async function () { | 518 | it('Should fail with a long name', async function () { |
519 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | 519 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) |
520 | 520 | ||
521 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 521 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
522 | }) | 522 | }) |
523 | 523 | ||
524 | it('Should fail with a bad category', async function () { | 524 | it('Should fail with a bad category', async function () { |
525 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | 525 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) |
526 | 526 | ||
527 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 527 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
528 | }) | 528 | }) |
529 | 529 | ||
530 | it('Should fail with a bad licence', async function () { | 530 | it('Should fail with a bad licence', async function () { |
531 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 531 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) |
532 | 532 | ||
533 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 533 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
534 | }) | 534 | }) |
535 | 535 | ||
536 | it('Should fail with a bad language', async function () { | 536 | it('Should fail with a bad language', async function () { |
537 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 537 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) |
538 | 538 | ||
539 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 539 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
540 | }) | 540 | }) |
541 | 541 | ||
542 | it('Should fail with a long description', async function () { | 542 | it('Should fail with a long description', async function () { |
543 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | 543 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) |
544 | 544 | ||
545 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 545 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
546 | }) | 546 | }) |
547 | 547 | ||
548 | it('Should fail with a long support text', async function () { | 548 | it('Should fail with a long support text', async function () { |
549 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) | 549 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) |
550 | 550 | ||
551 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 551 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
552 | }) | 552 | }) |
553 | 553 | ||
554 | it('Should fail with a bad channel', async function () { | 554 | it('Should fail with a bad channel', async function () { |
555 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | 555 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) |
556 | 556 | ||
557 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 557 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
558 | }) | 558 | }) |
559 | 559 | ||
560 | it('Should fail with too many tags', async function () { | 560 | it('Should fail with too many tags', async function () { |
561 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | 561 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) |
562 | 562 | ||
563 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 563 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
564 | }) | 564 | }) |
565 | 565 | ||
566 | it('Should fail with a tag length too low', async function () { | 566 | it('Should fail with a tag length too low', async function () { |
567 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | 567 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) |
568 | 568 | ||
569 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 569 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
570 | }) | 570 | }) |
571 | 571 | ||
572 | it('Should fail with a tag length too big', async function () { | 572 | it('Should fail with a tag length too big', async function () { |
573 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | 573 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) |
574 | 574 | ||
575 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 575 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
576 | }) | 576 | }) |
577 | 577 | ||
578 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 578 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
579 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) | 579 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) |
580 | 580 | ||
581 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 581 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
582 | }) | 582 | }) |
583 | 583 | ||
584 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 584 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
585 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) | 585 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) |
586 | 586 | ||
587 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 587 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
588 | }) | 588 | }) |
589 | 589 | ||
590 | it('Should fail with a bad originally published at param', async function () { | 590 | it('Should fail with a bad originally published at param', async function () { |
591 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) | 591 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) |
592 | 592 | ||
593 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 593 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
594 | }) | 594 | }) |
595 | 595 | ||
596 | it('Should fail with an incorrect thumbnail file', async function () { | 596 | it('Should fail with an incorrect thumbnail file', async function () { |
@@ -602,7 +602,7 @@ describe('Test videos API validator', function () { | |||
602 | await makeUploadRequest({ | 602 | await makeUploadRequest({ |
603 | url: server.url, | 603 | url: server.url, |
604 | method: 'PUT', | 604 | method: 'PUT', |
605 | path: path + videoId, | 605 | path: path + video.shortUUID, |
606 | token: server.accessToken, | 606 | token: server.accessToken, |
607 | fields, | 607 | fields, |
608 | attaches | 608 | attaches |
@@ -618,7 +618,7 @@ describe('Test videos API validator', function () { | |||
618 | await makeUploadRequest({ | 618 | await makeUploadRequest({ |
619 | url: server.url, | 619 | url: server.url, |
620 | method: 'PUT', | 620 | method: 'PUT', |
621 | path: path + videoId, | 621 | path: path + video.shortUUID, |
622 | token: server.accessToken, | 622 | token: server.accessToken, |
623 | fields, | 623 | fields, |
624 | attaches | 624 | attaches |
@@ -634,7 +634,7 @@ describe('Test videos API validator', function () { | |||
634 | await makeUploadRequest({ | 634 | await makeUploadRequest({ |
635 | url: server.url, | 635 | url: server.url, |
636 | method: 'PUT', | 636 | method: 'PUT', |
637 | path: path + videoId, | 637 | path: path + video.shortUUID, |
638 | token: server.accessToken, | 638 | token: server.accessToken, |
639 | fields, | 639 | fields, |
640 | attaches | 640 | attaches |
@@ -650,7 +650,7 @@ describe('Test videos API validator', function () { | |||
650 | await makeUploadRequest({ | 650 | await makeUploadRequest({ |
651 | url: server.url, | 651 | url: server.url, |
652 | method: 'PUT', | 652 | method: 'PUT', |
653 | path: path + videoId, | 653 | path: path + video.shortUUID, |
654 | token: server.accessToken, | 654 | token: server.accessToken, |
655 | fields, | 655 | fields, |
656 | attaches | 656 | attaches |
@@ -662,7 +662,7 @@ describe('Test videos API validator', function () { | |||
662 | 662 | ||
663 | await makePutBodyRequest({ | 663 | await makePutBodyRequest({ |
664 | url: server.url, | 664 | url: server.url, |
665 | path: path + videoId, | 665 | path: path + video.shortUUID, |
666 | token: userAccessToken, | 666 | token: userAccessToken, |
667 | fields, | 667 | fields, |
668 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 668 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 |
@@ -674,7 +674,7 @@ describe('Test videos API validator', function () { | |||
674 | it('Shoud report the appropriate error', async function () { | 674 | it('Shoud report the appropriate error', async function () { |
675 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 675 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) |
676 | 676 | ||
677 | const res = await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 677 | const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
678 | const error = res.body as PeerTubeProblemDocument | 678 | const error = res.body as PeerTubeProblemDocument |
679 | 679 | ||
680 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo') | 680 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo') |
@@ -694,7 +694,7 @@ describe('Test videos API validator', function () { | |||
694 | 694 | ||
695 | await makePutBodyRequest({ | 695 | await makePutBodyRequest({ |
696 | url: server.url, | 696 | url: server.url, |
697 | path: path + videoId, | 697 | path: path + video.shortUUID, |
698 | token: server.accessToken, | 698 | token: server.accessToken, |
699 | fields, | 699 | fields, |
700 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 700 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 |
@@ -739,7 +739,7 @@ describe('Test videos API validator', function () { | |||
739 | }) | 739 | }) |
740 | 740 | ||
741 | it('Should succeed with the correct parameters', async function () { | 741 | it('Should succeed with the correct parameters', async function () { |
742 | await getVideo(server.url, videoId) | 742 | await getVideo(server.url, video.shortUUID) |
743 | }) | 743 | }) |
744 | }) | 744 | }) |
745 | 745 | ||
@@ -810,7 +810,7 @@ describe('Test videos API validator', function () { | |||
810 | }) | 810 | }) |
811 | 811 | ||
812 | it('Should fail with a video of another user without the appropriate right', async function () { | 812 | it('Should fail with a video of another user without the appropriate right', async function () { |
813 | await removeVideo(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) | 813 | await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403) |
814 | }) | 814 | }) |
815 | 815 | ||
816 | it('Should fail with a video of another server') | 816 | it('Should fail with a video of another server') |
@@ -832,7 +832,7 @@ describe('Test videos API validator', function () { | |||
832 | }) | 832 | }) |
833 | 833 | ||
834 | it('Should succeed with the correct parameters', async function () { | 834 | it('Should succeed with the correct parameters', async function () { |
835 | await removeVideo(server.url, server.accessToken, videoId) | 835 | await removeVideo(server.url, server.accessToken, video.uuid) |
836 | }) | 836 | }) |
837 | }) | 837 | }) |
838 | 838 | ||
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 4ce6675b6..3425480ae 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { v4 as uuidv4 } from 'uuid' | 4 | import { buildUUID } from '@server/helpers/uuid' |
5 | import { AbuseState } from '@shared/models' | 5 | import { AbuseState } from '@shared/models' |
6 | import { | 6 | import { |
7 | addAbuseMessage, | 7 | addAbuseMessage, |
@@ -85,7 +85,7 @@ describe('Test moderation notifications', function () { | |||
85 | it('Should send a notification to moderators on local video abuse', async function () { | 85 | it('Should send a notification to moderators on local video abuse', async function () { |
86 | this.timeout(20000) | 86 | this.timeout(20000) |
87 | 87 | ||
88 | const name = 'video for abuse ' + uuidv4() | 88 | const name = 'video for abuse ' + buildUUID() |
89 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 89 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
90 | const video = resVideo.body.video | 90 | const video = resVideo.body.video |
91 | 91 | ||
@@ -98,7 +98,7 @@ describe('Test moderation notifications', function () { | |||
98 | it('Should send a notification to moderators on remote video abuse', async function () { | 98 | it('Should send a notification to moderators on remote video abuse', async function () { |
99 | this.timeout(20000) | 99 | this.timeout(20000) |
100 | 100 | ||
101 | const name = 'video for abuse ' + uuidv4() | 101 | const name = 'video for abuse ' + buildUUID() |
102 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 102 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
103 | const video = resVideo.body.video | 103 | const video = resVideo.body.video |
104 | 104 | ||
@@ -114,10 +114,10 @@ describe('Test moderation notifications', function () { | |||
114 | it('Should send a notification to moderators on local comment abuse', async function () { | 114 | it('Should send a notification to moderators on local comment abuse', async function () { |
115 | this.timeout(20000) | 115 | this.timeout(20000) |
116 | 116 | ||
117 | const name = 'video for abuse ' + uuidv4() | 117 | const name = 'video for abuse ' + buildUUID() |
118 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 118 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
119 | const video = resVideo.body.video | 119 | const video = resVideo.body.video |
120 | const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) | 120 | const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) |
121 | const comment = resComment.body.comment | 121 | const comment = resComment.body.comment |
122 | 122 | ||
123 | await waitJobs(servers) | 123 | await waitJobs(servers) |
@@ -131,10 +131,10 @@ describe('Test moderation notifications', function () { | |||
131 | it('Should send a notification to moderators on remote comment abuse', async function () { | 131 | it('Should send a notification to moderators on remote comment abuse', async function () { |
132 | this.timeout(20000) | 132 | this.timeout(20000) |
133 | 133 | ||
134 | const name = 'video for abuse ' + uuidv4() | 134 | const name = 'video for abuse ' + buildUUID() |
135 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 135 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
136 | const video = resVideo.body.video | 136 | const video = resVideo.body.video |
137 | await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) | 137 | await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) |
138 | 138 | ||
139 | await waitJobs(servers) | 139 | await waitJobs(servers) |
140 | 140 | ||
@@ -188,7 +188,7 @@ describe('Test moderation notifications', function () { | |||
188 | token: userAccessToken | 188 | token: userAccessToken |
189 | } | 189 | } |
190 | 190 | ||
191 | const name = 'abuse ' + uuidv4() | 191 | const name = 'abuse ' + buildUUID() |
192 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 192 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
193 | const video = resVideo.body.video | 193 | const video = resVideo.body.video |
194 | 194 | ||
@@ -236,7 +236,7 @@ describe('Test moderation notifications', function () { | |||
236 | token: servers[0].accessToken | 236 | token: servers[0].accessToken |
237 | } | 237 | } |
238 | 238 | ||
239 | const name = 'abuse ' + uuidv4() | 239 | const name = 'abuse ' + buildUUID() |
240 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 240 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
241 | const video = resVideo.body.video | 241 | const video = resVideo.body.video |
242 | 242 | ||
@@ -307,7 +307,7 @@ describe('Test moderation notifications', function () { | |||
307 | it('Should send a notification to video owner on blacklist', async function () { | 307 | it('Should send a notification to video owner on blacklist', async function () { |
308 | this.timeout(10000) | 308 | this.timeout(10000) |
309 | 309 | ||
310 | const name = 'video for abuse ' + uuidv4() | 310 | const name = 'video for abuse ' + buildUUID() |
311 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 311 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
312 | const uuid = resVideo.body.video.uuid | 312 | const uuid = resVideo.body.video.uuid |
313 | 313 | ||
@@ -320,7 +320,7 @@ describe('Test moderation notifications', function () { | |||
320 | it('Should send a notification to video owner on unblacklist', async function () { | 320 | it('Should send a notification to video owner on unblacklist', async function () { |
321 | this.timeout(10000) | 321 | this.timeout(10000) |
322 | 322 | ||
323 | const name = 'video for abuse ' + uuidv4() | 323 | const name = 'video for abuse ' + buildUUID() |
324 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 324 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
325 | const uuid = resVideo.body.video.uuid | 325 | const uuid = resVideo.body.video.uuid |
326 | 326 | ||
@@ -507,7 +507,7 @@ describe('Test moderation notifications', function () { | |||
507 | it('Should send notification to moderators on new video with auto-blacklist', async function () { | 507 | it('Should send notification to moderators on new video with auto-blacklist', async function () { |
508 | this.timeout(40000) | 508 | this.timeout(40000) |
509 | 509 | ||
510 | videoName = 'video with auto-blacklist ' + uuidv4() | 510 | videoName = 'video with auto-blacklist ' + buildUUID() |
511 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName }) | 511 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName }) |
512 | videoUUID = resVideo.body.video.uuid | 512 | videoUUID = resVideo.body.video.uuid |
513 | 513 | ||
@@ -553,7 +553,7 @@ describe('Test moderation notifications', function () { | |||
553 | 553 | ||
554 | const updateAt = new Date(new Date().getTime() + 1000000) | 554 | const updateAt = new Date(new Date().getTime() + 1000000) |
555 | 555 | ||
556 | const name = 'video with auto-blacklist and future schedule ' + uuidv4() | 556 | const name = 'video with auto-blacklist and future schedule ' + buildUUID() |
557 | 557 | ||
558 | const data = { | 558 | const data = { |
559 | name, | 559 | name, |
@@ -586,7 +586,7 @@ describe('Test moderation notifications', function () { | |||
586 | // In 2 seconds | 586 | // In 2 seconds |
587 | const updateAt = new Date(new Date().getTime() + 2000) | 587 | const updateAt = new Date(new Date().getTime() + 2000) |
588 | 588 | ||
589 | const name = 'video with schedule done and still auto-blacklisted ' + uuidv4() | 589 | const name = 'video with schedule done and still auto-blacklisted ' + buildUUID() |
590 | 590 | ||
591 | const data = { | 591 | const data = { |
592 | name, | 592 | name, |
@@ -609,7 +609,7 @@ describe('Test moderation notifications', function () { | |||
609 | it('Should not send a notification to moderators on new video without auto-blacklist', async function () { | 609 | it('Should not send a notification to moderators on new video without auto-blacklist', async function () { |
610 | this.timeout(60000) | 610 | this.timeout(60000) |
611 | 611 | ||
612 | const name = 'video without auto-blacklist ' + uuidv4() | 612 | const name = 'video without auto-blacklist ' + buildUUID() |
613 | 613 | ||
614 | // admin with blacklist right will not be auto-blacklisted | 614 | // admin with blacklist right will not be auto-blacklisted |
615 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name }) | 615 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name }) |
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 7e88d979b..e981c1718 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { v4 as uuidv4 } from 'uuid' | 5 | import { buildUUID } from '@server/helpers/uuid' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | updateMyUser, | 8 | updateMyUser, |
@@ -207,7 +207,7 @@ describe('Test user notifications', function () { | |||
207 | it('Should send a new video notification after a video import', async function () { | 207 | it('Should send a new video notification after a video import', async function () { |
208 | this.timeout(100000) | 208 | this.timeout(100000) |
209 | 209 | ||
210 | const name = 'video import ' + uuidv4() | 210 | const name = 'video import ' + buildUUID() |
211 | 211 | ||
212 | const attributes = { | 212 | const attributes = { |
213 | name, | 213 | name, |
@@ -278,7 +278,7 @@ describe('Test user notifications', function () { | |||
278 | it('Should send a notification when an imported video is transcoded', async function () { | 278 | it('Should send a notification when an imported video is transcoded', async function () { |
279 | this.timeout(50000) | 279 | this.timeout(50000) |
280 | 280 | ||
281 | const name = 'video import ' + uuidv4() | 281 | const name = 'video import ' + buildUUID() |
282 | 282 | ||
283 | const attributes = { | 283 | const attributes = { |
284 | name, | 284 | name, |
@@ -347,7 +347,7 @@ describe('Test user notifications', function () { | |||
347 | it('Should send a notification when the video import failed', async function () { | 347 | it('Should send a notification when the video import failed', async function () { |
348 | this.timeout(70000) | 348 | this.timeout(70000) |
349 | 349 | ||
350 | const name = 'video import ' + uuidv4() | 350 | const name = 'video import ' + buildUUID() |
351 | 351 | ||
352 | const attributes = { | 352 | const attributes = { |
353 | name, | 353 | name, |
@@ -365,7 +365,7 @@ describe('Test user notifications', function () { | |||
365 | it('Should send a notification when the video import succeeded', async function () { | 365 | it('Should send a notification when the video import succeeded', async function () { |
366 | this.timeout(70000) | 366 | this.timeout(70000) |
367 | 367 | ||
368 | const name = 'video import ' + uuidv4() | 368 | const name = 'video import ' + buildUUID() |
369 | 369 | ||
370 | const attributes = { | 370 | const attributes = { |
371 | name, | 371 | name, |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index fe4a0e100..d57d72f5e 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -47,7 +47,7 @@ describe('Test handle downs', function () { | |||
47 | let missedVideo2: Video | 47 | let missedVideo2: Video |
48 | let unlistedVideo: Video | 48 | let unlistedVideo: Video |
49 | 49 | ||
50 | const videoIdsServer1: number[] = [] | 50 | const videoIdsServer1: string[] = [] |
51 | 51 | ||
52 | const videoAttributes = { | 52 | const videoAttributes = { |
53 | name: 'my super name for server 1', | 53 | name: 'my super name for server 1', |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 9dad58c8c..da8de054b 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -56,7 +56,7 @@ import { | |||
56 | removeServerFromServerBlocklist | 56 | removeServerFromServerBlocklist |
57 | } from '../../../../shared/extra-utils/users/blocklist' | 57 | } from '../../../../shared/extra-utils/users/blocklist' |
58 | import { User } from '../../../../shared/models/users' | 58 | import { User } from '../../../../shared/models/users' |
59 | import { VideoPrivacy } from '../../../../shared/models/videos' | 59 | import { VideoPlaylistCreateResult, VideoPrivacy } from '../../../../shared/models/videos' |
60 | import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' | 60 | import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' |
61 | import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' | 61 | import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' |
62 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 62 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
@@ -427,31 +427,45 @@ describe('Test video playlists', function () { | |||
427 | expect(data).to.have.lengthOf(0) | 427 | expect(data).to.have.lengthOf(0) |
428 | } | 428 | } |
429 | }) | 429 | }) |
430 | }) | ||
430 | 431 | ||
431 | it('Should not list unlisted or private playlists', async function () { | 432 | describe('Playlist rights', function () { |
433 | let unlistedPlaylist: VideoPlaylistCreateResult | ||
434 | let privatePlaylist: VideoPlaylistCreateResult | ||
435 | |||
436 | before(async function () { | ||
432 | this.timeout(30000) | 437 | this.timeout(30000) |
433 | 438 | ||
434 | await createVideoPlaylist({ | 439 | { |
435 | url: servers[1].url, | 440 | const res = await createVideoPlaylist({ |
436 | token: servers[1].accessToken, | 441 | url: servers[1].url, |
437 | playlistAttrs: { | 442 | token: servers[1].accessToken, |
438 | displayName: 'playlist unlisted', | 443 | playlistAttrs: { |
439 | privacy: VideoPlaylistPrivacy.UNLISTED | 444 | displayName: 'playlist unlisted', |
440 | } | 445 | privacy: VideoPlaylistPrivacy.UNLISTED, |
441 | }) | 446 | videoChannelId: servers[1].videoChannel.id |
447 | } | ||
448 | }) | ||
449 | unlistedPlaylist = res.body.videoPlaylist | ||
450 | } | ||
442 | 451 | ||
443 | await createVideoPlaylist({ | 452 | { |
444 | url: servers[1].url, | 453 | const res = await createVideoPlaylist({ |
445 | token: servers[1].accessToken, | 454 | url: servers[1].url, |
446 | playlistAttrs: { | 455 | token: servers[1].accessToken, |
447 | displayName: 'playlist private', | 456 | playlistAttrs: { |
448 | privacy: VideoPlaylistPrivacy.PRIVATE | 457 | displayName: 'playlist private', |
449 | } | 458 | privacy: VideoPlaylistPrivacy.PRIVATE |
450 | }) | 459 | } |
460 | }) | ||
461 | privatePlaylist = res.body.videoPlaylist | ||
462 | } | ||
451 | 463 | ||
452 | await waitJobs(servers) | 464 | await waitJobs(servers) |
453 | await wait(3000) | 465 | await wait(3000) |
466 | }) | ||
454 | 467 | ||
468 | it('Should not list unlisted or private playlists', async function () { | ||
455 | for (const server of servers) { | 469 | for (const server of servers) { |
456 | const results = [ | 470 | const results = [ |
457 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), | 471 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), |
@@ -469,6 +483,27 @@ describe('Test video playlists', function () { | |||
469 | } | 483 | } |
470 | } | 484 | } |
471 | }) | 485 | }) |
486 | |||
487 | it('Should not get unlisted playlist using only the id', async function () { | ||
488 | await getVideoPlaylist(servers[1].url, unlistedPlaylist.id, 404) | ||
489 | }) | ||
490 | |||
491 | it('Should get unlisted plyaylist using uuid or shortUUID', async function () { | ||
492 | await getVideoPlaylist(servers[1].url, unlistedPlaylist.uuid) | ||
493 | await getVideoPlaylist(servers[1].url, unlistedPlaylist.shortUUID) | ||
494 | }) | ||
495 | |||
496 | it('Should not get private playlist without token', async function () { | ||
497 | for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { | ||
498 | await getVideoPlaylist(servers[1].url, id, 401) | ||
499 | } | ||
500 | }) | ||
501 | |||
502 | it('Should get private playlist with a token', async function () { | ||
503 | for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { | ||
504 | await getVideoPlaylistWithToken(servers[1].url, servers[1].accessToken, id) | ||
505 | } | ||
506 | }) | ||
472 | }) | 507 | }) |
473 | 508 | ||
474 | describe('Update playlists', function () { | 509 | describe('Update playlists', function () { |
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index fed6ca0e0..950aeb7cf 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
6 | import { Video, VideoCreateResult } from '@shared/models' | ||
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
8 | flushAndRunServer, | 9 | flushAndRunServer, |
@@ -13,12 +14,11 @@ import { | |||
13 | uploadVideo | 14 | uploadVideo |
14 | } from '../../../../shared/extra-utils/index' | 15 | } from '../../../../shared/extra-utils/index' |
15 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 16 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
17 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
16 | import { userLogin } from '../../../../shared/extra-utils/users/login' | 18 | import { userLogin } from '../../../../shared/extra-utils/users/login' |
17 | import { createUser } from '../../../../shared/extra-utils/users/users' | 19 | import { createUser } from '../../../../shared/extra-utils/users/users' |
18 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' | 20 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 21 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
20 | import { Video } from '@shared/models' | ||
21 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
22 | 22 | ||
23 | const expect = chai.expect | 23 | const expect = chai.expect |
24 | 24 | ||
@@ -32,7 +32,7 @@ describe('Test video privacy', function () { | |||
32 | let internalVideoId: number | 32 | let internalVideoId: number |
33 | let internalVideoUUID: string | 33 | let internalVideoUUID: string |
34 | 34 | ||
35 | let unlistedVideoUUID: string | 35 | let unlistedVideo: VideoCreateResult |
36 | let nonFederatedUnlistedVideoUUID: string | 36 | let nonFederatedUnlistedVideoUUID: string |
37 | 37 | ||
38 | let now: number | 38 | let now: number |
@@ -59,231 +59,246 @@ describe('Test video privacy', function () { | |||
59 | await doubleFollow(servers[0], servers[1]) | 59 | await doubleFollow(servers[0], servers[1]) |
60 | }) | 60 | }) |
61 | 61 | ||
62 | it('Should upload a private and internal videos on server 1', async function () { | 62 | describe('Private and internal videos', function () { |
63 | this.timeout(10000) | ||
64 | 63 | ||
65 | for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { | 64 | it('Should upload a private and internal videos on server 1', async function () { |
66 | const attributes = { privacy } | 65 | this.timeout(10000) |
67 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
68 | } | ||
69 | 66 | ||
70 | await waitJobs(servers) | 67 | for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { |
71 | }) | 68 | const attributes = { privacy } |
69 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
70 | } | ||
72 | 71 | ||
73 | it('Should not have these private and internal videos on server 2', async function () { | 72 | await waitJobs(servers) |
74 | const res = await getVideosList(servers[1].url) | 73 | }) |
75 | 74 | ||
76 | expect(res.body.total).to.equal(0) | 75 | it('Should not have these private and internal videos on server 2', async function () { |
77 | expect(res.body.data).to.have.lengthOf(0) | 76 | const res = await getVideosList(servers[1].url) |
78 | }) | ||
79 | 77 | ||
80 | it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { | 78 | expect(res.body.total).to.equal(0) |
81 | const res = await getVideosList(servers[0].url) | 79 | expect(res.body.data).to.have.lengthOf(0) |
80 | }) | ||
82 | 81 | ||
83 | expect(res.body.total).to.equal(0) | 82 | it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { |
84 | expect(res.body.data).to.have.lengthOf(0) | 83 | const res = await getVideosList(servers[0].url) |
85 | }) | 84 | |
85 | expect(res.body.total).to.equal(0) | ||
86 | expect(res.body.data).to.have.lengthOf(0) | ||
87 | }) | ||
86 | 88 | ||
87 | it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { | 89 | it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { |
88 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) | 90 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) |
89 | 91 | ||
90 | expect(res.body.total).to.equal(1) | 92 | expect(res.body.total).to.equal(1) |
91 | expect(res.body.data).to.have.lengthOf(1) | 93 | expect(res.body.data).to.have.lengthOf(1) |
92 | 94 | ||
93 | expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) | 95 | expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) |
94 | }) | 96 | }) |
95 | 97 | ||
96 | it('Should list my (private and internal) videos', async function () { | 98 | it('Should list my (private and internal) videos', async function () { |
97 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) | 99 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) |
98 | 100 | ||
99 | expect(res.body.total).to.equal(2) | 101 | expect(res.body.total).to.equal(2) |
100 | expect(res.body.data).to.have.lengthOf(2) | 102 | expect(res.body.data).to.have.lengthOf(2) |
101 | 103 | ||
102 | const videos: Video[] = res.body.data | 104 | const videos: Video[] = res.body.data |
103 | 105 | ||
104 | const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE) | 106 | const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE) |
105 | privateVideoId = privateVideo.id | 107 | privateVideoId = privateVideo.id |
106 | privateVideoUUID = privateVideo.uuid | 108 | privateVideoUUID = privateVideo.uuid |
107 | 109 | ||
108 | const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) | 110 | const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) |
109 | internalVideoId = internalVideo.id | 111 | internalVideoId = internalVideo.id |
110 | internalVideoUUID = internalVideo.uuid | 112 | internalVideoUUID = internalVideo.uuid |
111 | }) | 113 | }) |
112 | 114 | ||
113 | it('Should not be able to watch the private/internal video with non authenticated user', async function () { | 115 | it('Should not be able to watch the private/internal video with non authenticated user', async function () { |
114 | await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) | 116 | await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) |
115 | await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) | 117 | await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) |
116 | }) | 118 | }) |
117 | 119 | ||
118 | it('Should not be able to watch the private video with another user', async function () { | 120 | it('Should not be able to watch the private video with another user', async function () { |
119 | this.timeout(10000) | 121 | this.timeout(10000) |
120 | 122 | ||
121 | const user = { | 123 | const user = { |
122 | username: 'hello', | 124 | username: 'hello', |
123 | password: 'super password' | 125 | password: 'super password' |
124 | } | 126 | } |
125 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 127 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
126 | 128 | ||
127 | anotherUserToken = await userLogin(servers[0], user) | 129 | anotherUserToken = await userLogin(servers[0], user) |
128 | await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) | 130 | await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) |
129 | }) | 131 | }) |
130 | 132 | ||
131 | it('Should be able to watch the internal video with another user', async function () { | 133 | it('Should be able to watch the internal video with another user', async function () { |
132 | await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) | 134 | await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) |
133 | }) | 135 | }) |
134 | 136 | ||
135 | it('Should be able to watch the private video with the correct user', async function () { | 137 | it('Should be able to watch the private video with the correct user', async function () { |
136 | await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) | 138 | await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) |
139 | }) | ||
137 | }) | 140 | }) |
138 | 141 | ||
139 | it('Should upload an unlisted video on server 2', async function () { | 142 | describe('Unlisted videos', function () { |
140 | this.timeout(60000) | ||
141 | 143 | ||
142 | const attributes = { | 144 | it('Should upload an unlisted video on server 2', async function () { |
143 | name: 'unlisted video', | 145 | this.timeout(60000) |
144 | privacy: VideoPrivacy.UNLISTED | ||
145 | } | ||
146 | await uploadVideo(servers[1].url, servers[1].accessToken, attributes) | ||
147 | 146 | ||
148 | // Server 2 has transcoding enabled | 147 | const attributes = { |
149 | await waitJobs(servers) | 148 | name: 'unlisted video', |
150 | }) | 149 | privacy: VideoPrivacy.UNLISTED |
150 | } | ||
151 | await uploadVideo(servers[1].url, servers[1].accessToken, attributes) | ||
151 | 152 | ||
152 | it('Should not have this unlisted video listed on server 1 and 2', async function () { | 153 | // Server 2 has transcoding enabled |
153 | for (const server of servers) { | 154 | await waitJobs(servers) |
154 | const res = await getVideosList(server.url) | 155 | }) |
155 | 156 | ||
156 | expect(res.body.total).to.equal(0) | 157 | it('Should not have this unlisted video listed on server 1 and 2', async function () { |
157 | expect(res.body.data).to.have.lengthOf(0) | 158 | for (const server of servers) { |
158 | } | 159 | const res = await getVideosList(server.url) |
159 | }) | ||
160 | 160 | ||
161 | it('Should list my (unlisted) videos', async function () { | 161 | expect(res.body.total).to.equal(0) |
162 | const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) | 162 | expect(res.body.data).to.have.lengthOf(0) |
163 | } | ||
164 | }) | ||
163 | 165 | ||
164 | expect(res.body.total).to.equal(1) | 166 | it('Should list my (unlisted) videos', async function () { |
165 | expect(res.body.data).to.have.lengthOf(1) | 167 | const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) |
166 | 168 | ||
167 | unlistedVideoUUID = res.body.data[0].uuid | 169 | expect(res.body.total).to.equal(1) |
168 | }) | 170 | expect(res.body.data).to.have.lengthOf(1) |
169 | 171 | ||
170 | it('Should be able to get this unlisted video', async function () { | 172 | unlistedVideo = res.body.data[0] |
171 | for (const server of servers) { | 173 | }) |
172 | const res = await getVideo(server.url, unlistedVideoUUID) | ||
173 | 174 | ||
174 | expect(res.body.name).to.equal('unlisted video') | 175 | it('Should not be able to get this unlisted video using its id', async function () { |
175 | } | 176 | await getVideo(servers[1].url, unlistedVideo.id, 404) |
176 | }) | 177 | }) |
177 | 178 | ||
178 | it('Should upload a non-federating unlisted video to server 1', async function () { | 179 | it('Should be able to get this unlisted video using its uuid/shortUUID', async function () { |
179 | this.timeout(30000) | 180 | for (const server of servers) { |
181 | for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { | ||
182 | const res = await getVideo(server.url, id) | ||
180 | 183 | ||
181 | const attributes = { | 184 | expect(res.body.name).to.equal('unlisted video') |
182 | name: 'unlisted video', | 185 | } |
183 | privacy: VideoPrivacy.UNLISTED | 186 | } |
184 | } | 187 | }) |
185 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
186 | 188 | ||
187 | await waitJobs(servers) | 189 | it('Should upload a non-federating unlisted video to server 1', async function () { |
188 | }) | 190 | this.timeout(30000) |
191 | |||
192 | const attributes = { | ||
193 | name: 'unlisted video', | ||
194 | privacy: VideoPrivacy.UNLISTED | ||
195 | } | ||
196 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
189 | 197 | ||
190 | it('Should list my new unlisted video', async function () { | 198 | await waitJobs(servers) |
191 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) | 199 | }) |
192 | 200 | ||
193 | expect(res.body.total).to.equal(3) | 201 | it('Should list my new unlisted video', async function () { |
194 | expect(res.body.data).to.have.lengthOf(3) | 202 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) |
195 | 203 | ||
196 | nonFederatedUnlistedVideoUUID = res.body.data[0].uuid | 204 | expect(res.body.total).to.equal(3) |
197 | }) | 205 | expect(res.body.data).to.have.lengthOf(3) |
198 | 206 | ||
199 | it('Should be able to get non-federated unlisted video from origin', async function () { | 207 | nonFederatedUnlistedVideoUUID = res.body.data[0].uuid |
200 | const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) | 208 | }) |
201 | 209 | ||
202 | expect(res.body.name).to.equal('unlisted video') | 210 | it('Should be able to get non-federated unlisted video from origin', async function () { |
203 | }) | 211 | const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) |
204 | 212 | ||
205 | it('Should not be able to get non-federated unlisted video from federated server', async function () { | 213 | expect(res.body.name).to.equal('unlisted video') |
206 | await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) | 214 | }) |
215 | |||
216 | it('Should not be able to get non-federated unlisted video from federated server', async function () { | ||
217 | await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) | ||
218 | }) | ||
207 | }) | 219 | }) |
208 | 220 | ||
209 | it('Should update the private and internal videos to public on server 1', async function () { | 221 | describe('Privacy update', function () { |
210 | this.timeout(10000) | ||
211 | 222 | ||
212 | now = Date.now() | 223 | it('Should update the private and internal videos to public on server 1', async function () { |
224 | this.timeout(10000) | ||
213 | 225 | ||
214 | { | 226 | now = Date.now() |
215 | const attribute = { | ||
216 | name: 'private video becomes public', | ||
217 | privacy: VideoPrivacy.PUBLIC | ||
218 | } | ||
219 | 227 | ||
220 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) | 228 | { |
221 | } | 229 | const attribute = { |
230 | name: 'private video becomes public', | ||
231 | privacy: VideoPrivacy.PUBLIC | ||
232 | } | ||
222 | 233 | ||
223 | { | 234 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) |
224 | const attribute = { | ||
225 | name: 'internal video becomes public', | ||
226 | privacy: VideoPrivacy.PUBLIC | ||
227 | } | 235 | } |
228 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) | ||
229 | } | ||
230 | 236 | ||
231 | await waitJobs(servers) | 237 | { |
232 | }) | 238 | const attribute = { |
239 | name: 'internal video becomes public', | ||
240 | privacy: VideoPrivacy.PUBLIC | ||
241 | } | ||
242 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) | ||
243 | } | ||
233 | 244 | ||
234 | it('Should have this new public video listed on server 1 and 2', async function () { | 245 | await waitJobs(servers) |
235 | for (const server of servers) { | 246 | }) |
236 | const res = await getVideosList(server.url) | ||
237 | expect(res.body.total).to.equal(2) | ||
238 | expect(res.body.data).to.have.lengthOf(2) | ||
239 | 247 | ||
240 | const videos: Video[] = res.body.data | 248 | it('Should have this new public video listed on server 1 and 2', async function () { |
241 | const privateVideo = videos.find(v => v.name === 'private video becomes public') | 249 | for (const server of servers) { |
242 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | 250 | const res = await getVideosList(server.url) |
251 | expect(res.body.total).to.equal(2) | ||
252 | expect(res.body.data).to.have.lengthOf(2) | ||
243 | 253 | ||
244 | expect(privateVideo).to.not.be.undefined | 254 | const videos: Video[] = res.body.data |
245 | expect(internalVideo).to.not.be.undefined | 255 | const privateVideo = videos.find(v => v.name === 'private video becomes public') |
256 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | ||
246 | 257 | ||
247 | expect(new Date(privateVideo.publishedAt).getTime()).to.be.at.least(now) | 258 | expect(privateVideo).to.not.be.undefined |
248 | // We don't change the publish date of internal videos | 259 | expect(internalVideo).to.not.be.undefined |
249 | expect(new Date(internalVideo.publishedAt).getTime()).to.be.below(now) | ||
250 | 260 | ||
251 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) | 261 | expect(new Date(privateVideo.publishedAt).getTime()).to.be.at.least(now) |
252 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) | 262 | // We don't change the publish date of internal videos |
253 | } | 263 | expect(new Date(internalVideo.publishedAt).getTime()).to.be.below(now) |
254 | }) | ||
255 | 264 | ||
256 | it('Should set these videos as private and internal', async function () { | 265 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) |
257 | this.timeout(10000) | 266 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) |
267 | } | ||
268 | }) | ||
258 | 269 | ||
259 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) | 270 | it('Should set these videos as private and internal', async function () { |
260 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) | 271 | this.timeout(10000) |
261 | 272 | ||
262 | await waitJobs(servers) | 273 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) |
274 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) | ||
263 | 275 | ||
264 | for (const server of servers) { | 276 | await waitJobs(servers) |
265 | const res = await getVideosList(server.url) | ||
266 | 277 | ||
267 | expect(res.body.total).to.equal(0) | 278 | for (const server of servers) { |
268 | expect(res.body.data).to.have.lengthOf(0) | 279 | const res = await getVideosList(server.url) |
269 | } | 280 | |
281 | expect(res.body.total).to.equal(0) | ||
282 | expect(res.body.data).to.have.lengthOf(0) | ||
283 | } | ||
270 | 284 | ||
271 | { | 285 | { |
272 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) | 286 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) |
273 | const videos = res.body.data | 287 | const videos = res.body.data |
274 | 288 | ||
275 | expect(res.body.total).to.equal(3) | 289 | expect(res.body.total).to.equal(3) |
276 | expect(videos).to.have.lengthOf(3) | 290 | expect(videos).to.have.lengthOf(3) |
277 | 291 | ||
278 | const privateVideo = videos.find(v => v.name === 'private video becomes public') | 292 | const privateVideo = videos.find(v => v.name === 'private video becomes public') |
279 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | 293 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') |
280 | 294 | ||
281 | expect(privateVideo).to.not.be.undefined | 295 | expect(privateVideo).to.not.be.undefined |
282 | expect(internalVideo).to.not.be.undefined | 296 | expect(internalVideo).to.not.be.undefined |
283 | 297 | ||
284 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.INTERNAL) | 298 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.INTERNAL) |
285 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PRIVATE) | 299 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PRIVATE) |
286 | } | 300 | } |
301 | }) | ||
287 | }) | 302 | }) |
288 | 303 | ||
289 | after(async function () { | 304 | after(async function () { |