diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-28 11:14:26 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 07b1a18aa678d260009a93e36606c5c5f585723d (patch) | |
tree | 27a399fa0f7a29a7ac1d7d7cf077a24ea6ee39de /server/tests/api/check-params/videos-filter.ts | |
parent | 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (diff) | |
download | PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.tar.gz PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.tar.zst PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.zip |
Add playlist check param tests
Diffstat (limited to 'server/tests/api/check-params/videos-filter.ts')
-rw-r--r-- | server/tests/api/check-params/videos-filter.ts | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index e998c8a3d..cc2f35069 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { | 4 | import { |
6 | createUser, | 5 | createUser, |
6 | createVideoPlaylist, | ||
7 | flushTests, | 7 | flushTests, |
8 | killallServers, | 8 | killallServers, |
9 | makeGetRequest, | 9 | makeGetRequest, |
@@ -13,15 +13,15 @@ import { | |||
13 | userLogin | 13 | userLogin |
14 | } from '../../../../shared/utils' | 14 | } from '../../../../shared/utils' |
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 | 17 | ||
17 | const expect = chai.expect | 18 | async function testEndpoints (server: ServerInfo, token: string, filter: string, playlistUUID: string, statusCodeExpected: number) { |
18 | |||
19 | async function testEndpoints (server: ServerInfo, token: string, filter: string, statusCodeExpected: number) { | ||
20 | const paths = [ | 19 | const paths = [ |
21 | '/api/v1/video-channels/root_channel/videos', | 20 | '/api/v1/video-channels/root_channel/videos', |
22 | '/api/v1/accounts/root/videos', | 21 | '/api/v1/accounts/root/videos', |
23 | '/api/v1/videos', | 22 | '/api/v1/videos', |
24 | '/api/v1/search/videos' | 23 | '/api/v1/search/videos', |
24 | '/api/v1/video-playlists/' + playlistUUID + '/videos' | ||
25 | ] | 25 | ] |
26 | 26 | ||
27 | for (const path of paths) { | 27 | for (const path of paths) { |
@@ -41,6 +41,7 @@ describe('Test videos filters', function () { | |||
41 | let server: ServerInfo | 41 | let server: ServerInfo |
42 | let userAccessToken: string | 42 | let userAccessToken: string |
43 | let moderatorAccessToken: string | 43 | let moderatorAccessToken: string |
44 | let playlistUUID: string | ||
44 | 45 | ||
45 | // --------------------------------------------------------------- | 46 | // --------------------------------------------------------------- |
46 | 47 | ||
@@ -68,28 +69,38 @@ describe('Test videos filters', function () { | |||
68 | UserRole.MODERATOR | 69 | UserRole.MODERATOR |
69 | ) | 70 | ) |
70 | moderatorAccessToken = await userLogin(server, moderator) | 71 | moderatorAccessToken = await userLogin(server, moderator) |
72 | |||
73 | const res = await createVideoPlaylist({ | ||
74 | url: server.url, | ||
75 | token: server.accessToken, | ||
76 | playlistAttrs: { | ||
77 | displayName: 'super playlist', | ||
78 | privacy: VideoPlaylistPrivacy.PUBLIC | ||
79 | } | ||
80 | }) | ||
81 | playlistUUID = res.body.videoPlaylist.uuid | ||
71 | }) | 82 | }) |
72 | 83 | ||
73 | describe('When setting a video filter', function () { | 84 | describe('When setting a video filter', function () { |
74 | 85 | ||
75 | it('Should fail with a bad filter', async function () { | 86 | it('Should fail with a bad filter', async function () { |
76 | await testEndpoints(server, server.accessToken, 'bad-filter', 400) | 87 | await testEndpoints(server, server.accessToken, 'bad-filter', playlistUUID, 400) |
77 | }) | 88 | }) |
78 | 89 | ||
79 | it('Should succeed with a good filter', async function () { | 90 | it('Should succeed with a good filter', async function () { |
80 | await testEndpoints(server, server.accessToken,'local', 200) | 91 | await testEndpoints(server, server.accessToken,'local', playlistUUID, 200) |
81 | }) | 92 | }) |
82 | 93 | ||
83 | it('Should fail to list all-local with a simple user', async function () { | 94 | it('Should fail to list all-local with a simple user', async function () { |
84 | await testEndpoints(server, userAccessToken, 'all-local', 401) | 95 | await testEndpoints(server, userAccessToken, 'all-local', playlistUUID, 401) |
85 | }) | 96 | }) |
86 | 97 | ||
87 | it('Should succeed to list all-local with a moderator', async function () { | 98 | it('Should succeed to list all-local with a moderator', async function () { |
88 | await testEndpoints(server, moderatorAccessToken, 'all-local', 200) | 99 | await testEndpoints(server, moderatorAccessToken, 'all-local', playlistUUID, 200) |
89 | }) | 100 | }) |
90 | 101 | ||
91 | it('Should succeed to list all-local with an admin', async function () { | 102 | it('Should succeed to list all-local with an admin', async function () { |
92 | await testEndpoints(server, server.accessToken, 'all-local', 200) | 103 | await testEndpoints(server, server.accessToken, 'all-local', playlistUUID, 200) |
93 | }) | 104 | }) |
94 | 105 | ||
95 | // Because we cannot authenticate the user on the RSS endpoint | 106 | // Because we cannot authenticate the user on the RSS endpoint |
@@ -104,7 +115,7 @@ describe('Test videos filters', function () { | |||
104 | }) | 115 | }) |
105 | }) | 116 | }) |
106 | 117 | ||
107 | it('Should succed on the feeds endpoint with the local filter', async function () { | 118 | it('Should succeed on the feeds endpoint with the local filter', async function () { |
108 | await makeGetRequest({ | 119 | await makeGetRequest({ |
109 | url: server.url, | 120 | url: server.url, |
110 | path: '/feeds/videos.json', | 121 | path: '/feeds/videos.json', |