aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/multiple-servers.ts3
-rw-r--r--server/tests/api/videos/resumable-upload.ts17
-rw-r--r--server/tests/api/videos/video-change-ownership.ts89
-rw-r--r--server/tests/api/videos/video-channels.ts22
-rw-r--r--server/tests/api/videos/video-comments.ts16
-rw-r--r--server/tests/api/videos/video-imports.ts9
-rw-r--r--server/tests/api/videos/video-nsfw.ts26
-rw-r--r--server/tests/api/videos/video-playlists.ts34
-rw-r--r--server/tests/api/videos/video-privacy.ts3
-rw-r--r--server/tests/api/videos/videos-filter.ts13
-rw-r--r--server/tests/api/videos/videos-history.ts12
-rw-r--r--server/tests/api/videos/videos-overview.ts12
12 files changed, 63 insertions, 193 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 740314bfd..169bb2e23 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -10,7 +10,6 @@ import {
10 checkVideoFilesWereRemoved, 10 checkVideoFilesWereRemoved,
11 cleanupTests, 11 cleanupTests,
12 completeVideoCheck, 12 completeVideoCheck,
13 createUser,
14 dateIsValid, 13 dateIsValid,
15 doubleFollow, 14 doubleFollow,
16 flushAndRunMultipleServers, 15 flushAndRunMultipleServers,
@@ -153,7 +152,7 @@ describe('Test multiple servers', function () {
153 username: 'user1', 152 username: 'user1',
154 password: 'super_password' 153 password: 'super_password'
155 } 154 }
156 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) 155 await servers[1].usersCommand.create({ username: user.username, password: user.password })
157 const userAccessToken = await servers[1].loginCommand.getAccessToken(user) 156 const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
158 157
159 const videoAttributes = { 158 const videoAttributes = {
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 5845efc86..642c115d0 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -9,15 +9,13 @@ import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
11 flushAndRunServer, 11 flushAndRunServer,
12 getMyUserInformation,
13 prepareResumableUpload, 12 prepareResumableUpload,
14 sendResumableChunks, 13 sendResumableChunks,
15 ServerInfo, 14 ServerInfo,
16 setAccessTokensToServers, 15 setAccessTokensToServers,
17 setDefaultVideoChannel, 16 setDefaultVideoChannel
18 updateUser
19} from '@shared/extra-utils' 17} from '@shared/extra-utils'
20import { MyUser, VideoPrivacy } from '@shared/models' 18import { VideoPrivacy } from '@shared/models'
21 19
22const expect = chai.expect 20const expect = chai.expect
23 21
@@ -109,15 +107,10 @@ describe('Test resumable upload', function () {
109 await setAccessTokensToServers([ server ]) 107 await setAccessTokensToServers([ server ])
110 await setDefaultVideoChannel([ server ]) 108 await setDefaultVideoChannel([ server ])
111 109
112 const res = await getMyUserInformation(server.url, server.accessToken) 110 const body = await server.usersCommand.getMyInfo()
113 rootId = (res.body as MyUser).id 111 rootId = body.id
114 112
115 await updateUser({ 113 await server.usersCommand.update({ userId: rootId, videoQuota: 10_000_000 })
116 url: server.url,
117 userId: rootId,
118 accessToken: server.accessToken,
119 videoQuota: 10_000_000
120 })
121 }) 114 })
122 115
123 describe('Directory cleaning', function () { 116 describe('Directory cleaning', function () {
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 17c738e6f..b0bbd5a0d 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -6,11 +6,9 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c
6import { 6import {
7 ChangeOwnershipCommand, 7 ChangeOwnershipCommand,
8 cleanupTests, 8 cleanupTests,
9 createUser,
10 doubleFollow, 9 doubleFollow,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
12 flushAndRunServer, 11 flushAndRunServer,
13 getMyUserInformation,
14 getVideo, 12 getVideo,
15 getVideosList, 13 getVideosList,
16 ServerInfo, 14 ServerInfo,
@@ -19,21 +17,15 @@ import {
19 uploadVideo 17 uploadVideo
20} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
21import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
22import { User } from '../../../../shared/models/users'
23import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' 20import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
24 21
25const expect = chai.expect 22const expect = chai.expect
26 23
27describe('Test video change ownership - nominal', function () { 24describe('Test video change ownership - nominal', function () {
28 let servers: ServerInfo[] = [] 25 let servers: ServerInfo[] = []
29 const firstUser = { 26
30 username: 'first', 27 const firstUser = 'first'
31 password: 'My great password' 28 const secondUser = 'second'
32 }
33 const secondUser = {
34 username: 'second',
35 password: 'My other password'
36 }
37 29
38 let firstUserToken = '' 30 let firstUserToken = ''
39 let firstUserChannelId: number 31 let firstUserChannelId: number
@@ -65,35 +57,17 @@ describe('Test video change ownership - nominal', function () {
65 } 57 }
66 }) 58 })
67 59
68 const videoQuota = 42000000 60 firstUserToken = await servers[0].usersCommand.generateUserAndToken(firstUser)
69 await createUser({ 61 secondUserToken = await servers[0].usersCommand.generateUserAndToken(secondUser)
70 url: servers[0].url,
71 accessToken: servers[0].accessToken,
72 username: firstUser.username,
73 password: firstUser.password,
74 videoQuota: videoQuota
75 })
76 await createUser({
77 url: servers[0].url,
78 accessToken: servers[0].accessToken,
79 username: secondUser.username,
80 password: secondUser.password,
81 videoQuota: videoQuota
82 })
83
84 firstUserToken = await servers[0].loginCommand.getAccessToken(firstUser)
85 secondUserToken = await servers[0].loginCommand.getAccessToken(secondUser)
86 62
87 { 63 {
88 const res = await getMyUserInformation(servers[0].url, firstUserToken) 64 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: firstUserToken })
89 const firstUserInformation: User = res.body 65 firstUserChannelId = videoChannels[0].id
90 firstUserChannelId = firstUserInformation.videoChannels[0].id
91 } 66 }
92 67
93 { 68 {
94 const res = await getMyUserInformation(servers[0].url, secondUserToken) 69 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: secondUserToken })
95 const secondUserInformation: User = res.body 70 secondUserChannelId = videoChannels[0].id
96 secondUserChannelId = secondUserInformation.videoChannels[0].id
97 } 71 }
98 72
99 { 73 {
@@ -140,7 +114,7 @@ describe('Test video change ownership - nominal', function () {
140 it('Should send a request to change ownership of a video', async function () { 114 it('Should send a request to change ownership of a video', async function () {
141 this.timeout(15000) 115 this.timeout(15000)
142 116
143 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser.username }) 117 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser })
144 }) 118 })
145 119
146 it('Should only return a request to change ownership for the second user', async function () { 120 it('Should only return a request to change ownership for the second user', async function () {
@@ -166,7 +140,7 @@ describe('Test video change ownership - nominal', function () {
166 it('Should accept the same change ownership request without crashing', async function () { 140 it('Should accept the same change ownership request without crashing', async function () {
167 this.timeout(10000) 141 this.timeout(10000)
168 142
169 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser.username }) 143 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser })
170 }) 144 })
171 145
172 it('Should not create multiple change ownership requests while one is waiting', async function () { 146 it('Should not create multiple change ownership requests while one is waiting', async function () {
@@ -194,7 +168,7 @@ describe('Test video change ownership - nominal', function () {
194 it('Should send a new request to change ownership of a video', async function () { 168 it('Should send a new request to change ownership of a video', async function () {
195 this.timeout(15000) 169 this.timeout(15000)
196 170
197 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser.username }) 171 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser })
198 }) 172 })
199 173
200 it('Should return two requests to change ownership for the second user', async function () { 174 it('Should return two requests to change ownership for the second user', async function () {
@@ -251,7 +225,7 @@ describe('Test video change ownership - nominal', function () {
251 it('Should send a request to change ownership of a live', async function () { 225 it('Should send a request to change ownership of a live', async function () {
252 this.timeout(15000) 226 this.timeout(15000)
253 227
254 await command.create({ token: firstUserToken, videoId: liveId, username: secondUser.username }) 228 await command.create({ token: firstUserToken, videoId: liveId, username: secondUser })
255 229
256 const body = await command.list({ token: secondUserToken }) 230 const body = await command.list({ token: secondUserToken })
257 231
@@ -286,14 +260,9 @@ describe('Test video change ownership - nominal', function () {
286 260
287describe('Test video change ownership - quota too small', function () { 261describe('Test video change ownership - quota too small', function () {
288 let server: ServerInfo 262 let server: ServerInfo
289 const firstUser = { 263 const firstUser = 'first'
290 username: 'first', 264 const secondUser = 'second'
291 password: 'My great password' 265
292 }
293 const secondUser = {
294 username: 'second',
295 password: 'My other password'
296 }
297 let firstUserToken = '' 266 let firstUserToken = ''
298 let secondUserToken = '' 267 let secondUserToken = ''
299 let lastRequestId: number 268 let lastRequestId: number
@@ -305,24 +274,9 @@ describe('Test video change ownership - quota too small', function () {
305 server = await flushAndRunServer(1) 274 server = await flushAndRunServer(1)
306 await setAccessTokensToServers([ server ]) 275 await setAccessTokensToServers([ server ])
307 276
308 const videoQuota = 42000000 277 await server.usersCommand.create({ username: secondUser, videoQuota: 10 })
309 const limitedVideoQuota = 10
310 await createUser({
311 url: server.url,
312 accessToken: server.accessToken,
313 username: firstUser.username,
314 password: firstUser.password,
315 videoQuota: videoQuota
316 })
317 await createUser({
318 url: server.url,
319 accessToken: server.accessToken,
320 username: secondUser.username,
321 password: secondUser.password,
322 videoQuota: limitedVideoQuota
323 })
324 278
325 firstUserToken = await server.loginCommand.getAccessToken(firstUser) 279 firstUserToken = await server.usersCommand.generateUserAndToken(firstUser)
326 secondUserToken = await server.loginCommand.getAccessToken(secondUser) 280 secondUserToken = await server.loginCommand.getAccessToken(secondUser)
327 281
328 // Upload some videos on the server 282 // Upload some videos on the server
@@ -345,7 +299,7 @@ describe('Test video change ownership - quota too small', function () {
345 it('Should send a request to change ownership of a video', async function () { 299 it('Should send a request to change ownership of a video', async function () {
346 this.timeout(15000) 300 this.timeout(15000)
347 301
348 await server.changeOwnershipCommand.create({ token: firstUserToken, videoId: server.video.id, username: secondUser.username }) 302 await server.changeOwnershipCommand.create({ token: firstUserToken, videoId: server.video.id, username: secondUser })
349 }) 303 })
350 304
351 it('Should only return a request to change ownership for the second user', async function () { 305 it('Should only return a request to change ownership for the second user', async function () {
@@ -371,9 +325,8 @@ describe('Test video change ownership - quota too small', function () {
371 it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () { 325 it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () {
372 this.timeout(10000) 326 this.timeout(10000)
373 327
374 const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserToken) 328 const { videoChannels } = await server.usersCommand.getMyInfo({ token: secondUserToken })
375 const secondUserInformation: User = secondUserInformationResponse.body 329 const channelId = videoChannels[0].id
376 const channelId = secondUserInformation.videoChannels[0].id
377 330
378 await server.changeOwnershipCommand.accept({ 331 await server.changeOwnershipCommand.accept({
379 token: secondUserToken, 332 token: secondUserToken,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 83645640c..2e57cbbff 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -6,21 +6,22 @@ import { basename } from 'path'
6import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' 6import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 createUser,
10 doubleFollow, 9 doubleFollow,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
12 getVideo, 11 getVideo,
13 getVideoChannelVideos, 12 getVideoChannelVideos,
13 ServerInfo,
14 setAccessTokensToServers,
14 setDefaultVideoChannel, 15 setDefaultVideoChannel,
15 testFileExistsOrNot, 16 testFileExistsOrNot,
16 testImage, 17 testImage,
17 updateVideo, 18 updateVideo,
18 uploadVideo, 19 uploadVideo,
19 wait 20 viewVideo,
20} from '../../../../shared/extra-utils' 21 wait,
21import { getMyUserInformation, ServerInfo, setAccessTokensToServers, viewVideo } from '../../../../shared/extra-utils/index' 22 waitJobs
22import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 23} from '@shared/extra-utils'
23import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index' 24import { User, Video, VideoChannel, VideoDetails } from '@shared/models'
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
@@ -85,8 +86,7 @@ describe('Test video channels', function () {
85 }) 86 })
86 87
87 it('Should have two video channels when getting my information', async () => { 88 it('Should have two video channels when getting my information', async () => {
88 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 89 userInfo = await servers[0].usersCommand.getMyInfo()
89 userInfo = res.body
90 90
91 expect(userInfo.videoChannels).to.be.an('array') 91 expect(userInfo.videoChannels).to.be.an('array')
92 expect(userInfo.videoChannels).to.have.lengthOf(2) 92 expect(userInfo.videoChannels).to.have.lengthOf(2)
@@ -389,11 +389,11 @@ describe('Test video channels', function () {
389 } 389 }
390 390
391 { 391 {
392 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' }) 392 await servers[0].usersCommand.create({ username: 'toto', password: 'password' })
393 const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' }) 393 const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' })
394 394
395 const res = await getMyUserInformation(servers[0].url, accessToken) 395 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: accessToken })
396 const videoChannel = res.body.videoChannels[0] 396 const videoChannel = videoChannels[0]
397 expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) 397 expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
398 } 398 }
399 }) 399 })
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index f9bd23646..266824d58 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -5,13 +5,11 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 CommentsCommand, 7 CommentsCommand,
8 createUser,
9 dateIsValid, 8 dateIsValid,
10 flushAndRunServer, 9 flushAndRunServer,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers, 11 setAccessTokensToServers,
13 testImage, 12 testImage,
14 updateMyAvatar,
15 uploadVideo 13 uploadVideo
16} from '@shared/extra-utils' 14} from '@shared/extra-utils'
17 15
@@ -39,19 +37,9 @@ describe('Test video comments', function () {
39 videoUUID = res.body.video.uuid 37 videoUUID = res.body.video.uuid
40 videoId = res.body.video.id 38 videoId = res.body.video.id
41 39
42 await updateMyAvatar({ 40 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' })
43 url: server.url,
44 accessToken: server.accessToken,
45 fixture: 'avatar.png'
46 })
47 41
48 await createUser({ 42 userAccessTokenServer1 = await server.usersCommand.generateUserAndToken('user1')
49 url: server.url,
50 accessToken: server.accessToken,
51 username: 'user1',
52 password: 'password'
53 })
54 userAccessTokenServer1 = await server.loginCommand.getAccessToken('user1', 'password')
55 43
56 command = server.commentsCommand 44 command = server.commentsCommand
57 }) 45 })
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index f6ae8cab1..052c052b4 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -7,7 +7,6 @@ import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getMyUserInformation,
11 getMyVideos, 10 getMyVideos,
12 getVideo, 11 getVideo,
13 getVideosList, 12 getVideosList,
@@ -97,13 +96,13 @@ describe('Test video imports', function () {
97 await setAccessTokensToServers(servers) 96 await setAccessTokensToServers(servers)
98 97
99 { 98 {
100 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 99 const { videoChannels } = await servers[0].usersCommand.getMyInfo()
101 channelIdServer1 = res.body.videoChannels[0].id 100 channelIdServer1 = videoChannels[0].id
102 } 101 }
103 102
104 { 103 {
105 const res = await getMyUserInformation(servers[1].url, servers[1].accessToken) 104 const { videoChannels } = await servers[1].usersCommand.getMyInfo()
106 channelIdServer2 = res.body.videoChannels[0].id 105 channelIdServer2 = videoChannels[0].id
107 } 106 }
108 107
109 await doubleFollow(servers[0], servers[1]) 108 await doubleFollow(servers[0], servers[1])
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index a30b11ace..9dc26fca6 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -4,20 +4,17 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 createUser,
8 flushAndRunServer, 7 flushAndRunServer,
9 getAccountVideos, 8 getAccountVideos,
10 getMyUserInformation,
11 getMyVideos, 9 getMyVideos,
12 getVideoChannelVideos, 10 getVideoChannelVideos,
13 getVideosList, 11 getVideosList,
14 getVideosListWithToken, 12 getVideosListWithToken,
15 ServerInfo, 13 ServerInfo,
16 setAccessTokensToServers, 14 setAccessTokensToServers,
17 updateMyUser,
18 uploadVideo 15 uploadVideo
19} from '@shared/extra-utils' 16} from '@shared/extra-utils'
20import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models' 17import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models'
21 18
22const expect = chai.expect 19const expect = chai.expect
23 20
@@ -32,8 +29,7 @@ describe('Test video NSFW policy', function () {
32 let customConfig: CustomConfig 29 let customConfig: CustomConfig
33 30
34 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { 31 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
35 const res = await getMyUserInformation(server.url, server.accessToken) 32 const user = await server.usersCommand.getMyInfo()
36 const user: User = res.body
37 const videoChannelName = user.videoChannels[0].name 33 const videoChannelName = user.videoChannels[0].name
38 const accountName = user.account.name + '@' + user.account.host 34 const accountName = user.account.name + '@' + user.account.host
39 const hasQuery = Object.keys(query).length !== 0 35 const hasQuery = Object.keys(query).length !== 0
@@ -148,13 +144,11 @@ describe('Test video NSFW policy', function () {
148 it('Should create a user having the default nsfw policy', async function () { 144 it('Should create a user having the default nsfw policy', async function () {
149 const username = 'user1' 145 const username = 'user1'
150 const password = 'my super password' 146 const password = 'my super password'
151 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) 147 await server.usersCommand.create({ username: username, password: password })
152 148
153 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 149 userAccessToken = await server.loginCommand.getAccessToken({ username, password })
154 150
155 const res = await getMyUserInformation(server.url, userAccessToken) 151 const user = await server.usersCommand.getMyInfo({ token: userAccessToken })
156 const user = res.body
157
158 expect(user.nsfwPolicy).to.equal('blur') 152 expect(user.nsfwPolicy).to.equal('blur')
159 }) 153 })
160 154
@@ -173,11 +167,7 @@ describe('Test video NSFW policy', function () {
173 }) 167 })
174 168
175 it('Should display NSFW videos with display user NSFW policy', async function () { 169 it('Should display NSFW videos with display user NSFW policy', async function () {
176 await updateMyUser({ 170 await server.usersCommand.updateMe({ nsfwPolicy: 'display' })
177 url: server.url,
178 accessToken: server.accessToken,
179 nsfwPolicy: 'display'
180 })
181 171
182 for (const body of await getVideosFunctions(server.accessToken)) { 172 for (const body of await getVideosFunctions(server.accessToken)) {
183 expect(body.total).to.equal(2) 173 expect(body.total).to.equal(2)
@@ -190,11 +180,7 @@ describe('Test video NSFW policy', function () {
190 }) 180 })
191 181
192 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () { 182 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () {
193 await updateMyUser({ 183 await server.usersCommand.updateMe({ nsfwPolicy: 'do_not_list' })
194 url: server.url,
195 accessToken: server.accessToken,
196 nsfwPolicy: 'do_not_list'
197 })
198 184
199 for (const body of await getVideosFunctions(server.accessToken)) { 185 for (const body of await getVideosFunctions(server.accessToken)) {
200 expect(body.total).to.equal(1) 186 expect(body.total).to.equal(1)
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 38133e2ce..e57d86c14 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -6,13 +6,9 @@ import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 checkPlaylistFilesWereRemoved, 7 checkPlaylistFilesWereRemoved,
8 cleanupTests, 8 cleanupTests,
9 createUser,
10 doubleFollow, 9 doubleFollow,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
12 generateUserAccessToken,
13 getMyUserInformation,
14 PlaylistsCommand, 11 PlaylistsCommand,
15 removeUser,
16 ServerInfo, 12 ServerInfo,
17 setAccessTokensToServers, 13 setAccessTokensToServers,
18 setDefaultVideoChannel, 14 setDefaultVideoChannel,
@@ -24,7 +20,6 @@ import {
24 waitJobs 20 waitJobs
25} from '@shared/extra-utils' 21} from '@shared/extra-utils'
26import { 22import {
27 User,
28 VideoPlaylist, 23 VideoPlaylist,
29 VideoPlaylistCreateResult, 24 VideoPlaylistCreateResult,
30 VideoPlaylistElementType, 25 VideoPlaylistElementType,
@@ -113,15 +108,7 @@ describe('Test video playlists', function () {
113 108
114 nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id 109 nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id
115 110
116 { 111 userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1')
117 await createUser({
118 url: servers[0].url,
119 accessToken: servers[0].accessToken,
120 username: 'user1',
121 password: 'password'
122 })
123 userTokenServer1 = await servers[0].loginCommand.getAccessToken('user1', 'password')
124 }
125 112
126 await waitJobs(servers) 113 await waitJobs(servers)
127 }) 114 })
@@ -165,7 +152,7 @@ describe('Test video playlists', function () {
165 }) 152 })
166 153
167 it('Should get private playlist for a classic user', async function () { 154 it('Should get private playlist for a classic user', async function () {
168 const token = await generateUserAccessToken(servers[0], 'toto') 155 const token = await servers[0].usersCommand.generateUserAndToken('toto')
169 156
170 const body = await commands[0].listByAccount({ token, handle: 'toto' }) 157 const body = await commands[0].listByAccount({ token, handle: 'toto' })
171 158
@@ -1118,19 +1105,10 @@ describe('Test video playlists', function () {
1118 it('Should delete an account and delete its playlists', async function () { 1105 it('Should delete an account and delete its playlists', async function () {
1119 this.timeout(30000) 1106 this.timeout(30000)
1120 1107
1121 const user = { username: 'user_1', password: 'password' } 1108 const { userId, token } = await servers[0].usersCommand.generate('user_1')
1122 const res = await createUser({
1123 url: servers[0].url,
1124 accessToken: servers[0].accessToken,
1125 username: user.username,
1126 password: user.password
1127 })
1128
1129 const userId = res.body.user.id
1130 const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
1131 1109
1132 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken) 1110 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token })
1133 const userChannel = (resChannel.body as User).videoChannels[0] 1111 const userChannel = videoChannels[0]
1134 1112
1135 await commands[0].create({ 1113 await commands[0].create({
1136 attributes: { 1114 attributes: {
@@ -1152,7 +1130,7 @@ describe('Test video playlists', function () {
1152 } 1130 }
1153 } 1131 }
1154 1132
1155 await removeUser(servers[0].url, userId, servers[0].accessToken) 1133 await servers[0].usersCommand.remove({ userId })
1156 await waitJobs(servers) 1134 await waitJobs(servers)
1157 1135
1158 { 1136 {
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index f831dd8a9..4e349e350 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createUser,
9 doubleFollow, 8 doubleFollow,
10 flushAndRunServer, 9 flushAndRunServer,
11 getMyVideos, 10 getMyVideos,
@@ -125,7 +124,7 @@ describe('Test video privacy', function () {
125 username: 'hello', 124 username: 'hello',
126 password: 'super password' 125 password: 'super password'
127 } 126 }
128 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) 127 await servers[0].usersCommand.create({ username: user.username, password: user.password })
129 128
130 anotherUserToken = await servers[0].loginCommand.getAccessToken(user) 129 anotherUserToken = await servers[0].loginCommand.getAccessToken(user)
131 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) 130 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403)
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index 519dad646..4aa00cfc4 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createUser,
9 doubleFollow, 8 doubleFollow,
10 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
11 makeGetRequest, 10 makeGetRequest,
@@ -60,17 +59,7 @@ describe('Test videos filter', function () {
60 59
61 for (const server of servers) { 60 for (const server of servers) {
62 const moderator = { username: 'moderator', password: 'my super password' } 61 const moderator = { username: 'moderator', password: 'my super password' }
63 await createUser( 62 await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
64 {
65 url: server.url,
66 accessToken: server.accessToken,
67 username: moderator.username,
68 password: moderator.password,
69 videoQuota: undefined,
70 videoQuotaDaily: undefined,
71 role: UserRole.MODERATOR
72 }
73 )
74 server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator) 63 server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator)
75 64
76 await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber }) 65 await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber })
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 256271bd0..aa0623f7d 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createUser,
9 flushAndRunServer, 8 flushAndRunServer,
10 getVideosListWithToken, 9 getVideosListWithToken,
11 getVideoWithToken, 10 getVideoWithToken,
@@ -14,7 +13,6 @@ import {
14 reRunServer, 13 reRunServer,
15 ServerInfo, 14 ServerInfo,
16 setAccessTokensToServers, 15 setAccessTokensToServers,
17 updateMyUser,
18 uploadVideo, 16 uploadVideo,
19 wait 17 wait
20} from '@shared/extra-utils' 18} from '@shared/extra-utils'
@@ -59,7 +57,7 @@ describe('Test videos history', function () {
59 username: 'user_1', 57 username: 'user_1',
60 password: 'super password' 58 password: 'super password'
61 } 59 }
62 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) 60 await server.usersCommand.create({ username: user.username, password: user.password })
63 userAccessToken = await server.loginCommand.getAccessToken(user) 61 userAccessToken = await server.loginCommand.getAccessToken(user)
64 }) 62 })
65 63
@@ -174,9 +172,7 @@ describe('Test videos history', function () {
174 }) 172 })
175 173
176 it('Should disable videos history', async function () { 174 it('Should disable videos history', async function () {
177 await updateMyUser({ 175 await server.usersCommand.updateMe({
178 url: server.url,
179 accessToken: server.accessToken,
180 videosHistoryEnabled: false 176 videosHistoryEnabled: false
181 }) 177 })
182 178
@@ -184,9 +180,7 @@ describe('Test videos history', function () {
184 }) 180 })
185 181
186 it('Should re-enable videos history', async function () { 182 it('Should re-enable videos history', async function () {
187 await updateMyUser({ 183 await server.usersCommand.updateMe({
188 url: server.url,
189 accessToken: server.accessToken,
190 videosHistoryEnabled: true 184 videosHistoryEnabled: true
191 }) 185 })
192 186
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index ccbc6f4a4..a2da2eaef 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -2,15 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '@shared/extra-utils'
6 cleanupTests,
7 flushAndRunServer,
8 generateUserAccessToken,
9 ServerInfo,
10 setAccessTokensToServers,
11 uploadVideo,
12 wait
13} from '@shared/extra-utils'
14import { VideosOverview } from '@shared/models' 6import { VideosOverview } from '@shared/models'
15 7
16const expect = chai.expect 8const expect = chai.expect
@@ -112,7 +104,7 @@ describe('Test a videos overview', function () {
112 }) 104 })
113 105
114 it('Should hide muted accounts', async function () { 106 it('Should hide muted accounts', async function () {
115 const token = await generateUserAccessToken(server, 'choco') 107 const token = await server.usersCommand.generateUserAndToken('choco')
116 108
117 await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host }) 109 await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host })
118 110