aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/video-playlists.ts117
1 files changed, 117 insertions, 0 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
new file mode 100644
index 000000000..7004badac
--- /dev/null
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -0,0 +1,117 @@
1/* tslint:disable:no-unused-expression */
2
3import { omit } from 'lodash'
4import 'mocha'
5import { join } from 'path'
6import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
7import {
8 createUser,
9 flushTests,
10 getMyUserInformation,
11 immutableAssign,
12 killallServers,
13 makeGetRequest,
14 makePostBodyRequest,
15 makeUploadRequest,
16 runServer,
17 ServerInfo,
18 setAccessTokensToServers,
19 updateCustomSubConfig,
20 userLogin
21} from '../../../../shared/utils'
22import {
23 checkBadCountPagination,
24 checkBadSortPagination,
25 checkBadStartPagination
26} from '../../../../shared/utils/requests/check-api-params'
27import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/utils/videos/video-imports'
28
29describe('Test video playlists API validator', function () {
30 const path = '/api/v1/videos/video-playlists'
31 let server: ServerInfo
32 let userAccessToken = ''
33
34 // ---------------------------------------------------------------
35
36 before(async function () {
37 this.timeout(30000)
38
39 await flushTests()
40
41 server = await runServer(1)
42
43 await setAccessTokensToServers([ server ])
44
45 const username = 'user1'
46 const password = 'my super password'
47 await createUser(server.url, server.accessToken, username, password)
48 userAccessToken = await userLogin(server, { username, password })
49 })
50
51 describe('When listing video playlists', function () {
52 const globalPath = '/api/v1/video-playlists'
53 const accountPath = '/api/v1/accounts/root/video-playlists'
54 const videoChannelPath = '/api/v1/video-channels/root_channel/video-playlists'
55
56 it('Should fail with a bad start pagination', async function () {
57 await checkBadStartPagination(server.url, globalPath, server.accessToken)
58 await checkBadStartPagination(server.url, accountPath, server.accessToken)
59 await checkBadStartPagination(server.url, videoChannelPath, server.accessToken)
60 })
61
62 it('Should fail with a bad count pagination', async function () {
63 await checkBadCountPagination(server.url, globalPath, server.accessToken)
64 await checkBadCountPagination(server.url, accountPath, server.accessToken)
65 await checkBadCountPagination(server.url, videoChannelPath, server.accessToken)
66 })
67
68 it('Should fail with an incorrect sort', async function () {
69 await checkBadSortPagination(server.url, globalPath, server.accessToken)
70 await checkBadSortPagination(server.url, accountPath, server.accessToken)
71 await checkBadSortPagination(server.url, videoChannelPath, server.accessToken)
72 })
73
74 it('Should fail with a bad account parameter', async function () {
75 const accountPath = '/api/v1/accounts/root2/video-playlists'
76
77 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken })
78 })
79
80 it('Should fail with a bad video channel parameter', async function () {
81 const accountPath = '/api/v1/video-channels/bad_channel/video-playlists'
82
83 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken })
84 })
85
86 it('Should success with the correct parameters', async function () {
87 await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: 200, token: server.accessToken })
88 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 200, token: server.accessToken })
89 await makeGetRequest({ url: server.url, path: videoChannelPath, statusCodeExpected: 200, token: server.accessToken })
90 })
91 })
92
93 describe('When listing videos of a playlist', async function () {
94 const path = '/api/v1/video-playlists'
95
96 it('Should fail with a bad start pagination', async function () {
97 await checkBadStartPagination(server.url, path, server.accessToken)
98 })
99
100 it('Should fail with a bad count pagination', async function () {
101 await checkBadCountPagination(server.url, path, server.accessToken)
102 })
103
104 it('Should fail with an incorrect sort', async function () {
105 await checkBadSortPagination(server.url, path, server.accessToken)
106 })
107 })
108
109 after(async function () {
110 killallServers([ server ])
111
112 // Keep the logs if the test failed
113 if (this['ok']) {
114 await flushTests()
115 }
116 })
117})