aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/videos/index.ts1
-rw-r--r--server/tests/api/videos/video-change-ownership.ts85
2 files changed, 52 insertions, 34 deletions
diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts
index 8286ff356..a328a49c1 100644
--- a/server/tests/api/videos/index.ts
+++ b/server/tests/api/videos/index.ts
@@ -5,6 +5,7 @@ import './video-abuse'
5import './video-blacklist' 5import './video-blacklist'
6import './video-blacklist-management' 6import './video-blacklist-management'
7import './video-captions' 7import './video-captions'
8import './vidoe-change-ownership'
8import './video-channels' 9import './video-channels'
9import './video-comments' 10import './video-comments'
10import './video-description' 11import './video-description'
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 275be40be..1578a471d 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -5,7 +5,7 @@ import 'mocha'
5import { 5import {
6 acceptChangeOwnership, 6 acceptChangeOwnership,
7 changeVideoOwnership, 7 changeVideoOwnership,
8 createUser, 8 createUser, doubleFollow, flushAndRunMultipleServers,
9 flushTests, 9 flushTests,
10 getMyUserInformation, 10 getMyUserInformation,
11 getVideoChangeOwnershipList, 11 getVideoChangeOwnershipList,
@@ -16,15 +16,17 @@ import {
16 ServerInfo, 16 ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 uploadVideo, 18 uploadVideo,
19 userLogin 19 userLogin,
20 getVideo
20} from '../../utils' 21} from '../../utils'
21import { waitJobs } from '../../utils/server/jobs' 22import { waitJobs } from '../../utils/server/jobs'
22import { User } from '../../../../shared/models/users' 23import { User } from '../../../../shared/models/users'
24import { VideoDetails } from '../../../../shared/models/videos'
23 25
24const expect = chai.expect 26const expect = chai.expect
25 27
26describe('Test video change ownership - nominal', function () { 28describe('Test video change ownership - nominal', function () {
27 let server: ServerInfo = undefined 29 let servers: ServerInfo[] = []
28 const firstUser = { 30 const firstUser = {
29 username: 'first', 31 username: 'first',
30 password: 'My great password' 32 password: 'My great password'
@@ -40,43 +42,44 @@ describe('Test video change ownership - nominal', function () {
40 before(async function () { 42 before(async function () {
41 this.timeout(50000) 43 this.timeout(50000)
42 44
43 // Run one server 45 servers = await flushAndRunMultipleServers(2)
44 await flushTests() 46 await setAccessTokensToServers(servers)
45 server = await runServer(1)
46 await setAccessTokensToServers([server])
47 47
48 const videoQuota = 42000000 48 const videoQuota = 42000000
49 await createUser(server.url, server.accessToken, firstUser.username, firstUser.password, videoQuota) 49 await createUser(servers[0].url, servers[0].accessToken, firstUser.username, firstUser.password, videoQuota)
50 await createUser(server.url, server.accessToken, secondUser.username, secondUser.password, videoQuota) 50 await createUser(servers[0].url, servers[0].accessToken, secondUser.username, secondUser.password, videoQuota)
51 51
52 firstUserAccessToken = await userLogin(server, firstUser) 52 firstUserAccessToken = await userLogin(servers[0], firstUser)
53 secondUserAccessToken = await userLogin(server, secondUser) 53 secondUserAccessToken = await userLogin(servers[0], secondUser)
54 54
55 // Upload some videos on the server 55 const videoAttributes = {
56 const video1Attributes = {
57 name: 'my super name', 56 name: 'my super name',
58 description: 'my super description' 57 description: 'my super description'
59 } 58 }
60 await uploadVideo(server.url, firstUserAccessToken, video1Attributes) 59 await uploadVideo(servers[0].url, firstUserAccessToken, videoAttributes)
61 60
62 await waitJobs(server) 61 await waitJobs(servers)
63 62
64 const res = await getVideosList(server.url) 63 const res = await getVideosList(servers[0].url)
65 const videos = res.body.data 64 const videos = res.body.data
66 65
67 expect(videos.length).to.equal(1) 66 expect(videos.length).to.equal(1)
68 67
69 server.video = videos.find(video => video.name === 'my super name') 68 const video = videos.find(video => video.name === 'my super name')
69 expect(video.channel.name).to.equal('first_channel')
70 servers[0].video = video
71
72 await doubleFollow(servers[0], servers[1])
70 }) 73 })
71 74
72 it('Should not have video change ownership', async function () { 75 it('Should not have video change ownership', async function () {
73 const resFirstUser = await getVideoChangeOwnershipList(server.url, firstUserAccessToken) 76 const resFirstUser = await getVideoChangeOwnershipList(servers[0].url, firstUserAccessToken)
74 77
75 expect(resFirstUser.body.total).to.equal(0) 78 expect(resFirstUser.body.total).to.equal(0)
76 expect(resFirstUser.body.data).to.be.an('array') 79 expect(resFirstUser.body.data).to.be.an('array')
77 expect(resFirstUser.body.data.length).to.equal(0) 80 expect(resFirstUser.body.data.length).to.equal(0)
78 81
79 const resSecondUser = await getVideoChangeOwnershipList(server.url, secondUserAccessToken) 82 const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
80 83
81 expect(resSecondUser.body.total).to.equal(0) 84 expect(resSecondUser.body.total).to.equal(0)
82 expect(resSecondUser.body.data).to.be.an('array') 85 expect(resSecondUser.body.data).to.be.an('array')
@@ -86,17 +89,17 @@ describe('Test video change ownership - nominal', function () {
86 it('Should send a request to change ownership of a video', async function () { 89 it('Should send a request to change ownership of a video', async function () {
87 this.timeout(15000) 90 this.timeout(15000)
88 91
89 await changeVideoOwnership(server.url, firstUserAccessToken, server.video.id, secondUser.username) 92 await changeVideoOwnership(servers[0].url, firstUserAccessToken, servers[0].video.id, secondUser.username)
90 }) 93 })
91 94
92 it('Should only return a request to change ownership for the second user', async function () { 95 it('Should only return a request to change ownership for the second user', async function () {
93 const resFirstUser = await getVideoChangeOwnershipList(server.url, firstUserAccessToken) 96 const resFirstUser = await getVideoChangeOwnershipList(servers[0].url, firstUserAccessToken)
94 97
95 expect(resFirstUser.body.total).to.equal(0) 98 expect(resFirstUser.body.total).to.equal(0)
96 expect(resFirstUser.body.data).to.be.an('array') 99 expect(resFirstUser.body.data).to.be.an('array')
97 expect(resFirstUser.body.data.length).to.equal(0) 100 expect(resFirstUser.body.data.length).to.equal(0)
98 101
99 const resSecondUser = await getVideoChangeOwnershipList(server.url, secondUserAccessToken) 102 const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
100 103
101 expect(resSecondUser.body.total).to.equal(1) 104 expect(resSecondUser.body.total).to.equal(1)
102 expect(resSecondUser.body.data).to.be.an('array') 105 expect(resSecondUser.body.data).to.be.an('array')
@@ -108,13 +111,13 @@ describe('Test video change ownership - nominal', function () {
108 it('Should accept the same change ownership request without crashing', async function () { 111 it('Should accept the same change ownership request without crashing', async function () {
109 this.timeout(10000) 112 this.timeout(10000)
110 113
111 await changeVideoOwnership(server.url, firstUserAccessToken, server.video.id, secondUser.username) 114 await changeVideoOwnership(servers[0].url, firstUserAccessToken, servers[0].video.id, secondUser.username)
112 }) 115 })
113 116
114 it('Should not create multiple change ownership requests while one is waiting', async function () { 117 it('Should not create multiple change ownership requests while one is waiting', async function () {
115 this.timeout(10000) 118 this.timeout(10000)
116 119
117 const resSecondUser = await getVideoChangeOwnershipList(server.url, secondUserAccessToken) 120 const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
118 121
119 expect(resSecondUser.body.total).to.equal(1) 122 expect(resSecondUser.body.total).to.equal(1)
120 expect(resSecondUser.body.data).to.be.an('array') 123 expect(resSecondUser.body.data).to.be.an('array')
@@ -124,29 +127,29 @@ describe('Test video change ownership - nominal', function () {
124 it('Should not be possible to refuse the change of ownership from first user', async function () { 127 it('Should not be possible to refuse the change of ownership from first user', async function () {
125 this.timeout(10000) 128 this.timeout(10000)
126 129
127 await refuseChangeOwnership(server.url, firstUserAccessToken, lastRequestChangeOwnershipId, 403) 130 await refuseChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, 403)
128 }) 131 })
129 132
130 it('Should be possible to refuse the change of ownership from second user', async function () { 133 it('Should be possible to refuse the change of ownership from second user', async function () {
131 this.timeout(10000) 134 this.timeout(10000)
132 135
133 await refuseChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId) 136 await refuseChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId)
134 }) 137 })
135 138
136 it('Should send a new request to change ownership of a video', async function () { 139 it('Should send a new request to change ownership of a video', async function () {
137 this.timeout(15000) 140 this.timeout(15000)
138 141
139 await changeVideoOwnership(server.url, firstUserAccessToken, server.video.id, secondUser.username) 142 await changeVideoOwnership(servers[0].url, firstUserAccessToken, servers[0].video.id, secondUser.username)
140 }) 143 })
141 144
142 it('Should return two requests to change ownership for the second user', async function () { 145 it('Should return two requests to change ownership for the second user', async function () {
143 const resFirstUser = await getVideoChangeOwnershipList(server.url, firstUserAccessToken) 146 const resFirstUser = await getVideoChangeOwnershipList(servers[0].url, firstUserAccessToken)
144 147
145 expect(resFirstUser.body.total).to.equal(0) 148 expect(resFirstUser.body.total).to.equal(0)
146 expect(resFirstUser.body.data).to.be.an('array') 149 expect(resFirstUser.body.data).to.be.an('array')
147 expect(resFirstUser.body.data.length).to.equal(0) 150 expect(resFirstUser.body.data.length).to.equal(0)
148 151
149 const resSecondUser = await getVideoChangeOwnershipList(server.url, secondUserAccessToken) 152 const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
150 153
151 expect(resSecondUser.body.total).to.equal(2) 154 expect(resSecondUser.body.total).to.equal(2)
152 expect(resSecondUser.body.data).to.be.an('array') 155 expect(resSecondUser.body.data).to.be.an('array')
@@ -158,23 +161,37 @@ describe('Test video change ownership - nominal', function () {
158 it('Should not be possible to accept the change of ownership from first user', async function () { 161 it('Should not be possible to accept the change of ownership from first user', async function () {
159 this.timeout(10000) 162 this.timeout(10000)
160 163
161 const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserAccessToken) 164 const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken)
162 const secondUserInformation: User = secondUserInformationResponse.body 165 const secondUserInformation: User = secondUserInformationResponse.body
163 const channelId = secondUserInformation.videoChannels[0].id 166 const channelId = secondUserInformation.videoChannels[0].id
164 await acceptChangeOwnership(server.url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, 403) 167 await acceptChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, 403)
165 }) 168 })
166 169
167 it('Should be possible to accept the change of ownership from second user', async function () { 170 it('Should be possible to accept the change of ownership from second user', async function () {
168 this.timeout(10000) 171 this.timeout(10000)
169 172
170 const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserAccessToken) 173 const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken)
171 const secondUserInformation: User = secondUserInformationResponse.body 174 const secondUserInformation: User = secondUserInformationResponse.body
172 const channelId = secondUserInformation.videoChannels[0].id 175 const channelId = secondUserInformation.videoChannels[0].id
173 await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId) 176 await acceptChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId)
177
178 await waitJobs(servers)
179 })
180
181 it('Should have video channel updated', async function () {
182 for (const server of servers) {
183 const res = await getVideo(server.url, servers[0].video.uuid)
184
185 const video: VideoDetails = res.body
186
187 expect(video.name).to.equal('my super name')
188 expect(video.channel.displayName).to.equal('Main second channel')
189 expect(video.channel.name).to.equal('second_channel')
190 }
174 }) 191 })
175 192
176 after(async function () { 193 after(async function () {
177 killallServers([server]) 194 killallServers(servers)
178 }) 195 })
179}) 196})
180 197