aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:04:35 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit89d241a79c262b9775c233b73cff080043ebb5e6 (patch)
treecb3b6cb431d25d891ef4e02f66c61d252d17048f /server/tests/api/check-params
parentd23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff)
downloadPeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip
Shorter server command names
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/abuses.ts28
-rw-r--r--server/tests/api/check-params/accounts.ts2
-rw-r--r--server/tests/api/check-params/blocklist.ts4
-rw-r--r--server/tests/api/check-params/bulk.ts4
-rw-r--r--server/tests/api/check-params/config.ts4
-rw-r--r--server/tests/api/check-params/contact-form.ts2
-rw-r--r--server/tests/api/check-params/custom-pages.ts4
-rw-r--r--server/tests/api/check-params/debug.ts4
-rw-r--r--server/tests/api/check-params/follows.ts4
-rw-r--r--server/tests/api/check-params/jobs.ts4
-rw-r--r--server/tests/api/check-params/live.ts30
-rw-r--r--server/tests/api/check-params/logs.ts4
-rw-r--r--server/tests/api/check-params/plugins.ts8
-rw-r--r--server/tests/api/check-params/redundancy.ts10
-rw-r--r--server/tests/api/check-params/search.ts2
-rw-r--r--server/tests/api/check-params/services.ts20
-rw-r--r--server/tests/api/check-params/upload-quota.ts30
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts4
-rw-r--r--server/tests/api/check-params/users.ts74
-rw-r--r--server/tests/api/check-params/video-blacklist.ts60
-rw-r--r--server/tests/api/check-params/video-captions.ts8
-rw-r--r--server/tests/api/check-params/video-channels.ts8
-rw-r--r--server/tests/api/check-params/video-comments.ts20
-rw-r--r--server/tests/api/check-params/video-imports.ts16
-rw-r--r--server/tests/api/check-params/video-playlists.ts16
-rw-r--r--server/tests/api/check-params/videos-filter.ts8
-rw-r--r--server/tests/api/check-params/videos-history.ts2
-rw-r--r--server/tests/api/check-params/videos-overviews.ts6
-rw-r--r--server/tests/api/check-params/videos.ts34
29 files changed, 210 insertions, 210 deletions
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 199cc5599..7a6790ba8 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -39,12 +39,12 @@ describe('Test abuses API validators', function () {
39 39
40 await setAccessTokensToServers([ server ]) 40 await setAccessTokensToServers([ server ])
41 41
42 userToken = await server.usersCommand.generateUserAndToken('user_1') 42 userToken = await server.users.generateUserAndToken('user_1')
43 userToken2 = await server.usersCommand.generateUserAndToken('user_2') 43 userToken2 = await server.users.generateUserAndToken('user_2')
44 44
45 server.video = await server.videosCommand.upload() 45 server.store.video = await server.videos.upload()
46 46
47 command = server.abusesCommand 47 command = server.abuses
48 }) 48 })
49 49
50 describe('When listing abuses for admins', function () { 50 describe('When listing abuses for admins', function () {
@@ -224,25 +224,25 @@ describe('Test abuses API validators', function () {
224 }) 224 })
225 225
226 it('Should fail with a non authenticated user', async function () { 226 it('Should fail with a non authenticated user', async function () {
227 const fields = { video: { id: server.video.id }, reason: 'my super reason' } 227 const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
228 228
229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
230 }) 230 })
231 231
232 it('Should fail with a reason too short', async function () { 232 it('Should fail with a reason too short', async function () {
233 const fields = { video: { id: server.video.id }, reason: 'h' } 233 const fields = { video: { id: server.store.video.id }, reason: 'h' }
234 234
235 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 235 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
236 }) 236 })
237 237
238 it('Should fail with a too big reason', async function () { 238 it('Should fail with a too big reason', async function () {
239 const fields = { video: { id: server.video.id }, reason: 'super'.repeat(605) } 239 const fields = { video: { id: server.store.video.id }, reason: 'super'.repeat(605) }
240 240
241 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 241 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
242 }) 242 })
243 243
244 it('Should succeed with the correct parameters (basic)', async function () { 244 it('Should succeed with the correct parameters (basic)', async function () {
245 const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' } 245 const fields: AbuseCreate = { video: { id: server.store.video.shortUUID }, reason: 'my super reason' }
246 246
247 const res = await makePostBodyRequest({ 247 const res = await makePostBodyRequest({
248 url: server.url, 248 url: server.url,
@@ -255,19 +255,19 @@ describe('Test abuses API validators', function () {
255 }) 255 })
256 256
257 it('Should fail with a wrong predefined reason', async function () { 257 it('Should fail with a wrong predefined reason', async function () {
258 const fields = { video: { id: server.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] } 258 const fields = { video: { id: server.store.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
259 259
260 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 260 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
261 }) 261 })
262 262
263 it('Should fail with negative timestamps', async function () { 263 it('Should fail with negative timestamps', async function () {
264 const fields = { video: { id: server.video.id, startAt: -1 }, reason: 'my super reason' } 264 const fields = { video: { id: server.store.video.id, startAt: -1 }, reason: 'my super reason' }
265 265
266 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 266 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
267 }) 267 })
268 268
269 it('Should fail mith misordered startAt/endAt', async function () { 269 it('Should fail mith misordered startAt/endAt', async function () {
270 const fields = { video: { id: server.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' } 270 const fields = { video: { id: server.store.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
271 271
272 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 272 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
273 }) 273 })
@@ -275,7 +275,7 @@ describe('Test abuses API validators', function () {
275 it('Should succeed with the corret parameters (advanced)', async function () { 275 it('Should succeed with the corret parameters (advanced)', async function () {
276 const fields: AbuseCreate = { 276 const fields: AbuseCreate = {
277 video: { 277 video: {
278 id: server.video.id, 278 id: server.store.video.id,
279 startAt: 1, 279 startAt: 1,
280 endAt: 5 280 endAt: 5
281 }, 281 },
@@ -414,8 +414,8 @@ describe('Test abuses API validators', function () {
414 414
415 await doubleFollow(anotherServer, server) 415 await doubleFollow(anotherServer, server)
416 416
417 const server2VideoId = await anotherServer.videosCommand.getId({ uuid: server.video.uuid }) 417 const server2VideoId = await anotherServer.videos.getId({ uuid: server.store.video.uuid })
418 await anotherServer.abusesCommand.report({ reason: 'remote server', videoId: server2VideoId }) 418 await anotherServer.abuses.report({ reason: 'remote server', videoId: server2VideoId })
419 419
420 await waitJobs([ server, anotherServer ]) 420 await waitJobs([ server, anotherServer ])
421 421
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index 45d440c47..223322626 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -40,7 +40,7 @@ describe('Test accounts API validators', function () {
40 describe('When getting an account', function () { 40 describe('When getting an account', function () {
41 41
42 it('Should return 404 with a non existing name', async function () { 42 it('Should return 404 with a non existing name', async function () {
43 await server.accountsCommand.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 43 await server.accounts.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
44 }) 44 })
45 }) 45 })
46 46
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index 18238bb04..14e45e503 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -33,9 +33,9 @@ describe('Test blocklist API validators', function () {
33 server = servers[0] 33 server = servers[0]
34 34
35 const user = { username: 'user1', password: 'password' } 35 const user = { username: 'user1', password: 'password' }
36 await server.usersCommand.create({ username: user.username, password: user.password }) 36 await server.users.create({ username: user.username, password: user.password })
37 37
38 userAccessToken = await server.loginCommand.getAccessToken(user) 38 userAccessToken = await server.login.getAccessToken(user)
39 39
40 await doubleFollow(servers[0], servers[1]) 40 await doubleFollow(servers[0], servers[1])
41 }) 41 })
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
index 3f80c79a8..69ff7dd96 100644
--- a/server/tests/api/check-params/bulk.ts
+++ b/server/tests/api/check-params/bulk.ts
@@ -23,9 +23,9 @@ describe('Test bulk API validators', function () {
23 await setAccessTokensToServers([ server ]) 23 await setAccessTokensToServers([ server ])
24 24
25 const user = { username: 'user1', password: 'password' } 25 const user = { username: 'user1', password: 'password' }
26 await server.usersCommand.create({ username: user.username, password: user.password }) 26 await server.users.create({ username: user.username, password: user.password })
27 27
28 userAccessToken = await server.loginCommand.getAccessToken(user) 28 userAccessToken = await server.login.getAccessToken(user)
29 }) 29 })
30 30
31 describe('When removing comments of', function () { 31 describe('When removing comments of', function () {
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index c204d9415..6fd26864e 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -205,8 +205,8 @@ describe('Test config API validators', function () {
205 username: 'user1', 205 username: 'user1',
206 password: 'password' 206 password: 'password'
207 } 207 }
208 await server.usersCommand.create({ username: user.username, password: user.password }) 208 await server.users.create({ username: user.username, password: user.password })
209 userAccessToken = await server.loginCommand.getAccessToken(user) 209 userAccessToken = await server.login.getAccessToken(user)
210 }) 210 })
211 211
212 describe('When getting the configuration', function () { 212 describe('When getting the configuration', function () {
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 4eed1661a..d2541777f 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -26,7 +26,7 @@ describe('Test contact form API validators', function () {
26 26
27 // Email is disabled 27 // Email is disabled
28 server = await flushAndRunServer(1) 28 server = await flushAndRunServer(1)
29 command = server.contactFormCommand 29 command = server.contactForm
30 }) 30 })
31 31
32 it('Should not accept a contact form if emails are disabled', async function () { 32 it('Should not accept a contact form if emails are disabled', async function () {
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts
index 58b0b8600..3d84fb3e6 100644
--- a/server/tests/api/check-params/custom-pages.ts
+++ b/server/tests/api/check-params/custom-pages.ts
@@ -25,9 +25,9 @@ describe('Test custom pages validators', function () {
25 await setAccessTokensToServers([ server ]) 25 await setAccessTokensToServers([ server ])
26 26
27 const user = { username: 'user1', password: 'password' } 27 const user = { username: 'user1', password: 'password' }
28 await server.usersCommand.create({ username: user.username, password: user.password }) 28 await server.users.create({ username: user.username, password: user.password })
29 29
30 userAccessToken = await server.loginCommand.getAccessToken(user) 30 userAccessToken = await server.login.getAccessToken(user)
31 }) 31 })
32 32
33 describe('When updating instance homepage', function () { 33 describe('When updating instance homepage', function () {
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 2a7485cf3..609f9566e 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -29,8 +29,8 @@ describe('Test debug API validators', function () {
29 username: 'user1', 29 username: 'user1',
30 password: 'my super password' 30 password: 'my super password'
31 } 31 }
32 await server.usersCommand.create({ username: user.username, password: user.password }) 32 await server.users.create({ username: user.username, password: user.password })
33 userAccessToken = await server.loginCommand.getAccessToken(user) 33 userAccessToken = await server.login.getAccessToken(user)
34 }) 34 })
35 35
36 describe('When getting debug endpoint', function () { 36 describe('When getting debug endpoint', function () {
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 24e483448..fae3712ce 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -39,8 +39,8 @@ describe('Test server follows API validators', function () {
39 password: 'password' 39 password: 'password'
40 } 40 }
41 41
42 await server.usersCommand.create({ username: user.username, password: user.password }) 42 await server.users.create({ username: user.username, password: user.password })
43 userAccessToken = await server.loginCommand.getAccessToken(user) 43 userAccessToken = await server.login.getAccessToken(user)
44 }) 44 })
45 45
46 describe('When adding follows', function () { 46 describe('When adding follows', function () {
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index 29439bebf..3786e8612 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -34,8 +34,8 @@ describe('Test jobs API validators', function () {
34 username: 'user1', 34 username: 'user1',
35 password: 'my super password' 35 password: 'my super password'
36 } 36 }
37 await server.usersCommand.create({ username: user.username, password: user.password }) 37 await server.users.create({ username: user.username, password: user.password })
38 userAccessToken = await server.loginCommand.getAccessToken(user) 38 userAccessToken = await server.login.getAccessToken(user)
39 }) 39 })
40 40
41 describe('When listing jobs', function () { 41 describe('When listing jobs', function () {
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 4b54fc31c..20f27dd1d 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -35,7 +35,7 @@ describe('Test video lives API validator', function () {
35 35
36 await setAccessTokensToServers([ server ]) 36 await setAccessTokensToServers([ server ])
37 37
38 await server.configCommand.updateCustomSubConfig({ 38 await server.config.updateCustomSubConfig({
39 newConfig: { 39 newConfig: {
40 live: { 40 live: {
41 enabled: true, 41 enabled: true,
@@ -48,19 +48,19 @@ describe('Test video lives API validator', function () {
48 48
49 const username = 'user1' 49 const username = 'user1'
50 const password = 'my super password' 50 const password = 'my super password'
51 await server.usersCommand.create({ username: username, password: password }) 51 await server.users.create({ username: username, password: password })
52 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 52 userAccessToken = await server.login.getAccessToken({ username, password })
53 53
54 { 54 {
55 const { videoChannels } = await server.usersCommand.getMyInfo() 55 const { videoChannels } = await server.users.getMyInfo()
56 channelId = videoChannels[0].id 56 channelId = videoChannels[0].id
57 } 57 }
58 58
59 { 59 {
60 videoIdNotLive = (await server.videosCommand.quickUpload({ name: 'not live' })).id 60 videoIdNotLive = (await server.videos.quickUpload({ name: 'not live' })).id
61 } 61 }
62 62
63 command = server.liveCommand 63 command = server.live
64 }) 64 })
65 65
66 describe('When creating a live', function () { 66 describe('When creating a live', function () {
@@ -144,10 +144,10 @@ describe('Test video lives API validator', function () {
144 username: 'fake', 144 username: 'fake',
145 password: 'fake_password' 145 password: 'fake_password'
146 } 146 }
147 await server.usersCommand.create({ username: user.username, password: user.password }) 147 await server.users.create({ username: user.username, password: user.password })
148 148
149 const accessTokenUser = await server.loginCommand.getAccessToken(user) 149 const accessTokenUser = await server.login.getAccessToken(user)
150 const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser }) 150 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
151 const customChannelId = videoChannels[0].id 151 const customChannelId = videoChannels[0].id
152 152
153 const fields = { ...baseCorrectParams, channelId: customChannelId } 153 const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -230,7 +230,7 @@ describe('Test video lives API validator', function () {
230 }) 230 })
231 231
232 it('Should forbid if live is disabled', async function () { 232 it('Should forbid if live is disabled', async function () {
233 await server.configCommand.updateCustomSubConfig({ 233 await server.config.updateCustomSubConfig({
234 newConfig: { 234 newConfig: {
235 live: { 235 live: {
236 enabled: false 236 enabled: false
@@ -250,7 +250,7 @@ describe('Test video lives API validator', function () {
250 it('Should forbid to save replay if not enabled by the admin', async function () { 250 it('Should forbid to save replay if not enabled by the admin', async function () {
251 const fields = { ...baseCorrectParams, saveReplay: true } 251 const fields = { ...baseCorrectParams, saveReplay: true }
252 252
253 await server.configCommand.updateCustomSubConfig({ 253 await server.config.updateCustomSubConfig({
254 newConfig: { 254 newConfig: {
255 live: { 255 live: {
256 enabled: true, 256 enabled: true,
@@ -271,7 +271,7 @@ describe('Test video lives API validator', function () {
271 it('Should allow to save replay if enabled by the admin', async function () { 271 it('Should allow to save replay if enabled by the admin', async function () {
272 const fields = { ...baseCorrectParams, saveReplay: true } 272 const fields = { ...baseCorrectParams, saveReplay: true }
273 273
274 await server.configCommand.updateCustomSubConfig({ 274 await server.config.updateCustomSubConfig({
275 newConfig: { 275 newConfig: {
276 live: { 276 live: {
277 enabled: true, 277 enabled: true,
@@ -290,7 +290,7 @@ describe('Test video lives API validator', function () {
290 }) 290 })
291 291
292 it('Should not allow live if max instance lives is reached', async function () { 292 it('Should not allow live if max instance lives is reached', async function () {
293 await server.configCommand.updateCustomSubConfig({ 293 await server.config.updateCustomSubConfig({
294 newConfig: { 294 newConfig: {
295 live: { 295 live: {
296 enabled: true, 296 enabled: true,
@@ -309,7 +309,7 @@ describe('Test video lives API validator', function () {
309 }) 309 })
310 310
311 it('Should not allow live if max user lives is reached', async function () { 311 it('Should not allow live if max user lives is reached', async function () {
312 await server.configCommand.updateCustomSubConfig({ 312 await server.config.updateCustomSubConfig({
313 newConfig: { 313 newConfig: {
314 live: { 314 live: {
315 enabled: true, 315 enabled: true,
@@ -401,7 +401,7 @@ describe('Test video lives API validator', function () {
401 }) 401 })
402 402
403 it('Should fail to update replay status if replay is not allowed on the instance', async function () { 403 it('Should fail to update replay status if replay is not allowed on the instance', async function () {
404 await server.configCommand.updateCustomSubConfig({ 404 await server.config.updateCustomSubConfig({
405 newConfig: { 405 newConfig: {
406 live: { 406 live: {
407 enabled: true, 407 enabled: true,
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 69eaad69f..cf8f77959 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -29,8 +29,8 @@ describe('Test logs API validators', function () {
29 username: 'user1', 29 username: 'user1',
30 password: 'my super password' 30 password: 'my super password'
31 } 31 }
32 await server.usersCommand.create({ username: user.username, password: user.password }) 32 await server.users.create({ username: user.username, password: user.password })
33 userAccessToken = await server.loginCommand.getAccessToken(user) 33 userAccessToken = await server.login.getAccessToken(user)
34 }) 34 })
35 35
36 describe('When getting logs', function () { 36 describe('When getting logs', function () {
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 08fb2397f..d4b72c0f4 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -42,17 +42,17 @@ describe('Test server plugins API validators', function () {
42 password: 'password' 42 password: 'password'
43 } 43 }
44 44
45 await server.usersCommand.create({ username: user.username, password: user.password }) 45 await server.users.create({ username: user.username, password: user.password })
46 userAccessToken = await server.loginCommand.getAccessToken(user) 46 userAccessToken = await server.login.getAccessToken(user)
47 47
48 { 48 {
49 const res = await server.pluginsCommand.install({ npmName: npmPlugin }) 49 const res = await server.plugins.install({ npmName: npmPlugin })
50 const plugin = res.body as PeerTubePlugin 50 const plugin = res.body as PeerTubePlugin
51 npmVersion = plugin.version 51 npmVersion = plugin.version
52 } 52 }
53 53
54 { 54 {
55 const res = await server.pluginsCommand.install({ npmName: themePlugin }) 55 const res = await server.plugins.install({ npmName: themePlugin })
56 const plugin = res.body as PeerTubePlugin 56 const plugin = res.body as PeerTubePlugin
57 themeVersion = plugin.version 57 themeVersion = plugin.version
58 } 58 }
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index b1692b986..fca92fde4 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -40,16 +40,16 @@ describe('Test server redundancy API validators', function () {
40 password: 'password' 40 password: 'password'
41 } 41 }
42 42
43 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 43 await servers[0].users.create({ username: user.username, password: user.password })
44 userAccessToken = await servers[0].loginCommand.getAccessToken(user) 44 userAccessToken = await servers[0].login.getAccessToken(user)
45 45
46 videoIdLocal = (await servers[0].videosCommand.quickUpload({ name: 'video' })).id 46 videoIdLocal = (await servers[0].videos.quickUpload({ name: 'video' })).id
47 47
48 const remoteUUID = (await servers[1].videosCommand.quickUpload({ name: 'video' })).uuid 48 const remoteUUID = (await servers[1].videos.quickUpload({ name: 'video' })).uuid
49 49
50 await waitJobs(servers) 50 await waitJobs(servers)
51 51
52 videoRemote = await servers[0].videosCommand.get({ id: remoteUUID }) 52 videoRemote = await servers[0].videos.get({ id: remoteUUID })
53 }) 53 })
54 54
55 describe('When listing redundancies', function () { 55 describe('When listing redundancies', function () {
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 7973c112f..1acfa0922 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -14,7 +14,7 @@ import {
14} from '@shared/extra-utils' 14} from '@shared/extra-utils'
15 15
16function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) { 16function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
17 return server.configCommand.updateCustomSubConfig({ 17 return server.config.updateCustomSubConfig({
18 newConfig: { 18 newConfig: {
19 search: { 19 search: {
20 searchIndex: { 20 searchIndex: {
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index f86712b4e..83435c24a 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -25,14 +25,14 @@ describe('Test services API validators', function () {
25 await setAccessTokensToServers([ server ]) 25 await setAccessTokensToServers([ server ])
26 await setDefaultVideoChannel([ server ]) 26 await setDefaultVideoChannel([ server ])
27 27
28 server.video = await server.videosCommand.upload({ attributes: { name: 'my super name' } }) 28 server.store.video = await server.videos.upload({ attributes: { name: 'my super name' } })
29 29
30 { 30 {
31 const created = await server.playlistsCommand.create({ 31 const created = await server.playlists.create({
32 attributes: { 32 attributes: {
33 displayName: 'super playlist', 33 displayName: 'super playlist',
34 privacy: VideoPlaylistPrivacy.PUBLIC, 34 privacy: VideoPlaylistPrivacy.PUBLIC,
35 videoChannelId: server.videoChannel.id 35 videoChannelId: server.store.channel.id
36 } 36 }
37 }) 37 })
38 38
@@ -48,7 +48,7 @@ describe('Test services API validators', function () {
48 }) 48 })
49 49
50 it('Should fail with an invalid host', async function () { 50 it('Should fail with an invalid host', async function () {
51 const embedUrl = 'http://hello.com/videos/watch/' + server.video.uuid 51 const embedUrl = 'http://hello.com/videos/watch/' + server.store.video.uuid
52 await checkParamEmbed(server, embedUrl) 52 await checkParamEmbed(server, embedUrl)
53 }) 53 })
54 54
@@ -63,37 +63,37 @@ describe('Test services API validators', function () {
63 }) 63 })
64 64
65 it('Should fail with an invalid path', async function () { 65 it('Should fail with an invalid path', async function () {
66 const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.video.uuid}` 66 const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.store.video.uuid}`
67 67
68 await checkParamEmbed(server, embedUrl) 68 await checkParamEmbed(server, embedUrl)
69 }) 69 })
70 70
71 it('Should fail with an invalid max height', async function () { 71 it('Should fail with an invalid max height', async function () {
72 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 72 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
73 73
74 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' }) 74 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' })
75 }) 75 })
76 76
77 it('Should fail with an invalid max width', async function () { 77 it('Should fail with an invalid max width', async function () {
78 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 78 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
79 79
80 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' }) 80 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' })
81 }) 81 })
82 82
83 it('Should fail with an invalid format', async function () { 83 it('Should fail with an invalid format', async function () {
84 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 84 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
85 85
86 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' }) 86 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' })
87 }) 87 })
88 88
89 it('Should fail with a non supported format', async function () { 89 it('Should fail with a non supported format', async function () {
90 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 90 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
91 91
92 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' }) 92 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' })
93 }) 93 })
94 94
95 it('Should succeed with the correct params with a video', async function () { 95 it('Should succeed with the correct params with a video', async function () {
96 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 96 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
97 const query = { 97 const query = {
98 format: 'json', 98 format: 'json',
99 maxheight: 400, 99 maxheight: 400,
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index 164c581e3..4ca544790 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -29,12 +29,12 @@ describe('Test upload quota', function () {
29 await setAccessTokensToServers([ server ]) 29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ]) 30 await setDefaultVideoChannel([ server ])
31 31
32 const user = await server.usersCommand.getMyInfo() 32 const user = await server.users.getMyInfo()
33 rootId = user.id 33 rootId = user.id
34 34
35 await server.usersCommand.update({ userId: rootId, videoQuota: 42 }) 35 await server.users.update({ userId: rootId, videoQuota: 42 })
36 36
37 command = server.videosCommand 37 command = server.videos
38 }) 38 })
39 39
40 describe('When having a video quota', function () { 40 describe('When having a video quota', function () {
@@ -43,8 +43,8 @@ describe('Test upload quota', function () {
43 this.timeout(30000) 43 this.timeout(30000)
44 44
45 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } 45 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
46 await server.usersCommand.register(user) 46 await server.users.register(user)
47 const userToken = await server.loginCommand.getAccessToken(user) 47 const userToken = await server.login.getAccessToken(user)
48 48
49 const attributes = { fixture: 'video_short2.webm' } 49 const attributes = { fixture: 'video_short2.webm' }
50 for (let i = 0; i < 5; i++) { 50 for (let i = 0; i < 5; i++) {
@@ -58,8 +58,8 @@ describe('Test upload quota', function () {
58 this.timeout(30000) 58 this.timeout(30000)
59 59
60 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } 60 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
61 await server.usersCommand.register(user) 61 await server.users.register(user)
62 const userToken = await server.loginCommand.getAccessToken(user) 62 const userToken = await server.login.getAccessToken(user)
63 63
64 const attributes = { fixture: 'video_short2.webm' } 64 const attributes = { fixture: 'video_short2.webm' }
65 for (let i = 0; i < 5; i++) { 65 for (let i = 0; i < 5; i++) {
@@ -73,16 +73,16 @@ describe('Test upload quota', function () {
73 this.timeout(120000) 73 this.timeout(120000)
74 74
75 const baseAttributes = { 75 const baseAttributes = {
76 channelId: server.videoChannel.id, 76 channelId: server.store.channel.id,
77 privacy: VideoPrivacy.PUBLIC 77 privacy: VideoPrivacy.PUBLIC
78 } 78 }
79 await server.importsCommand.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } }) 79 await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
80 await server.importsCommand.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } }) 80 await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
81 await server.importsCommand.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } }) 81 await server.imports.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
82 82
83 await waitJobs([ server ]) 83 await waitJobs([ server ])
84 84
85 const { total, data: videoImports } = await server.importsCommand.getMyVideoImports() 85 const { total, data: videoImports } = await server.imports.getMyVideoImports()
86 expect(total).to.equal(3) 86 expect(total).to.equal(3)
87 87
88 expect(videoImports).to.have.lengthOf(3) 88 expect(videoImports).to.have.lengthOf(3)
@@ -98,7 +98,7 @@ describe('Test upload quota', function () {
98 describe('When having a daily video quota', function () { 98 describe('When having a daily video quota', function () {
99 99
100 it('Should fail with a user having too many videos daily', async function () { 100 it('Should fail with a user having too many videos daily', async function () {
101 await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 }) 101 await server.users.update({ userId: rootId, videoQuotaDaily: 42 })
102 102
103 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }) 103 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' })
104 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }) 104 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' })
@@ -107,7 +107,7 @@ describe('Test upload quota', function () {
107 107
108 describe('When having an absolute and daily video quota', function () { 108 describe('When having an absolute and daily video quota', function () {
109 it('Should fail if exceeding total quota', async function () { 109 it('Should fail if exceeding total quota', async function () {
110 await server.usersCommand.update({ 110 await server.users.update({
111 userId: rootId, 111 userId: rootId,
112 videoQuota: 42, 112 videoQuota: 42,
113 videoQuotaDaily: 1024 * 1024 * 1024 113 videoQuotaDaily: 1024 * 1024 * 1024
@@ -118,7 +118,7 @@ describe('Test upload quota', function () {
118 }) 118 })
119 119
120 it('Should fail if exceeding daily quota', async function () { 120 it('Should fail if exceeding daily quota', async function () {
121 await server.usersCommand.update({ 121 await server.users.update({
122 userId: rootId, 122 userId: rootId,
123 videoQuota: 1024 * 1024 * 1024, 123 videoQuota: 1024 * 1024 * 1024,
124 videoQuotaDaily: 42 124 videoQuotaDaily: 42
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 8ce201d61..885ad68e4 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -38,8 +38,8 @@ describe('Test user subscriptions API validators', function () {
38 username: 'user1', 38 username: 'user1',
39 password: 'my super password' 39 password: 'my super password'
40 } 40 }
41 await server.usersCommand.create({ username: user.username, password: user.password }) 41 await server.users.create({ username: user.username, password: user.password })
42 userAccessToken = await server.loginCommand.getAccessToken(user) 42 userAccessToken = await server.login.getAccessToken(user)
43 }) 43 })
44 44
45 describe('When listing my subscriptions', function () { 45 describe('When listing my subscriptions', function () {
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 33c48a009..bce3f0774 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -60,27 +60,27 @@ describe('Test users API validators', function () {
60 60
61 { 61 {
62 const user = { username: 'user1' } 62 const user = { username: 'user1' }
63 await server.usersCommand.create({ ...user }) 63 await server.users.create({ ...user })
64 userToken = await server.loginCommand.getAccessToken(user) 64 userToken = await server.login.getAccessToken(user)
65 } 65 }
66 66
67 { 67 {
68 const moderator = { username: 'moderator1' } 68 const moderator = { username: 'moderator1' }
69 await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR }) 69 await server.users.create({ ...moderator, role: UserRole.MODERATOR })
70 moderatorToken = await server.loginCommand.getAccessToken(moderator) 70 moderatorToken = await server.login.getAccessToken(moderator)
71 } 71 }
72 72
73 { 73 {
74 const moderator = { username: 'moderator2' } 74 const moderator = { username: 'moderator2' }
75 await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR }) 75 await server.users.create({ ...moderator, role: UserRole.MODERATOR })
76 } 76 }
77 77
78 { 78 {
79 video = await server.videosCommand.upload() 79 video = await server.videos.upload()
80 } 80 }
81 81
82 { 82 {
83 const { data } = await server.usersCommand.list() 83 const { data } = await server.users.list()
84 userId = data.find(u => u.username === 'user1').id 84 userId = data.find(u => u.username === 'user1').id
85 rootId = data.find(u => u.username === 'root').id 85 rootId = data.find(u => u.username === 'root').id
86 moderatorId = data.find(u => u.username === 'moderator2').id 86 moderatorId = data.find(u => u.username === 'moderator2').id
@@ -341,7 +341,7 @@ describe('Test users API validators', function () {
341 341
342 it('Should fail with a non admin user', async function () { 342 it('Should fail with a non admin user', async function () {
343 const user = { username: 'user1' } 343 const user = { username: 'user1' }
344 userToken = await server.loginCommand.getAccessToken(user) 344 userToken = await server.login.getAccessToken(user)
345 345
346 const fields = { 346 const fields = {
347 username: 'user3', 347 username: 'user3',
@@ -596,28 +596,28 @@ describe('Test users API validators', function () {
596 describe('When managing my scoped tokens', function () { 596 describe('When managing my scoped tokens', function () {
597 597
598 it('Should fail to get my scoped tokens with an non authenticated user', async function () { 598 it('Should fail to get my scoped tokens with an non authenticated user', async function () {
599 await server.usersCommand.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 599 await server.users.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
600 }) 600 })
601 601
602 it('Should fail to get my scoped tokens with a bad token', async function () { 602 it('Should fail to get my scoped tokens with a bad token', async function () {
603 await server.usersCommand.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 603 await server.users.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
604 604
605 }) 605 })
606 606
607 it('Should succeed to get my scoped tokens', async function () { 607 it('Should succeed to get my scoped tokens', async function () {
608 await server.usersCommand.getMyScopedTokens() 608 await server.users.getMyScopedTokens()
609 }) 609 })
610 610
611 it('Should fail to renew my scoped tokens with an non authenticated user', async function () { 611 it('Should fail to renew my scoped tokens with an non authenticated user', async function () {
612 await server.usersCommand.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 612 await server.users.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
613 }) 613 })
614 614
615 it('Should fail to renew my scoped tokens with a bad token', async function () { 615 it('Should fail to renew my scoped tokens with a bad token', async function () {
616 await server.usersCommand.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 616 await server.users.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
617 }) 617 })
618 618
619 it('Should succeed to renew my scoped tokens', async function () { 619 it('Should succeed to renew my scoped tokens', async function () {
620 await server.usersCommand.renewMyScopedTokens() 620 await server.users.renewMyScopedTokens()
621 }) 621 })
622 }) 622 })
623 623
@@ -769,11 +769,11 @@ describe('Test users API validators', function () {
769 769
770 describe('When getting my information', function () { 770 describe('When getting my information', function () {
771 it('Should fail with a non authenticated user', async function () { 771 it('Should fail with a non authenticated user', async function () {
772 await server.usersCommand.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 772 await server.users.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
773 }) 773 })
774 774
775 it('Should success with the correct parameters', async function () { 775 it('Should success with the correct parameters', async function () {
776 await server.usersCommand.getMyInfo({ token: userToken }) 776 await server.users.getMyInfo({ token: userToken })
777 }) 777 })
778 }) 778 })
779 779
@@ -781,7 +781,7 @@ describe('Test users API validators', function () {
781 let command: UsersCommand 781 let command: UsersCommand
782 782
783 before(function () { 783 before(function () {
784 command = server.usersCommand 784 command = server.users
785 }) 785 })
786 786
787 it('Should fail with a non authenticated user', async function () { 787 it('Should fail with a non authenticated user', async function () {
@@ -846,54 +846,54 @@ describe('Test users API validators', function () {
846 it('Should fail with an incorrect id', async function () { 846 it('Should fail with an incorrect id', async function () {
847 const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 } 847 const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
848 848
849 await server.usersCommand.remove(options) 849 await server.users.remove(options)
850 await server.usersCommand.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 850 await server.users.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
851 await server.usersCommand.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 851 await server.users.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
852 }) 852 })
853 853
854 it('Should fail with the root user', async function () { 854 it('Should fail with the root user', async function () {
855 const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 } 855 const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
856 856
857 await server.usersCommand.remove(options) 857 await server.users.remove(options)
858 await server.usersCommand.banUser(options) 858 await server.users.banUser(options)
859 await server.usersCommand.unbanUser(options) 859 await server.users.unbanUser(options)
860 }) 860 })
861 861
862 it('Should return 404 with a non existing id', async function () { 862 it('Should return 404 with a non existing id', async function () {
863 const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 } 863 const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 }
864 864
865 await server.usersCommand.remove(options) 865 await server.users.remove(options)
866 await server.usersCommand.banUser(options) 866 await server.users.banUser(options)
867 await server.usersCommand.unbanUser(options) 867 await server.users.unbanUser(options)
868 }) 868 })
869 869
870 it('Should fail with a non admin user', async function () { 870 it('Should fail with a non admin user', async function () {
871 const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 } 871 const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
872 872
873 await server.usersCommand.remove(options) 873 await server.users.remove(options)
874 await server.usersCommand.banUser(options) 874 await server.users.banUser(options)
875 await server.usersCommand.unbanUser(options) 875 await server.users.unbanUser(options)
876 }) 876 })
877 877
878 it('Should fail on a moderator with a moderator', async function () { 878 it('Should fail on a moderator with a moderator', async function () {
879 const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 } 879 const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
880 880
881 await server.usersCommand.remove(options) 881 await server.users.remove(options)
882 await server.usersCommand.banUser(options) 882 await server.users.banUser(options)
883 await server.usersCommand.unbanUser(options) 883 await server.users.unbanUser(options)
884 }) 884 })
885 885
886 it('Should succeed on a user with a moderator', async function () { 886 it('Should succeed on a user with a moderator', async function () {
887 const options = { userId, token: moderatorToken } 887 const options = { userId, token: moderatorToken }
888 888
889 await server.usersCommand.banUser(options) 889 await server.users.banUser(options)
890 await server.usersCommand.unbanUser(options) 890 await server.users.unbanUser(options)
891 }) 891 })
892 }) 892 })
893 893
894 describe('When deleting our account', function () { 894 describe('When deleting our account', function () {
895 it('Should fail with with the root account', async function () { 895 it('Should fail with with the root account', async function () {
896 await server.usersCommand.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 896 await server.users.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
897 }) 897 })
898 }) 898 })
899 899
@@ -1011,7 +1011,7 @@ describe('Test users API validators', function () {
1011 1011
1012 it('Should fail with an existing channel', async function () { 1012 it('Should fail with an existing channel', async function () {
1013 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' } 1013 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
1014 await server.channelsCommand.create({ attributes }) 1014 await server.channels.create({ attributes })
1015 1015
1016 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } } 1016 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
1017 1017
@@ -1055,7 +1055,7 @@ describe('Test users API validators', function () {
1055 1055
1056 describe('When registering multiple users on a server with users limit', function () { 1056 describe('When registering multiple users on a server with users limit', function () {
1057 it('Should fail when after 3 registrations', async function () { 1057 it('Should fail when after 3 registrations', async function () {
1058 await server.usersCommand.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 1058 await server.users.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
1059 }) 1059 })
1060 }) 1060 })
1061 1061
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index 0fda31b29..51609b982 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -40,41 +40,41 @@ describe('Test video blacklist API validators', function () {
40 { 40 {
41 const username = 'user1' 41 const username = 'user1'
42 const password = 'my super password' 42 const password = 'my super password'
43 await servers[0].usersCommand.create({ username: username, password: password }) 43 await servers[0].users.create({ username: username, password: password })
44 userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password }) 44 userAccessToken1 = await servers[0].login.getAccessToken({ username, password })
45 } 45 }
46 46
47 { 47 {
48 const username = 'user2' 48 const username = 'user2'
49 const password = 'my super password' 49 const password = 'my super password'
50 await servers[0].usersCommand.create({ username: username, password: password }) 50 await servers[0].users.create({ username: username, password: password })
51 userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password }) 51 userAccessToken2 = await servers[0].login.getAccessToken({ username, password })
52 } 52 }
53 53
54 { 54 {
55 servers[0].video = await servers[0].videosCommand.upload({ token: userAccessToken1 }) 55 servers[0].store.video = await servers[0].videos.upload({ token: userAccessToken1 })
56 } 56 }
57 57
58 { 58 {
59 const { uuid } = await servers[0].videosCommand.upload() 59 const { uuid } = await servers[0].videos.upload()
60 notBlacklistedVideoId = uuid 60 notBlacklistedVideoId = uuid
61 } 61 }
62 62
63 { 63 {
64 const { uuid } = await servers[1].videosCommand.upload() 64 const { uuid } = await servers[1].videos.upload()
65 remoteVideoUUID = uuid 65 remoteVideoUUID = uuid
66 } 66 }
67 67
68 await waitJobs(servers) 68 await waitJobs(servers)
69 69
70 command = servers[0].blacklistCommand 70 command = servers[0].blacklist
71 }) 71 })
72 72
73 describe('When adding a video in blacklist', function () { 73 describe('When adding a video in blacklist', function () {
74 const basePath = '/api/v1/videos/' 74 const basePath = '/api/v1/videos/'
75 75
76 it('Should fail with nothing', async function () { 76 it('Should fail with nothing', async function () {
77 const path = basePath + servers[0].video + '/blacklist' 77 const path = basePath + servers[0].store.video + '/blacklist'
78 const fields = {} 78 const fields = {}
79 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 79 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
80 }) 80 })
@@ -86,13 +86,13 @@ describe('Test video blacklist API validators', function () {
86 }) 86 })
87 87
88 it('Should fail with a non authenticated user', async function () { 88 it('Should fail with a non authenticated user', async function () {
89 const path = basePath + servers[0].video + '/blacklist' 89 const path = basePath + servers[0].store.video + '/blacklist'
90 const fields = {} 90 const fields = {}
91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
92 }) 92 })
93 93
94 it('Should fail with a non admin user', async function () { 94 it('Should fail with a non admin user', async function () {
95 const path = basePath + servers[0].video + '/blacklist' 95 const path = basePath + servers[0].store.video + '/blacklist'
96 const fields = {} 96 const fields = {}
97 await makePostBodyRequest({ 97 await makePostBodyRequest({
98 url: servers[0].url, 98 url: servers[0].url,
@@ -104,7 +104,7 @@ describe('Test video blacklist API validators', function () {
104 }) 104 })
105 105
106 it('Should fail with an invalid reason', async function () { 106 it('Should fail with an invalid reason', async function () {
107 const path = basePath + servers[0].video.uuid + '/blacklist' 107 const path = basePath + servers[0].store.video.uuid + '/blacklist'
108 const fields = { reason: 'a'.repeat(305) } 108 const fields = { reason: 'a'.repeat(305) }
109 109
110 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 110 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
@@ -124,7 +124,7 @@ describe('Test video blacklist API validators', function () {
124 }) 124 })
125 125
126 it('Should succeed with the correct params', async function () { 126 it('Should succeed with the correct params', async function () {
127 const path = basePath + servers[0].video.uuid + '/blacklist' 127 const path = basePath + servers[0].store.video.uuid + '/blacklist'
128 const fields = {} 128 const fields = {}
129 129
130 await makePostBodyRequest({ 130 await makePostBodyRequest({
@@ -159,13 +159,13 @@ describe('Test video blacklist API validators', function () {
159 }) 159 })
160 160
161 it('Should fail with a non authenticated user', async function () { 161 it('Should fail with a non authenticated user', async function () {
162 const path = basePath + servers[0].video + '/blacklist' 162 const path = basePath + servers[0].store.video + '/blacklist'
163 const fields = {} 163 const fields = {}
164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
165 }) 165 })
166 166
167 it('Should fail with a non admin user', async function () { 167 it('Should fail with a non admin user', async function () {
168 const path = basePath + servers[0].video + '/blacklist' 168 const path = basePath + servers[0].store.video + '/blacklist'
169 const fields = {} 169 const fields = {}
170 await makePutBodyRequest({ 170 await makePutBodyRequest({
171 url: servers[0].url, 171 url: servers[0].url,
@@ -177,14 +177,14 @@ describe('Test video blacklist API validators', function () {
177 }) 177 })
178 178
179 it('Should fail with an invalid reason', async function () { 179 it('Should fail with an invalid reason', async function () {
180 const path = basePath + servers[0].video.uuid + '/blacklist' 180 const path = basePath + servers[0].store.video.uuid + '/blacklist'
181 const fields = { reason: 'a'.repeat(305) } 181 const fields = { reason: 'a'.repeat(305) }
182 182
183 await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 183 await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
184 }) 184 })
185 185
186 it('Should succeed with the correct params', async function () { 186 it('Should succeed with the correct params', async function () {
187 const path = basePath + servers[0].video.shortUUID + '/blacklist' 187 const path = basePath + servers[0].store.video.shortUUID + '/blacklist'
188 const fields = { reason: 'hello' } 188 const fields = { reason: 'hello' }
189 189
190 await makePutBodyRequest({ 190 await makePutBodyRequest({
@@ -200,27 +200,27 @@ describe('Test video blacklist API validators', function () {
200 describe('When getting blacklisted video', function () { 200 describe('When getting blacklisted video', function () {
201 201
202 it('Should fail with a non authenticated user', async function () { 202 it('Should fail with a non authenticated user', async function () {
203 await servers[0].videosCommand.get({ id: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 203 await servers[0].videos.get({ id: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
204 }) 204 })
205 205
206 it('Should fail with another user', async function () { 206 it('Should fail with another user', async function () {
207 await servers[0].videosCommand.getWithToken({ 207 await servers[0].videos.getWithToken({
208 token: userAccessToken2, 208 token: userAccessToken2,
209 id: servers[0].video.uuid, 209 id: servers[0].store.video.uuid,
210 expectedStatus: HttpStatusCode.FORBIDDEN_403 210 expectedStatus: HttpStatusCode.FORBIDDEN_403
211 }) 211 })
212 }) 212 })
213 213
214 it('Should succeed with the owner authenticated user', async function () { 214 it('Should succeed with the owner authenticated user', async function () {
215 const video = await servers[0].videosCommand.getWithToken({ token: userAccessToken1, id: servers[0].video.uuid }) 215 const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.video.uuid })
216 expect(video.blacklisted).to.be.true 216 expect(video.blacklisted).to.be.true
217 }) 217 })
218 218
219 it('Should succeed with an admin', async function () { 219 it('Should succeed with an admin', async function () {
220 const video = servers[0].video 220 const video = servers[0].store.video
221 221
222 for (const id of [ video.id, video.uuid, video.shortUUID ]) { 222 for (const id of [ video.id, video.uuid, video.shortUUID ]) {
223 const video = await servers[0].videosCommand.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 }) 223 const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
224 expect(video.blacklisted).to.be.true 224 expect(video.blacklisted).to.be.true
225 } 225 }
226 }) 226 })
@@ -229,11 +229,11 @@ describe('Test video blacklist API validators', function () {
229 describe('When removing a video in blacklist', function () { 229 describe('When removing a video in blacklist', function () {
230 230
231 it('Should fail with a non authenticated user', async function () { 231 it('Should fail with a non authenticated user', async function () {
232 await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 232 await command.remove({ token: 'fake token', videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
233 }) 233 })
234 234
235 it('Should fail with a non admin user', async function () { 235 it('Should fail with a non admin user', async function () {
236 await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 236 await command.remove({ token: userAccessToken2, videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
237 }) 237 })
238 238
239 it('Should fail with an incorrect id', async function () { 239 it('Should fail with an incorrect id', async function () {
@@ -246,7 +246,7 @@ describe('Test video blacklist API validators', function () {
246 }) 246 })
247 247
248 it('Should succeed with the correct params', async function () { 248 it('Should succeed with the correct params', async function () {
249 await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) 249 await command.remove({ videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
250 }) 250 })
251 }) 251 })
252 252
@@ -254,11 +254,11 @@ describe('Test video blacklist API validators', function () {
254 const basePath = '/api/v1/videos/blacklist/' 254 const basePath = '/api/v1/videos/blacklist/'
255 255
256 it('Should fail with a non authenticated user', async function () { 256 it('Should fail with a non authenticated user', async function () {
257 await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 257 await servers[0].blacklist.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
258 }) 258 })
259 259
260 it('Should fail with a non admin user', async function () { 260 it('Should fail with a non admin user', async function () {
261 await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 261 await servers[0].blacklist.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
262 }) 262 })
263 263
264 it('Should fail with a bad start pagination', async function () { 264 it('Should fail with a bad start pagination', async function () {
@@ -274,11 +274,11 @@ describe('Test video blacklist API validators', function () {
274 }) 274 })
275 275
276 it('Should fail with an invalid type', async function () { 276 it('Should fail with an invalid type', async function () {
277 await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 277 await servers[0].blacklist.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
278 }) 278 })
279 279
280 it('Should succeed with the correct parameters', async function () { 280 it('Should succeed with the correct parameters', async function () {
281 await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL }) 281 await servers[0].blacklist.list({ type: VideoBlacklistType.MANUAL })
282 }) 282 })
283 }) 283 })
284 284
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index f3941b3fa..913f894b9 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -30,15 +30,15 @@ describe('Test video captions API validator', function () {
30 30
31 await setAccessTokensToServers([ server ]) 31 await setAccessTokensToServers([ server ])
32 32
33 video = await server.videosCommand.upload() 33 video = await server.videos.upload()
34 34
35 { 35 {
36 const user = { 36 const user = {
37 username: 'user1', 37 username: 'user1',
38 password: 'my super password' 38 password: 'my super password'
39 } 39 }
40 await server.usersCommand.create({ username: user.username, password: user.password }) 40 await server.users.create({ username: user.username, password: user.password })
41 userAccessToken = await server.loginCommand.getAccessToken(user) 41 userAccessToken = await server.login.getAccessToken(user)
42 } 42 }
43 }) 43 })
44 44
@@ -152,7 +152,7 @@ describe('Test video captions API validator', function () {
152 // }) 152 // })
153 153
154 it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () { 154 it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
155 await server.captionsCommand.createVideoCaption({ 155 await server.captions.createVideoCaption({
156 language: 'zh', 156 language: 'zh',
157 videoId: video.uuid, 157 videoId: video.uuid,
158 fixture: 'subtitle-good.srt', 158 fixture: 'subtitle-good.srt',
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 2b4c17ea1..8e6e32f20 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -44,11 +44,11 @@ describe('Test video channels API validator', function () {
44 } 44 }
45 45
46 { 46 {
47 await server.usersCommand.create({ username: user.username, password: user.password }) 47 await server.users.create({ username: user.username, password: user.password })
48 accessTokenUser = await server.loginCommand.getAccessToken(user) 48 accessTokenUser = await server.login.getAccessToken(user)
49 } 49 }
50 50
51 command = server.channelsCommand 51 command = server.channels
52 }) 52 })
53 53
54 describe('When listing a video channels', function () { 54 describe('When listing a video channels', function () {
@@ -81,7 +81,7 @@ describe('Test video channels API validator', function () {
81 }) 81 })
82 82
83 it('Should fail with a unknown account', async function () { 83 it('Should fail with a unknown account', async function () {
84 await server.channelsCommand.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 84 await server.channels.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
85 }) 85 })
86 86
87 it('Should succeed with the correct parameters', async function () { 87 it('Should succeed with the correct parameters', async function () {
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index bdf7f91ee..44af9d7e3 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -38,26 +38,26 @@ describe('Test video comments API validator', function () {
38 await setAccessTokensToServers([ server ]) 38 await setAccessTokensToServers([ server ])
39 39
40 { 40 {
41 const video = await server.videosCommand.upload({ attributes: {} }) 41 const video = await server.videos.upload({ attributes: {} })
42 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' 42 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
43 } 43 }
44 44
45 { 45 {
46 const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'coucou' }) 46 const created = await server.comments.createThread({ videoId: video.uuid, text: 'coucou' })
47 commentId = created.id 47 commentId = created.id
48 pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId 48 pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
49 } 49 }
50 50
51 { 51 {
52 const user = { username: 'user1', password: 'my super password' } 52 const user = { username: 'user1', password: 'my super password' }
53 await server.usersCommand.create({ username: user.username, password: user.password }) 53 await server.users.create({ username: user.username, password: user.password })
54 userAccessToken = await server.loginCommand.getAccessToken(user) 54 userAccessToken = await server.login.getAccessToken(user)
55 } 55 }
56 56
57 { 57 {
58 const user = { username: 'user2', password: 'my super password' } 58 const user = { username: 'user2', password: 'my super password' }
59 await server.usersCommand.create({ username: user.username, password: user.password }) 59 await server.users.create({ username: user.username, password: user.password })
60 userAccessToken2 = await server.loginCommand.getAccessToken(user) 60 userAccessToken2 = await server.login.getAccessToken(user)
61 } 61 }
62 }) 62 })
63 63
@@ -274,7 +274,7 @@ describe('Test video comments API validator', function () {
274 let commentToDelete: number 274 let commentToDelete: number
275 275
276 { 276 {
277 const created = await server.commentsCommand.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' }) 277 const created = await server.comments.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
278 commentToDelete = created.id 278 commentToDelete = created.id
279 } 279 }
280 280
@@ -289,12 +289,12 @@ describe('Test video comments API validator', function () {
289 let anotherVideoUUID: string 289 let anotherVideoUUID: string
290 290
291 { 291 {
292 const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes: { name: 'video' } }) 292 const { uuid } = await server.videos.upload({ token: userAccessToken, attributes: { name: 'video' } })
293 anotherVideoUUID = uuid 293 anotherVideoUUID = uuid
294 } 294 }
295 295
296 { 296 {
297 const created = await server.commentsCommand.createThread({ videoId: anotherVideoUUID, text: 'hello' }) 297 const created = await server.comments.createThread({ videoId: anotherVideoUUID, text: 'hello' })
298 commentToDelete = created.id 298 commentToDelete = created.id
299 } 299 }
300 300
@@ -316,7 +316,7 @@ describe('Test video comments API validator', function () {
316 316
317 describe('When a video has comments disabled', function () { 317 describe('When a video has comments disabled', function () {
318 before(async function () { 318 before(async function () {
319 video = await server.videosCommand.upload({ attributes: { commentsEnabled: false } }) 319 video = await server.videos.upload({ attributes: { commentsEnabled: false } })
320 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' 320 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
321 }) 321 })
322 322
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index d09e473de..1a6b6075f 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -36,11 +36,11 @@ describe('Test video imports API validator', function () {
36 36
37 const username = 'user1' 37 const username = 'user1'
38 const password = 'my super password' 38 const password = 'my super password'
39 await server.usersCommand.create({ username: username, password: password }) 39 await server.users.create({ username: username, password: password })
40 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 40 userAccessToken = await server.login.getAccessToken({ username, password })
41 41
42 { 42 {
43 const { videoChannels } = await server.usersCommand.getMyInfo() 43 const { videoChannels } = await server.users.getMyInfo()
44 channelId = videoChannels[0].id 44 channelId = videoChannels[0].id
45 } 45 }
46 }) 46 })
@@ -162,10 +162,10 @@ describe('Test video imports API validator', function () {
162 username: 'fake', 162 username: 'fake',
163 password: 'fake_password' 163 password: 'fake_password'
164 } 164 }
165 await server.usersCommand.create({ username: user.username, password: user.password }) 165 await server.users.create({ username: user.username, password: user.password })
166 166
167 const accessTokenUser = await server.loginCommand.getAccessToken(user) 167 const accessTokenUser = await server.login.getAccessToken(user)
168 const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser }) 168 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
169 const customChannelId = videoChannels[0].id 169 const customChannelId = videoChannels[0].id
170 170
171 const fields = { ...baseCorrectParams, channelId: customChannelId } 171 const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -256,7 +256,7 @@ describe('Test video imports API validator', function () {
256 }) 256 })
257 257
258 it('Should forbid to import http videos', async function () { 258 it('Should forbid to import http videos', async function () {
259 await server.configCommand.updateCustomSubConfig({ 259 await server.config.updateCustomSubConfig({
260 newConfig: { 260 newConfig: {
261 import: { 261 import: {
262 videos: { 262 videos: {
@@ -281,7 +281,7 @@ describe('Test video imports API validator', function () {
281 }) 281 })
282 282
283 it('Should forbid to import torrent videos', async function () { 283 it('Should forbid to import torrent videos', async function () {
284 await server.configCommand.updateCustomSubConfig({ 284 await server.config.updateCustomSubConfig({
285 newConfig: { 285 newConfig: {
286 import: { 286 import: {
287 videos: { 287 videos: {
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index ebd7e2413..e0e42ebb0 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -47,10 +47,10 @@ describe('Test video playlists API validator', function () {
47 await setAccessTokensToServers([ server ]) 47 await setAccessTokensToServers([ server ])
48 await setDefaultVideoChannel([ server ]) 48 await setDefaultVideoChannel([ server ])
49 49
50 userAccessToken = await server.usersCommand.generateUserAndToken('user1') 50 userAccessToken = await server.users.generateUserAndToken('user1')
51 videoId = (await server.videosCommand.quickUpload({ name: 'video 1' })).id 51 videoId = (await server.videos.quickUpload({ name: 'video 1' })).id
52 52
53 command = server.playlistsCommand 53 command = server.playlists
54 54
55 { 55 {
56 const { data } = await command.listByAccount({ 56 const { data } = await command.listByAccount({
@@ -68,7 +68,7 @@ describe('Test video playlists API validator', function () {
68 attributes: { 68 attributes: {
69 displayName: 'super playlist', 69 displayName: 'super playlist',
70 privacy: VideoPlaylistPrivacy.PUBLIC, 70 privacy: VideoPlaylistPrivacy.PUBLIC,
71 videoChannelId: server.videoChannel.id 71 videoChannelId: server.store.channel.id
72 } 72 }
73 }) 73 })
74 } 74 }
@@ -176,7 +176,7 @@ describe('Test video playlists API validator', function () {
176 const playlist = await command.create({ 176 const playlist = await command.create({
177 attributes: { 177 attributes: {
178 displayName: 'super playlist', 178 displayName: 'super playlist',
179 videoChannelId: server.videoChannel.id, 179 videoChannelId: server.store.channel.id,
180 privacy: VideoPlaylistPrivacy.UNLISTED 180 privacy: VideoPlaylistPrivacy.UNLISTED
181 } 181 }
182 }) 182 })
@@ -200,7 +200,7 @@ describe('Test video playlists API validator', function () {
200 displayName: 'display name', 200 displayName: 'display name',
201 privacy: VideoPlaylistPrivacy.UNLISTED, 201 privacy: VideoPlaylistPrivacy.UNLISTED,
202 thumbnailfile: 'thumbnail.jpg', 202 thumbnailfile: 'thumbnail.jpg',
203 videoChannelId: server.videoChannel.id, 203 videoChannelId: server.store.channel.id,
204 204
205 ...attributes 205 ...attributes
206 }, 206 },
@@ -485,8 +485,8 @@ describe('Test video playlists API validator', function () {
485 } 485 }
486 486
487 before(async function () { 487 before(async function () {
488 videoId3 = (await server.videosCommand.quickUpload({ name: 'video 3' })).id 488 videoId3 = (await server.videos.quickUpload({ name: 'video 3' })).id
489 videoId4 = (await server.videosCommand.quickUpload({ name: 'video 4' })).id 489 videoId4 = (await server.videos.quickUpload({ name: 'video 4' })).id
490 490
491 for (const id of [ videoId3, videoId4 ]) { 491 for (const id of [ videoId3, videoId4 ]) {
492 await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } }) 492 await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } })
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index d7bf081d4..cbfdef1db 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -49,13 +49,13 @@ describe('Test video filters validators', function () {
49 await setDefaultVideoChannel([ server ]) 49 await setDefaultVideoChannel([ server ])
50 50
51 const user = { username: 'user1', password: 'my super password' } 51 const user = { username: 'user1', password: 'my super password' }
52 await server.usersCommand.create({ username: user.username, password: user.password }) 52 await server.users.create({ username: user.username, password: user.password })
53 userAccessToken = await server.loginCommand.getAccessToken(user) 53 userAccessToken = await server.login.getAccessToken(user)
54 54
55 const moderator = { username: 'moderator', password: 'my super password' } 55 const moderator = { username: 'moderator', password: 'my super password' }
56 await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) 56 await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
57 57
58 moderatorAccessToken = await server.loginCommand.getAccessToken(moderator) 58 moderatorAccessToken = await server.login.getAccessToken(moderator)
59 }) 59 })
60 60
61 describe('When setting a video filter', function () { 61 describe('When setting a video filter', function () {
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 1da922a17..549c9fa1f 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -29,7 +29,7 @@ describe('Test videos history API validator', function () {
29 29
30 await setAccessTokensToServers([ server ]) 30 await setAccessTokensToServers([ server ])
31 31
32 const { uuid } = await server.videosCommand.upload() 32 const { uuid } = await server.videos.upload()
33 watchingPath = '/api/v1/videos/' + uuid + '/watching' 33 watchingPath = '/api/v1/videos/' + uuid + '/watching'
34 }) 34 })
35 35
diff --git a/server/tests/api/check-params/videos-overviews.ts b/server/tests/api/check-params/videos-overviews.ts
index 44a936c9f..3597c81d3 100644
--- a/server/tests/api/check-params/videos-overviews.ts
+++ b/server/tests/api/check-params/videos-overviews.ts
@@ -17,12 +17,12 @@ describe('Test videos overview', function () {
17 describe('When getting videos overview', function () { 17 describe('When getting videos overview', function () {
18 18
19 it('Should fail with a bad pagination', async function () { 19 it('Should fail with a bad pagination', async function () {
20 await server.overviewsCommand.getVideos({ page: 0, expectedStatus: 400 }) 20 await server.overviews.getVideos({ page: 0, expectedStatus: 400 })
21 await server.overviewsCommand.getVideos({ page: 100, expectedStatus: 400 }) 21 await server.overviews.getVideos({ page: 100, expectedStatus: 400 })
22 }) 22 })
23 23
24 it('Should succeed with a good pagination', async function () { 24 it('Should succeed with a good pagination', async function () {
25 await server.overviewsCommand.getVideos({ page: 1 }) 25 await server.overviews.getVideos({ page: 1 })
26 }) 26 })
27 }) 27 })
28 28
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 8f9f33b8c..69bdae7cf 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -44,11 +44,11 @@ describe('Test videos API validator', function () {
44 44
45 const username = 'user1' 45 const username = 'user1'
46 const password = 'my super password' 46 const password = 'my super password'
47 await server.usersCommand.create({ username: username, password: password }) 47 await server.users.create({ username: username, password: password })
48 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 48 userAccessToken = await server.login.getAccessToken({ username, password })
49 49
50 { 50 {
51 const body = await server.usersCommand.getMyInfo() 51 const body = await server.users.getMyInfo()
52 channelId = body.videoChannels[0].id 52 channelId = body.videoChannels[0].id
53 channelName = body.videoChannels[0].name 53 channelName = body.videoChannels[0].name
54 accountName = body.account.name + '@' + body.account.host 54 accountName = body.account.name + '@' + body.account.host
@@ -274,10 +274,10 @@ describe('Test videos API validator', function () {
274 username: 'fake' + randomInt(0, 1500), 274 username: 'fake' + randomInt(0, 1500),
275 password: 'fake_password' 275 password: 'fake_password'
276 } 276 }
277 await server.usersCommand.create({ username: user.username, password: user.password }) 277 await server.users.create({ username: user.username, password: user.password })
278 278
279 const accessTokenUser = await server.loginCommand.getAccessToken(user) 279 const accessTokenUser = await server.login.getAccessToken(user)
280 const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser }) 280 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
281 const customChannelId = videoChannels[0].id 281 const customChannelId = videoChannels[0].id
282 282
283 const fields = { ...baseCorrectParams, channelId: customChannelId } 283 const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -484,7 +484,7 @@ describe('Test videos API validator', function () {
484 } 484 }
485 485
486 before(async function () { 486 before(async function () {
487 const { data } = await server.videosCommand.list() 487 const { data } = await server.videos.list()
488 video = data[0] 488 video = data[0]
489 }) 489 })
490 490
@@ -710,15 +710,15 @@ describe('Test videos API validator', function () {
710 }) 710 })
711 711
712 it('Should fail without a correct uuid', async function () { 712 it('Should fail without a correct uuid', async function () {
713 await server.videosCommand.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 713 await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
714 }) 714 })
715 715
716 it('Should return 404 with an incorrect video', async function () { 716 it('Should return 404 with an incorrect video', async function () {
717 await server.videosCommand.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 717 await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
718 }) 718 })
719 719
720 it('Shoud report the appropriate error', async function () { 720 it('Shoud report the appropriate error', async function () {
721 const body = await server.videosCommand.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 721 const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
722 const error = body as unknown as PeerTubeProblemDocument 722 const error = body as unknown as PeerTubeProblemDocument
723 723
724 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') 724 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
@@ -734,7 +734,7 @@ describe('Test videos API validator', function () {
734 }) 734 })
735 735
736 it('Should succeed with the correct parameters', async function () { 736 it('Should succeed with the correct parameters', async function () {
737 await server.videosCommand.get({ id: video.shortUUID }) 737 await server.videos.get({ id: video.shortUUID })
738 }) 738 })
739 }) 739 })
740 740
@@ -742,7 +742,7 @@ describe('Test videos API validator', function () {
742 let videoId: number 742 let videoId: number
743 743
744 before(async function () { 744 before(async function () {
745 const { data } = await server.videosCommand.list() 745 const { data } = await server.videos.list()
746 videoId = data[0].id 746 videoId = data[0].id
747 }) 747 })
748 748
@@ -797,21 +797,21 @@ describe('Test videos API validator', function () {
797 }) 797 })
798 798
799 it('Should fail without a correct uuid', async function () { 799 it('Should fail without a correct uuid', async function () {
800 await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 800 await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
801 }) 801 })
802 802
803 it('Should fail with a video which does not exist', async function () { 803 it('Should fail with a video which does not exist', async function () {
804 await server.videosCommand.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 804 await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
805 }) 805 })
806 806
807 it('Should fail with a video of another user without the appropriate right', async function () { 807 it('Should fail with a video of another user without the appropriate right', async function () {
808 await server.videosCommand.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 808 await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
809 }) 809 })
810 810
811 it('Should fail with a video of another server') 811 it('Should fail with a video of another server')
812 812
813 it('Shoud report the appropriate error', async function () { 813 it('Shoud report the appropriate error', async function () {
814 const body = await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
815 const error = body as unknown as PeerTubeProblemDocument 815 const error = body as unknown as PeerTubeProblemDocument
816 816
817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') 817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
@@ -827,7 +827,7 @@ describe('Test videos API validator', function () {
827 }) 827 })
828 828
829 it('Should succeed with the correct parameters', async function () { 829 it('Should succeed with the correct parameters', async function () {
830 await server.videosCommand.remove({ id: video.uuid }) 830 await server.videos.remove({ id: video.uuid })
831 }) 831 })
832 }) 832 })
833 833