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/blocklist.ts2
-rw-r--r--server/tests/api/check-params/config.ts2
-rw-r--r--server/tests/api/check-params/debug.ts2
-rw-r--r--server/tests/api/check-params/follows.ts2
-rw-r--r--server/tests/api/check-params/jobs.ts2
-rw-r--r--server/tests/api/check-params/logs.ts2
-rw-r--r--server/tests/api/check-params/redundancy.ts2
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts2
-rw-r--r--server/tests/api/check-params/users.ts24
-rw-r--r--server/tests/api/check-params/video-abuses.ts2
-rw-r--r--server/tests/api/check-params/video-blacklist.ts13
-rw-r--r--server/tests/api/check-params/video-captions.ts2
-rw-r--r--server/tests/api/check-params/video-channels.ts2
-rw-r--r--server/tests/api/check-params/video-comments.ts2
-rw-r--r--server/tests/api/check-params/video-imports.ts4
-rw-r--r--server/tests/api/check-params/videos-filter.ts18
-rw-r--r--server/tests/api/check-params/videos.ts4
17 files changed, 54 insertions, 33 deletions
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index c20453c16..62a2c2a52 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -36,7 +36,7 @@ describe('Test blocklist API validators', function () {
36 server = servers[0] 36 server = servers[0]
37 37
38 const user = { username: 'user1', password: 'password' } 38 const user = { username: 'user1', password: 'password' }
39 await createUser(server.url, server.accessToken, user.username, user.password) 39 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
40 40
41 userAccessToken = await userLogin(server, user) 41 userAccessToken = await userLogin(server, user)
42 42
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 01ab84584..3bcb015d9 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -110,7 +110,7 @@ describe('Test config API validators', function () {
110 username: 'user1', 110 username: 'user1',
111 password: 'password' 111 password: 'password'
112 } 112 }
113 await createUser(server.url, server.accessToken, user.username, user.password) 113 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
114 userAccessToken = await userLogin(server, user) 114 userAccessToken = await userLogin(server, user)
115 }) 115 })
116 116
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 9bf664657..da94beffe 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -33,7 +33,7 @@ describe('Test debug API validators', function () {
33 username: 'user1', 33 username: 'user1',
34 password: 'my super password' 34 password: 'my super password'
35 } 35 }
36 await createUser(server.url, server.accessToken, user.username, user.password) 36 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
37 userAccessToken = await userLogin(server, user) 37 userAccessToken = await userLogin(server, user)
38 }) 38 })
39 39
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index ed1d2db59..5bb337682 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -35,7 +35,7 @@ describe('Test server follows API validators', function () {
35 password: 'password' 35 password: 'password'
36 } 36 }
37 37
38 await createUser(server.url, server.accessToken, user.username, user.password) 38 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
39 userAccessToken = await userLogin(server, user) 39 userAccessToken = await userLogin(server, user)
40 }) 40 })
41 41
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index 89760ff98..5fb2b9606 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -38,7 +38,7 @@ describe('Test jobs API validators', function () {
38 username: 'user1', 38 username: 'user1',
39 password: 'my super password' 39 password: 'my super password'
40 } 40 }
41 await createUser(server.url, server.accessToken, user.username, user.password) 41 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
42 userAccessToken = await userLogin(server, user) 42 userAccessToken = await userLogin(server, user)
43 }) 43 })
44 44
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index d6a40da61..9bc6ac244 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -33,7 +33,7 @@ describe('Test logs API validators', function () {
33 username: 'user1', 33 username: 'user1',
34 password: 'my super password' 34 password: 'my super password'
35 } 35 }
36 await createUser(server.url, server.accessToken, user.username, user.password) 36 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
37 userAccessToken = await userLogin(server, user) 37 userAccessToken = await userLogin(server, user)
38 }) 38 })
39 39
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index ff4726ceb..d14e35cf2 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -34,7 +34,7 @@ describe('Test server redundancy API validators', function () {
34 password: 'password' 34 password: 'password'
35 } 35 }
36 36
37 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 37 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
38 userAccessToken = await userLogin(servers[0], user) 38 userAccessToken = await userLogin(servers[0], user)
39 }) 39 })
40 40
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 04a3eb97c..a18e1a43b 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -42,7 +42,7 @@ describe('Test user subscriptions API validators', function () {
42 username: 'user1', 42 username: 'user1',
43 password: 'my super password' 43 password: 'my super password'
44 } 44 }
45 await createUser(server.url, server.accessToken, user.username, user.password) 45 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
46 userAccessToken = await userLogin(server, user) 46 userAccessToken = await userLogin(server, user)
47 }) 47 })
48 48
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index f3ee99e85..b5c812e8f 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -19,6 +19,7 @@ import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from
19import { VideoPrivacy } from '../../../../shared/models/videos' 19import { VideoPrivacy } from '../../../../shared/models/videos'
20import { waitJobs } from '../../../../shared/utils/server/jobs' 20import { waitJobs } from '../../../../shared/utils/server/jobs'
21import { expect } from 'chai' 21import { expect } from 'chai'
22import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
22 23
23describe('Test users API validators', function () { 24describe('Test users API validators', function () {
24 const path = '/api/v1/users/' 25 const path = '/api/v1/users/'
@@ -47,7 +48,13 @@ describe('Test users API validators', function () {
47 await setAccessTokensToServers([ server ]) 48 await setAccessTokensToServers([ server ])
48 49
49 const videoQuota = 42000000 50 const videoQuota = 42000000
50 await createUser(server.url, server.accessToken, user.username, user.password, videoQuota) 51 await createUser({
52 url: server.url,
53 accessToken: server.accessToken,
54 username: user.username,
55 password: user.password,
56 videoQuota: videoQuota
57 })
51 userAccessToken = await userLogin(server, user) 58 userAccessToken = await userLogin(server, user)
52 59
53 { 60 {
@@ -99,7 +106,8 @@ describe('Test users API validators', function () {
99 password: 'my super password', 106 password: 'my super password',
100 videoQuota: -1, 107 videoQuota: -1,
101 videoQuotaDaily: -1, 108 videoQuotaDaily: -1,
102 role: UserRole.USER 109 role: UserRole.USER,
110 adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST
103 } 111 }
104 112
105 it('Should fail with a too small username', async function () { 113 it('Should fail with a too small username', async function () {
@@ -150,6 +158,12 @@ describe('Test users API validators', function () {
150 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 158 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
151 }) 159 })
152 160
161 it('Should fail with invalid admin flags', async function () {
162 const fields = immutableAssign(baseCorrectParams, { adminFlags: 'toto' })
163
164 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
165 })
166
153 it('Should fail with an non authenticated user', async function () { 167 it('Should fail with an non authenticated user', async function () {
154 await makePostBodyRequest({ 168 await makePostBodyRequest({
155 url: server.url, 169 url: server.url,
@@ -498,6 +512,12 @@ describe('Test users API validators', function () {
498 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields }) 512 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields })
499 }) 513 })
500 514
515 it('Should fail with invalid admin flags', async function () {
516 const fields = { adminFlags: 'toto' }
517
518 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
519 })
520
501 it('Should succeed with the correct params', async function () { 521 it('Should succeed with the correct params', async function () {
502 const fields = { 522 const fields = {
503 email: 'email@example.com', 523 email: 'email@example.com',
diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts
index 3b8f5f14d..7edc8e39d 100644
--- a/server/tests/api/check-params/video-abuses.ts
+++ b/server/tests/api/check-params/video-abuses.ts
@@ -41,7 +41,7 @@ describe('Test video abuses API validators', function () {
41 41
42 const username = 'user1' 42 const username = 'user1'
43 const password = 'my super password' 43 const password = 'my super password'
44 await createUser(server.url, server.accessToken, username, password) 44 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
45 userAccessToken = await userLogin(server, { username, password }) 45 userAccessToken = await userLogin(server, { username, password })
46 46
47 const res = await uploadVideo(server.url, server.accessToken, {}) 47 const res = await uploadVideo(server.url, server.accessToken, {})
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index fc039e847..81423aee9 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -8,7 +8,6 @@ import {
8 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
9 flushTests, 9 flushTests,
10 getBlacklistedVideosList, 10 getBlacklistedVideosList,
11 getBlacklistedVideosListWithTypeFilter,
12 getVideo, 11 getVideo,
13 getVideoWithToken, 12 getVideoWithToken,
14 killallServers, 13 killallServers,
@@ -49,14 +48,14 @@ describe('Test video blacklist API validators', function () {
49 { 48 {
50 const username = 'user1' 49 const username = 'user1'
51 const password = 'my super password' 50 const password = 'my super password'
52 await createUser(servers[0].url, servers[0].accessToken, username, password) 51 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: username, password: password })
53 userAccessToken1 = await userLogin(servers[0], { username, password }) 52 userAccessToken1 = await userLogin(servers[0], { username, password })
54 } 53 }
55 54
56 { 55 {
57 const username = 'user2' 56 const username = 'user2'
58 const password = 'my super password' 57 const password = 'my super password'
59 await createUser(servers[0].url, servers[0].accessToken, username, password) 58 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: username, password: password })
60 userAccessToken2 = await userLogin(servers[0], { username, password }) 59 userAccessToken2 = await userLogin(servers[0], { username, password })
61 } 60 }
62 61
@@ -221,11 +220,11 @@ describe('Test video blacklist API validators', function () {
221 const basePath = '/api/v1/videos/blacklist/' 220 const basePath = '/api/v1/videos/blacklist/'
222 221
223 it('Should fail with a non authenticated user', async function () { 222 it('Should fail with a non authenticated user', async function () {
224 await getBlacklistedVideosList(servers[0].url, 'fake token', 401) 223 await getBlacklistedVideosList({ url: servers[0].url, token: 'fake token', specialStatus: 401 })
225 }) 224 })
226 225
227 it('Should fail with a non admin user', async function () { 226 it('Should fail with a non admin user', async function () {
228 await getBlacklistedVideosList(servers[0].url, userAccessToken2, 403) 227 await getBlacklistedVideosList({ url: servers[0].url, token: userAccessToken2, specialStatus: 403 })
229 }) 228 })
230 229
231 it('Should fail with a bad start pagination', async function () { 230 it('Should fail with a bad start pagination', async function () {
@@ -241,11 +240,11 @@ describe('Test video blacklist API validators', function () {
241 }) 240 })
242 241
243 it('Should fail with an invalid type', async function () { 242 it('Should fail with an invalid type', async function () {
244 await getBlacklistedVideosListWithTypeFilter(servers[0].url, servers[0].accessToken, 0, 400) 243 await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: 0, specialStatus: 400 })
245 }) 244 })
246 245
247 it('Should succeed with the correct parameters', async function () { 246 it('Should succeed with the correct parameters', async function () {
248 await getBlacklistedVideosListWithTypeFilter(servers[0].url, servers[0].accessToken, VideoBlacklistType.MANUAL) 247 await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlacklistType.MANUAL })
249 }) 248 })
250 }) 249 })
251 250
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index e4d36fd4f..de2ca8cd1 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -45,7 +45,7 @@ describe('Test video captions API validator', function () {
45 username: 'user1', 45 username: 'user1',
46 password: 'my super password' 46 password: 'my super password'
47 } 47 }
48 await createUser(server.url, server.accessToken, user.username, user.password) 48 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
49 userAccessToken = await userLogin(server, user) 49 userAccessToken = await userLogin(server, user)
50 } 50 }
51 }) 51 })
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 14e4deaf7..b72fc4220 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -53,7 +53,7 @@ describe('Test video channels API validator', function () {
53 } 53 }
54 54
55 { 55 {
56 await createUser(server.url, server.accessToken, user.username, user.password) 56 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
57 accessTokenUser = await userLogin(server, user) 57 accessTokenUser = await userLogin(server, user)
58 } 58 }
59 }) 59 })
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 5981780ed..5f70998ef 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -52,7 +52,7 @@ describe('Test video comments API validator', function () {
52 username: 'user1', 52 username: 'user1',
53 password: 'my super password' 53 password: 'my super password'
54 } 54 }
55 await createUser(server.url, server.accessToken, user.username, user.password) 55 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
56 userAccessToken = await userLogin(server, user) 56 userAccessToken = await userLogin(server, user)
57 } 57 }
58 }) 58 })
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 6dd9f15f7..4d2bf2e8d 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -46,7 +46,7 @@ describe('Test video imports API validator', function () {
46 46
47 const username = 'user1' 47 const username = 'user1'
48 const password = 'my super password' 48 const password = 'my super password'
49 await createUser(server.url, server.accessToken, username, password) 49 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
50 userAccessToken = await userLogin(server, { username, password }) 50 userAccessToken = await userLogin(server, { username, password })
51 51
52 { 52 {
@@ -167,7 +167,7 @@ describe('Test video imports API validator', function () {
167 username: 'fake', 167 username: 'fake',
168 password: 'fake_password' 168 password: 'fake_password'
169 } 169 }
170 await createUser(server.url, server.accessToken, user.username, user.password) 170 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
171 171
172 const accessTokenUser = await userLogin(server, user) 172 const accessTokenUser = await userLogin(server, user)
173 const res = await getMyUserInformation(server.url, accessTokenUser) 173 const res = await getMyUserInformation(server.url, accessTokenUser)
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index d5557cd07..7c487ae81 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -56,18 +56,20 @@ describe('Test videos filters', function () {
56 await setDefaultVideoChannel([ server ]) 56 await setDefaultVideoChannel([ server ])
57 57
58 const user = { username: 'user1', password: 'my super password' } 58 const user = { username: 'user1', password: 'my super password' }
59 await createUser(server.url, server.accessToken, user.username, user.password) 59 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
60 userAccessToken = await userLogin(server, user) 60 userAccessToken = await userLogin(server, user)
61 61
62 const moderator = { username: 'moderator', password: 'my super password' } 62 const moderator = { username: 'moderator', password: 'my super password' }
63 await createUser( 63 await createUser(
64 server.url, 64 {
65 server.accessToken, 65 url: server.url,
66 moderator.username, 66 accessToken: server.accessToken,
67 moderator.password, 67 username: moderator.username,
68 undefined, 68 password: moderator.password,
69 undefined, 69 videoQuota: undefined,
70 UserRole.MODERATOR 70 videoQuotaDaily: undefined,
71 role: UserRole.MODERATOR
72 }
71 ) 73 )
72 moderatorAccessToken = await userLogin(server, moderator) 74 moderatorAccessToken = await userLogin(server, moderator)
73 75
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 5a013b890..3f0e0d646 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -41,7 +41,7 @@ describe('Test videos API validator', function () {
41 41
42 const username = 'user1' 42 const username = 'user1'
43 const password = 'my super password' 43 const password = 'my super password'
44 await createUser(server.url, server.accessToken, username, password) 44 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
45 userAccessToken = await userLogin(server, { username, password }) 45 userAccessToken = await userLogin(server, { username, password })
46 46
47 { 47 {
@@ -265,7 +265,7 @@ describe('Test videos API validator', function () {
265 username: 'fake', 265 username: 'fake',
266 password: 'fake_password' 266 password: 'fake_password'
267 } 267 }
268 await createUser(server.url, server.accessToken, user.username, user.password) 268 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
269 269
270 const accessTokenUser = await userLogin(server, user) 270 const accessTokenUser = await userLogin(server, user)
271 const res = await getMyUserInformation(server.url, accessTokenUser) 271 const res = await getMyUserInformation(server.url, accessTokenUser)