diff options
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/video-playlists.ts | 34 | ||||
-rw-r--r-- | server/tests/api/check-params/videos-filter.ts | 26 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 2 |
3 files changed, 26 insertions, 36 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index 8c5e44bdd..ae5aa287f 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -37,6 +37,7 @@ describe('Test video playlists API validator', function () { | |||
37 | let watchLaterPlaylistId: number | 37 | let watchLaterPlaylistId: number |
38 | let videoId: number | 38 | let videoId: number |
39 | let videoId2: number | 39 | let videoId2: number |
40 | let playlistElementId: number | ||
40 | 41 | ||
41 | // --------------------------------------------------------------- | 42 | // --------------------------------------------------------------- |
42 | 43 | ||
@@ -132,18 +133,18 @@ describe('Test video playlists API validator', function () { | |||
132 | }) | 133 | }) |
133 | 134 | ||
134 | describe('When listing videos of a playlist', function () { | 135 | describe('When listing videos of a playlist', function () { |
135 | const path = '/api/v1/video-playlists' | 136 | const path = '/api/v1/video-playlists/' |
136 | 137 | ||
137 | it('Should fail with a bad start pagination', async function () { | 138 | it('Should fail with a bad start pagination', async function () { |
138 | await checkBadStartPagination(server.url, path, server.accessToken) | 139 | await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken) |
139 | }) | 140 | }) |
140 | 141 | ||
141 | it('Should fail with a bad count pagination', async function () { | 142 | it('Should fail with a bad count pagination', async function () { |
142 | await checkBadCountPagination(server.url, path, server.accessToken) | 143 | await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken) |
143 | }) | 144 | }) |
144 | 145 | ||
145 | it('Should fail with a bad filter', async function () { | 146 | it('Should success with the correct parameters', async function () { |
146 | await checkBadSortPagination(server.url, path, server.accessToken) | 147 | await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: 200 }) |
147 | }) | 148 | }) |
148 | }) | 149 | }) |
149 | 150 | ||
@@ -296,7 +297,7 @@ describe('Test video playlists API validator', function () { | |||
296 | token: server.accessToken, | 297 | token: server.accessToken, |
297 | playlistId: playlistUUID, | 298 | playlistId: playlistUUID, |
298 | elementAttrs: Object.assign({ | 299 | elementAttrs: Object.assign({ |
299 | videoId: videoId, | 300 | videoId, |
300 | startTimestamp: 2, | 301 | startTimestamp: 2, |
301 | stopTimestamp: 3 | 302 | stopTimestamp: 3 |
302 | }, elementAttrs) | 303 | }, elementAttrs) |
@@ -344,7 +345,8 @@ describe('Test video playlists API validator', function () { | |||
344 | 345 | ||
345 | it('Succeed with the correct params', async function () { | 346 | it('Succeed with the correct params', async function () { |
346 | const params = getBase({}, { expectedStatus: 200 }) | 347 | const params = getBase({}, { expectedStatus: 200 }) |
347 | await addVideoInPlaylist(params) | 348 | const res = await addVideoInPlaylist(params) |
349 | playlistElementId = res.body.videoPlaylistElement.id | ||
348 | }) | 350 | }) |
349 | 351 | ||
350 | it('Should fail if the video was already added in the playlist', async function () { | 352 | it('Should fail if the video was already added in the playlist', async function () { |
@@ -362,7 +364,7 @@ describe('Test video playlists API validator', function () { | |||
362 | startTimestamp: 1, | 364 | startTimestamp: 1, |
363 | stopTimestamp: 2 | 365 | stopTimestamp: 2 |
364 | }, elementAttrs), | 366 | }, elementAttrs), |
365 | videoId: videoId, | 367 | playlistElementId, |
366 | playlistId: playlistUUID, | 368 | playlistId: playlistUUID, |
367 | expectedStatus: 400 | 369 | expectedStatus: 400 |
368 | }, wrapper) | 370 | }, wrapper) |
@@ -390,14 +392,14 @@ describe('Test video playlists API validator', function () { | |||
390 | } | 392 | } |
391 | }) | 393 | }) |
392 | 394 | ||
393 | it('Should fail with an unknown or incorrect video id', async function () { | 395 | it('Should fail with an unknown or incorrect playlistElement id', async function () { |
394 | { | 396 | { |
395 | const params = getBase({}, { videoId: 'toto' }) | 397 | const params = getBase({}, { playlistElementId: 'toto' }) |
396 | await updateVideoPlaylistElement(params) | 398 | await updateVideoPlaylistElement(params) |
397 | } | 399 | } |
398 | 400 | ||
399 | { | 401 | { |
400 | const params = getBase({}, { videoId: 42, expectedStatus: 404 }) | 402 | const params = getBase({}, { playlistElementId: 42, expectedStatus: 404 }) |
401 | await updateVideoPlaylistElement(params) | 403 | await updateVideoPlaylistElement(params) |
402 | } | 404 | } |
403 | }) | 405 | }) |
@@ -415,7 +417,7 @@ describe('Test video playlists API validator', function () { | |||
415 | }) | 417 | }) |
416 | 418 | ||
417 | it('Should fail with an unknown element', async function () { | 419 | it('Should fail with an unknown element', async function () { |
418 | const params = getBase({}, { videoId: videoId2, expectedStatus: 404 }) | 420 | const params = getBase({}, { playlistElementId: 888, expectedStatus: 404 }) |
419 | await updateVideoPlaylistElement(params) | 421 | await updateVideoPlaylistElement(params) |
420 | }) | 422 | }) |
421 | 423 | ||
@@ -587,7 +589,7 @@ describe('Test video playlists API validator', function () { | |||
587 | return Object.assign({ | 589 | return Object.assign({ |
588 | url: server.url, | 590 | url: server.url, |
589 | token: server.accessToken, | 591 | token: server.accessToken, |
590 | videoId: videoId, | 592 | playlistElementId, |
591 | playlistId: playlistUUID, | 593 | playlistId: playlistUUID, |
592 | expectedStatus: 400 | 594 | expectedStatus: 400 |
593 | }, wrapper) | 595 | }, wrapper) |
@@ -617,18 +619,18 @@ describe('Test video playlists API validator', function () { | |||
617 | 619 | ||
618 | it('Should fail with an unknown or incorrect video id', async function () { | 620 | it('Should fail with an unknown or incorrect video id', async function () { |
619 | { | 621 | { |
620 | const params = getBase({ videoId: 'toto' }) | 622 | const params = getBase({ playlistElementId: 'toto' }) |
621 | await removeVideoFromPlaylist(params) | 623 | await removeVideoFromPlaylist(params) |
622 | } | 624 | } |
623 | 625 | ||
624 | { | 626 | { |
625 | const params = getBase({ videoId: 42, expectedStatus: 404 }) | 627 | const params = getBase({ playlistElementId: 42, expectedStatus: 404 }) |
626 | await removeVideoFromPlaylist(params) | 628 | await removeVideoFromPlaylist(params) |
627 | } | 629 | } |
628 | }) | 630 | }) |
629 | 631 | ||
630 | it('Should fail with an unknown element', async function () { | 632 | it('Should fail with an unknown element', async function () { |
631 | const params = getBase({ videoId: videoId2, expectedStatus: 404 }) | 633 | const params = getBase({ playlistElementId: 888, expectedStatus: 404 }) |
632 | await removeVideoFromPlaylist(params) | 634 | await removeVideoFromPlaylist(params) |
633 | }) | 635 | }) |
634 | 636 | ||
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index babef8223..5a5668665 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts | |||
@@ -15,13 +15,12 @@ import { | |||
15 | import { UserRole } from '../../../../shared/models/users' | 15 | import { UserRole } from '../../../../shared/models/users' |
16 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 16 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
17 | 17 | ||
18 | async function testEndpoints (server: ServerInfo, token: string, filter: string, playlistUUID: string, statusCodeExpected: number) { | 18 | async function testEndpoints (server: ServerInfo, token: string, filter: string, statusCodeExpected: number) { |
19 | const paths = [ | 19 | const paths = [ |
20 | '/api/v1/video-channels/root_channel/videos', | 20 | '/api/v1/video-channels/root_channel/videos', |
21 | '/api/v1/accounts/root/videos', | 21 | '/api/v1/accounts/root/videos', |
22 | '/api/v1/videos', | 22 | '/api/v1/videos', |
23 | '/api/v1/search/videos', | 23 | '/api/v1/search/videos' |
24 | '/api/v1/video-playlists/' + playlistUUID + '/videos' | ||
25 | ] | 24 | ] |
26 | 25 | ||
27 | for (const path of paths) { | 26 | for (const path of paths) { |
@@ -70,39 +69,28 @@ describe('Test videos filters', function () { | |||
70 | } | 69 | } |
71 | ) | 70 | ) |
72 | moderatorAccessToken = await userLogin(server, moderator) | 71 | moderatorAccessToken = await userLogin(server, moderator) |
73 | |||
74 | const res = await createVideoPlaylist({ | ||
75 | url: server.url, | ||
76 | token: server.accessToken, | ||
77 | playlistAttrs: { | ||
78 | displayName: 'super playlist', | ||
79 | privacy: VideoPlaylistPrivacy.PUBLIC, | ||
80 | videoChannelId: server.videoChannel.id | ||
81 | } | ||
82 | }) | ||
83 | playlistUUID = res.body.videoPlaylist.uuid | ||
84 | }) | 72 | }) |
85 | 73 | ||
86 | describe('When setting a video filter', function () { | 74 | describe('When setting a video filter', function () { |
87 | 75 | ||
88 | it('Should fail with a bad filter', async function () { | 76 | it('Should fail with a bad filter', async function () { |
89 | await testEndpoints(server, server.accessToken, 'bad-filter', playlistUUID, 400) | 77 | await testEndpoints(server, server.accessToken, 'bad-filter', 400) |
90 | }) | 78 | }) |
91 | 79 | ||
92 | it('Should succeed with a good filter', async function () { | 80 | it('Should succeed with a good filter', async function () { |
93 | await testEndpoints(server, server.accessToken,'local', playlistUUID, 200) | 81 | await testEndpoints(server, server.accessToken,'local', 200) |
94 | }) | 82 | }) |
95 | 83 | ||
96 | it('Should fail to list all-local with a simple user', async function () { | 84 | it('Should fail to list all-local with a simple user', async function () { |
97 | await testEndpoints(server, userAccessToken, 'all-local', playlistUUID, 401) | 85 | await testEndpoints(server, userAccessToken, 'all-local', 401) |
98 | }) | 86 | }) |
99 | 87 | ||
100 | it('Should succeed to list all-local with a moderator', async function () { | 88 | it('Should succeed to list all-local with a moderator', async function () { |
101 | await testEndpoints(server, moderatorAccessToken, 'all-local', playlistUUID, 200) | 89 | await testEndpoints(server, moderatorAccessToken, 'all-local', 200) |
102 | }) | 90 | }) |
103 | 91 | ||
104 | it('Should succeed to list all-local with an admin', async function () { | 92 | it('Should succeed to list all-local with an admin', async function () { |
105 | await testEndpoints(server, server.accessToken, 'all-local', playlistUUID, 200) | 93 | await testEndpoints(server, server.accessToken, 'all-local', 200) |
106 | }) | 94 | }) |
107 | 95 | ||
108 | // Because we cannot authenticate the user on the RSS endpoint | 96 | // Because we cannot authenticate the user on the RSS endpoint |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 51e592a15..fa6d6f622 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -62,7 +62,7 @@ describe('Test videos API validator', function () { | |||
62 | } | 62 | } |
63 | }) | 63 | }) |
64 | 64 | ||
65 | describe('When listing a video', function () { | 65 | describe('When listing videos', function () { |
66 | it('Should fail with a bad start pagination', async function () { | 66 | it('Should fail with a bad start pagination', async function () { |
67 | await checkBadStartPagination(server.url, path) | 67 | await checkBadStartPagination(server.url, path) |
68 | }) | 68 | }) |