diff options
Diffstat (limited to 'server/tests/api/videos/video-change-ownership.ts')
-rw-r--r-- | server/tests/api/videos/video-change-ownership.ts | 108 |
1 files changed, 86 insertions, 22 deletions
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index fad4c8b1f..a3384851b 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -1,11 +1,13 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 6 | import { |
6 | acceptChangeOwnership, | 7 | acceptChangeOwnership, |
7 | changeVideoOwnership, | 8 | changeVideoOwnership, |
8 | cleanupTests, | 9 | cleanupTests, |
10 | createLive, | ||
9 | createUser, | 11 | createUser, |
10 | doubleFollow, | 12 | doubleFollow, |
11 | flushAndRunMultipleServers, | 13 | flushAndRunMultipleServers, |
@@ -17,13 +19,14 @@ import { | |||
17 | refuseChangeOwnership, | 19 | refuseChangeOwnership, |
18 | ServerInfo, | 20 | ServerInfo, |
19 | setAccessTokensToServers, | 21 | setAccessTokensToServers, |
22 | setDefaultVideoChannel, | ||
23 | updateCustomSubConfig, | ||
20 | uploadVideo, | 24 | uploadVideo, |
21 | userLogin | 25 | userLogin |
22 | } from '../../../../shared/extra-utils' | 26 | } from '../../../../shared/extra-utils' |
23 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 27 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
24 | import { User } from '../../../../shared/models/users' | 28 | import { User } from '../../../../shared/models/users' |
25 | import { VideoDetails } from '../../../../shared/models/videos' | 29 | import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' |
26 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
27 | 30 | ||
28 | const expect = chai.expect | 31 | const expect = chai.expect |
29 | 32 | ||
@@ -37,15 +40,32 @@ describe('Test video change ownership - nominal', function () { | |||
37 | username: 'second', | 40 | username: 'second', |
38 | password: 'My other password' | 41 | password: 'My other password' |
39 | } | 42 | } |
43 | |||
40 | let firstUserAccessToken = '' | 44 | let firstUserAccessToken = '' |
45 | let firstUserChannelId: number | ||
46 | |||
41 | let secondUserAccessToken = '' | 47 | let secondUserAccessToken = '' |
48 | let secondUserChannelId: number | ||
49 | |||
42 | let lastRequestChangeOwnershipId = '' | 50 | let lastRequestChangeOwnershipId = '' |
43 | 51 | ||
52 | let liveId: number | ||
53 | |||
44 | before(async function () { | 54 | before(async function () { |
45 | this.timeout(50000) | 55 | this.timeout(50000) |
46 | 56 | ||
47 | servers = await flushAndRunMultipleServers(2) | 57 | servers = await flushAndRunMultipleServers(2) |
48 | await setAccessTokensToServers(servers) | 58 | await setAccessTokensToServers(servers) |
59 | await setDefaultVideoChannel(servers) | ||
60 | |||
61 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | ||
62 | transcoding: { | ||
63 | enabled: false | ||
64 | }, | ||
65 | live: { | ||
66 | enabled: true | ||
67 | } | ||
68 | }) | ||
49 | 69 | ||
50 | const videoQuota = 42000000 | 70 | const videoQuota = 42000000 |
51 | await createUser({ | 71 | await createUser({ |
@@ -66,22 +86,35 @@ describe('Test video change ownership - nominal', function () { | |||
66 | firstUserAccessToken = await userLogin(servers[0], firstUser) | 86 | firstUserAccessToken = await userLogin(servers[0], firstUser) |
67 | secondUserAccessToken = await userLogin(servers[0], secondUser) | 87 | secondUserAccessToken = await userLogin(servers[0], secondUser) |
68 | 88 | ||
69 | const videoAttributes = { | 89 | { |
70 | name: 'my super name', | 90 | const res = await getMyUserInformation(servers[0].url, firstUserAccessToken) |
71 | description: 'my super description' | 91 | const firstUserInformation: User = res.body |
92 | firstUserChannelId = firstUserInformation.videoChannels[0].id | ||
72 | } | 93 | } |
73 | await uploadVideo(servers[0].url, firstUserAccessToken, videoAttributes) | ||
74 | 94 | ||
75 | await waitJobs(servers) | 95 | { |
96 | const res = await getMyUserInformation(servers[0].url, secondUserAccessToken) | ||
97 | const secondUserInformation: User = res.body | ||
98 | secondUserChannelId = secondUserInformation.videoChannels[0].id | ||
99 | } | ||
76 | 100 | ||
77 | const res = await getVideosList(servers[0].url) | 101 | { |
78 | const videos = res.body.data | 102 | const videoAttributes = { |
103 | name: 'my super name', | ||
104 | description: 'my super description' | ||
105 | } | ||
106 | const res = await uploadVideo(servers[0].url, firstUserAccessToken, videoAttributes) | ||
79 | 107 | ||
80 | expect(videos.length).to.equal(1) | 108 | const resVideo = await getVideo(servers[0].url, res.body.video.id) |
109 | servers[0].video = resVideo.body | ||
110 | } | ||
81 | 111 | ||
82 | const video = videos.find(video => video.name === 'my super name') | 112 | { |
83 | expect(video.channel.name).to.equal('first_channel') | 113 | const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC } |
84 | servers[0].video = video | 114 | const res = await createLive(servers[0].url, firstUserAccessToken, attributes) |
115 | |||
116 | liveId = res.body.video.id | ||
117 | } | ||
85 | 118 | ||
86 | await doubleFollow(servers[0], servers[1]) | 119 | await doubleFollow(servers[0], servers[1]) |
87 | }) | 120 | }) |
@@ -175,19 +208,19 @@ describe('Test video change ownership - nominal', function () { | |||
175 | it('Should not be possible to accept the change of ownership from first user', async function () { | 208 | it('Should not be possible to accept the change of ownership from first user', async function () { |
176 | this.timeout(10000) | 209 | this.timeout(10000) |
177 | 210 | ||
178 | const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken) | 211 | await acceptChangeOwnership( |
179 | const secondUserInformation: User = secondUserInformationResponse.body | 212 | servers[0].url, |
180 | const channelId = secondUserInformation.videoChannels[0].id | 213 | firstUserAccessToken, |
181 | await acceptChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, HttpStatusCode.FORBIDDEN_403) | 214 | lastRequestChangeOwnershipId, |
215 | secondUserChannelId, | ||
216 | HttpStatusCode.FORBIDDEN_403 | ||
217 | ) | ||
182 | }) | 218 | }) |
183 | 219 | ||
184 | it('Should be possible to accept the change of ownership from second user', async function () { | 220 | it('Should be possible to accept the change of ownership from second user', async function () { |
185 | this.timeout(10000) | 221 | this.timeout(10000) |
186 | 222 | ||
187 | const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken) | 223 | await acceptChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId, secondUserChannelId) |
188 | const secondUserInformation: User = secondUserInformationResponse.body | ||
189 | const channelId = secondUserInformation.videoChannels[0].id | ||
190 | await acceptChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId) | ||
191 | 224 | ||
192 | await waitJobs(servers) | 225 | await waitJobs(servers) |
193 | }) | 226 | }) |
@@ -204,6 +237,37 @@ describe('Test video change ownership - nominal', function () { | |||
204 | } | 237 | } |
205 | }) | 238 | }) |
206 | 239 | ||
240 | it('Should send a request to change ownership of a live', async function () { | ||
241 | this.timeout(15000) | ||
242 | |||
243 | await changeVideoOwnership(servers[0].url, firstUserAccessToken, liveId, secondUser.username) | ||
244 | |||
245 | const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken) | ||
246 | |||
247 | expect(resSecondUser.body.total).to.equal(3) | ||
248 | expect(resSecondUser.body.data.length).to.equal(3) | ||
249 | |||
250 | lastRequestChangeOwnershipId = resSecondUser.body.data[0].id | ||
251 | }) | ||
252 | |||
253 | it('Should accept a live ownership change', async function () { | ||
254 | this.timeout(20000) | ||
255 | |||
256 | await acceptChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId, secondUserChannelId) | ||
257 | |||
258 | await waitJobs(servers) | ||
259 | |||
260 | for (const server of servers) { | ||
261 | const res = await getVideo(server.url, servers[0].video.uuid) | ||
262 | |||
263 | const video: VideoDetails = res.body | ||
264 | |||
265 | expect(video.name).to.equal('my super name') | ||
266 | expect(video.channel.displayName).to.equal('Main second channel') | ||
267 | expect(video.channel.name).to.equal('second_channel') | ||
268 | } | ||
269 | }) | ||
270 | |||
207 | after(async function () { | 271 | after(async function () { |
208 | await cleanupTests(servers) | 272 | await cleanupTests(servers) |
209 | }) | 273 | }) |