aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-change-ownership.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-change-ownership.ts')
-rw-r--r--server/tests/api/videos/video-change-ownership.ts89
1 files changed, 21 insertions, 68 deletions
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,