aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-17 15:45:42 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (patch)
tree33c93ef19451d7e46d4be74ce0681359d2dcc70e /server/tests
parent965c4b22d0e4d2f853501e844e6ebbb861bd389d (diff)
downloadPeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.gz
PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.zst
PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.zip
Add ability to set a name to a channel
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts19
-rw-r--r--server/tests/api/check-params/video-channels.ts47
-rw-r--r--server/tests/api/server/follows.ts2
-rw-r--r--server/tests/api/server/handle-down.ts2
-rw-r--r--server/tests/api/users/user-subscriptions.ts37
-rw-r--r--server/tests/api/users/users-multiple-servers.ts9
-rw-r--r--server/tests/api/videos/multiple-servers.ts12
-rw-r--r--server/tests/api/videos/single-server.ts4
-rw-r--r--server/tests/api/videos/video-channels.ts61
-rw-r--r--server/tests/cli/update-host.ts1
-rw-r--r--server/tests/real-world/populate-database.ts1
-rw-r--r--server/tests/utils/videos/video-channels.ts4
-rw-r--r--server/tests/utils/videos/videos.ts4
13 files changed, 105 insertions, 98 deletions
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 9f7d15b27..628a74476 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -5,7 +5,6 @@ import 'mocha'
5import { 5import {
6 createUser, 6 createUser,
7 flushTests, 7 flushTests,
8 getMyUserInformation,
9 killallServers, 8 killallServers,
10 makeDeleteRequest, 9 makeDeleteRequest,
11 makeGetRequest, 10 makeGetRequest,
@@ -21,7 +20,6 @@ describe('Test user subscriptions API validators', function () {
21 const path = '/api/v1/users/me/subscriptions' 20 const path = '/api/v1/users/me/subscriptions'
22 let server: ServerInfo 21 let server: ServerInfo
23 let userAccessToken = '' 22 let userAccessToken = ''
24 let userChannelUUID: string
25 23
26 // --------------------------------------------------------------- 24 // ---------------------------------------------------------------
27 25
@@ -40,11 +38,6 @@ describe('Test user subscriptions API validators', function () {
40 } 38 }
41 await createUser(server.url, server.accessToken, user.username, user.password) 39 await createUser(server.url, server.accessToken, user.username, user.password)
42 userAccessToken = await userLogin(server, user) 40 userAccessToken = await userLogin(server, user)
43
44 {
45 const res = await getMyUserInformation(server.url, server.accessToken)
46 userChannelUUID = res.body.videoChannels[ 0 ].uuid
47 }
48 }) 41 })
49 42
50 describe('When listing my subscriptions', function () { 43 describe('When listing my subscriptions', function () {
@@ -69,7 +62,7 @@ describe('Test user subscriptions API validators', function () {
69 }) 62 })
70 63
71 it('Should success with the correct parameters', async function () { 64 it('Should success with the correct parameters', async function () {
72 await await makeGetRequest({ 65 await makeGetRequest({
73 url: server.url, 66 url: server.url,
74 path, 67 path,
75 token: userAccessToken, 68 token: userAccessToken,
@@ -102,7 +95,7 @@ describe('Test user subscriptions API validators', function () {
102 }) 95 })
103 96
104 it('Should success with the correct parameters', async function () { 97 it('Should success with the correct parameters', async function () {
105 await await makeGetRequest({ 98 await makeGetRequest({
106 url: server.url, 99 url: server.url,
107 path, 100 path,
108 token: userAccessToken, 101 token: userAccessToken,
@@ -116,7 +109,7 @@ describe('Test user subscriptions API validators', function () {
116 await makePostBodyRequest({ 109 await makePostBodyRequest({
117 url: server.url, 110 url: server.url,
118 path, 111 path,
119 fields: { uri: userChannelUUID + '@localhost:9001' }, 112 fields: { uri: 'user1_channel@localhost:9001' },
120 statusCodeExpected: 401 113 statusCodeExpected: 401
121 }) 114 })
122 }) 115 })
@@ -152,7 +145,7 @@ describe('Test user subscriptions API validators', function () {
152 url: server.url, 145 url: server.url,
153 path, 146 path,
154 token: server.accessToken, 147 token: server.accessToken,
155 fields: { uri: userChannelUUID + '@localhost:9001' }, 148 fields: { uri: 'user1_channel@localhost:9001' },
156 statusCodeExpected: 204 149 statusCodeExpected: 204
157 }) 150 })
158 }) 151 })
@@ -162,7 +155,7 @@ describe('Test user subscriptions API validators', function () {
162 it('Should fail with a non authenticated user', async function () { 155 it('Should fail with a non authenticated user', async function () {
163 await makeDeleteRequest({ 156 await makeDeleteRequest({
164 url: server.url, 157 url: server.url,
165 path: path + '/' + userChannelUUID + '@localhost:9001', 158 path: path + '/user1_channel@localhost:9001',
166 statusCodeExpected: 401 159 statusCodeExpected: 401
167 }) 160 })
168 }) 161 })
@@ -202,7 +195,7 @@ describe('Test user subscriptions API validators', function () {
202 it('Should success with the correct parameters', async function () { 195 it('Should success with the correct parameters', async function () {
203 await makeDeleteRequest({ 196 await makeDeleteRequest({
204 url: server.url, 197 url: server.url,
205 path: path + '/' + userChannelUUID + '@localhost:9001', 198 path: path + '/user1_channel@localhost:9001',
206 token: server.accessToken, 199 token: server.accessToken,
207 statusCodeExpected: 204 200 statusCodeExpected: 204
208 }) 201 })
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 0980de73b..bcf4b7473 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -31,7 +31,6 @@ describe('Test video channels API validator', function () {
31 const videoChannelPath = '/api/v1/video-channels' 31 const videoChannelPath = '/api/v1/video-channels'
32 let server: ServerInfo 32 let server: ServerInfo
33 let accessTokenUser: string 33 let accessTokenUser: string
34 let videoChannelUUID: string
35 34
36 // --------------------------------------------------------------- 35 // ---------------------------------------------------------------
37 36
@@ -53,12 +52,6 @@ describe('Test video channels API validator', function () {
53 await createUser(server.url, server.accessToken, user.username, user.password) 52 await createUser(server.url, server.accessToken, user.username, user.password)
54 accessTokenUser = await userLogin(server, user) 53 accessTokenUser = await userLogin(server, user)
55 } 54 }
56
57 {
58 const res = await getMyUserInformation(server.url, server.accessToken)
59 const user: User = res.body
60 videoChannelUUID = user.videoChannels[0].uuid
61 }
62 }) 55 })
63 56
64 describe('When listing a video channels', function () { 57 describe('When listing a video channels', function () {
@@ -83,6 +76,7 @@ describe('Test video channels API validator', function () {
83 76
84 describe('When adding a video channel', function () { 77 describe('When adding a video channel', function () {
85 const baseCorrectParams = { 78 const baseCorrectParams = {
79 name: 'super_channel',
86 displayName: 'hello', 80 displayName: 'hello',
87 description: 'super description', 81 description: 'super description',
88 support: 'super support text' 82 support: 'super support text'
@@ -104,6 +98,16 @@ describe('Test video channels API validator', function () {
104 }) 98 })
105 99
106 it('Should fail without a name', async function () { 100 it('Should fail without a name', async function () {
101 const fields = omit(baseCorrectParams, 'name')
102 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
103 })
104
105 it('Should fail with a bad name', async function () {
106 const fields = immutableAssign(baseCorrectParams, { name: 'super name' })
107 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
108 })
109
110 it('Should fail without a name', async function () {
107 const fields = omit(baseCorrectParams, 'displayName') 111 const fields = omit(baseCorrectParams, 'displayName')
108 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 112 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
109 }) 113 })
@@ -142,7 +146,7 @@ describe('Test video channels API validator', function () {
142 let path: string 146 let path: string
143 147
144 before(async function () { 148 before(async function () {
145 path = videoChannelPath + '/' + videoChannelUUID 149 path = videoChannelPath + '/super_channel'
146 }) 150 })
147 151
148 it('Should fail with a non authenticated user', async function () { 152 it('Should fail with a non authenticated user', async function () {
@@ -195,7 +199,7 @@ describe('Test video channels API validator', function () {
195 let path: string 199 let path: string
196 200
197 before(async function () { 201 before(async function () {
198 path = videoChannelPath + '/' + videoChannelUUID 202 path = videoChannelPath + '/super_channel'
199 }) 203 })
200 204
201 it('Should fail with an incorrect input file', async function () { 205 it('Should fail with an incorrect input file', async function () {
@@ -255,18 +259,10 @@ describe('Test video channels API validator', function () {
255 expect(res.body.data).to.be.an('array') 259 expect(res.body.data).to.be.an('array')
256 }) 260 })
257 261
258 it('Should fail without a correct uuid', async function () {
259 await makeGetRequest({
260 url: server.url,
261 path: videoChannelPath + '/coucou',
262 statusCodeExpected: 400
263 })
264 })
265
266 it('Should return 404 with an incorrect video channel', async function () { 262 it('Should return 404 with an incorrect video channel', async function () {
267 await makeGetRequest({ 263 await makeGetRequest({
268 url: server.url, 264 url: server.url,
269 path: videoChannelPath + '/4da6fde3-88f7-4d16-b119-108df5630b06', 265 path: videoChannelPath + '/super_channel2',
270 statusCodeExpected: 404 266 statusCodeExpected: 404
271 }) 267 })
272 }) 268 })
@@ -274,7 +270,7 @@ describe('Test video channels API validator', function () {
274 it('Should succeed with the correct parameters', async function () { 270 it('Should succeed with the correct parameters', async function () {
275 await makeGetRequest({ 271 await makeGetRequest({
276 url: server.url, 272 url: server.url,
277 path: videoChannelPath + '/' + videoChannelUUID, 273 path: videoChannelPath + '/super_channel',
278 statusCodeExpected: 200 274 statusCodeExpected: 200
279 }) 275 })
280 }) 276 })
@@ -282,26 +278,23 @@ describe('Test video channels API validator', function () {
282 278
283 describe('When deleting a video channel', function () { 279 describe('When deleting a video channel', function () {
284 it('Should fail with a non authenticated user', async function () { 280 it('Should fail with a non authenticated user', async function () {
285 await deleteVideoChannel(server.url, 'coucou', videoChannelUUID, 401) 281 await deleteVideoChannel(server.url, 'coucou', 'super_channel', 401)
286 }) 282 })
287 283
288 it('Should fail with another authenticated user', async function () { 284 it('Should fail with another authenticated user', async function () {
289 await deleteVideoChannel(server.url, accessTokenUser, videoChannelUUID, 403) 285 await deleteVideoChannel(server.url, accessTokenUser, 'super_channel', 403)
290 }) 286 })
291 287
292 it('Should fail with an unknown video channel id', async function () { 288 it('Should fail with an unknown video channel id', async function () {
293 await deleteVideoChannel(server.url, server.accessToken,454554, 404) 289 await deleteVideoChannel(server.url, server.accessToken,'super_channel2', 404)
294 }) 290 })
295 291
296 it('Should succeed with the correct parameters', async function () { 292 it('Should succeed with the correct parameters', async function () {
297 await deleteVideoChannel(server.url, server.accessToken, videoChannelUUID) 293 await deleteVideoChannel(server.url, server.accessToken, 'super_channel')
298 }) 294 })
299 295
300 it('Should fail to delete the last user video channel', async function () { 296 it('Should fail to delete the last user video channel', async function () {
301 const res = await getVideoChannelsList(server.url, 0, 1) 297 await deleteVideoChannel(server.url, server.accessToken, 'root_channel', 409)
302 const lastVideoChannelUUID = res.body.data[0].uuid
303
304 await deleteVideoChannel(server.url, server.accessToken, lastVideoChannelUUID, 409)
305 }) 298 })
306 }) 299 })
307 300
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 1cad8998c..243fcd4e7 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -311,7 +311,7 @@ describe('Test follows', function () {
311 likes: 1, 311 likes: 1,
312 dislikes: 1, 312 dislikes: 1,
313 channel: { 313 channel: {
314 name: 'Default root channel', 314 name: 'Main root channel',
315 description: '', 315 description: '',
316 isLocal 316 isLocal
317 }, 317 },
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 18a0d9ce3..df35b36eb 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -71,7 +71,7 @@ describe('Test handle downs', function () {
71 privacy: VideoPrivacy.PUBLIC, 71 privacy: VideoPrivacy.PUBLIC,
72 commentsEnabled: true, 72 commentsEnabled: true,
73 channel: { 73 channel: {
74 name: 'Default root channel', 74 name: 'Main root channel',
75 description: '', 75 description: '',
76 isLocal: false 76 isLocal: false
77 }, 77 },
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 2ba6cdfaf..ba59a9a60 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -3,7 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, userLogin } from '../../utils' 5import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, userLogin } from '../../utils'
6import { getMyUserInformation, killallServers, ServerInfo, uploadVideo } from '../../utils/index' 6import { killallServers, ServerInfo, uploadVideo } from '../../utils/index'
7import { setAccessTokensToServers } from '../../utils/users/login' 7import { setAccessTokensToServers } from '../../utils/users/login'
8import { Video, VideoChannel } from '../../../../shared/models/videos' 8import { Video, VideoChannel } from '../../../../shared/models/videos'
9import { waitJobs } from '../../utils/server/jobs' 9import { waitJobs } from '../../utils/server/jobs'
@@ -18,8 +18,7 @@ const expect = chai.expect
18 18
19describe('Test users subscriptions', function () { 19describe('Test users subscriptions', function () {
20 let servers: ServerInfo[] = [] 20 let servers: ServerInfo[] = []
21 const users: { accessToken: string, videoChannelName: string }[] = [] 21 const users: { accessToken: string }[] = []
22 let rootChannelNameServer1: string
23 22
24 before(async function () { 23 before(async function () {
25 this.timeout(120000) 24 this.timeout(120000)
@@ -32,19 +31,13 @@ describe('Test users subscriptions', function () {
32 // Server 1 and server 2 follow each other 31 // Server 1 and server 2 follow each other
33 await doubleFollow(servers[0], servers[1]) 32 await doubleFollow(servers[0], servers[1])
34 33
35 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
36 rootChannelNameServer1 = res.body.videoChannels[0].name
37
38 { 34 {
39 for (const server of servers) { 35 for (const server of servers) {
40 const user = { username: 'user' + server.serverNumber, password: 'password' } 36 const user = { username: 'user' + server.serverNumber, password: 'password' }
41 await createUser(server.url, server.accessToken, user.username, user.password) 37 await createUser(server.url, server.accessToken, user.username, user.password)
42 38
43 const accessToken = await userLogin(server, user) 39 const accessToken = await userLogin(server, user)
44 const res = await getMyUserInformation(server.url, accessToken) 40 users.push({ accessToken })
45 const videoChannels: VideoChannel[] = res.body.videoChannels
46
47 users.push({ accessToken, videoChannelName: videoChannels[0].name })
48 41
49 const videoName1 = 'video 1-' + server.serverNumber 42 const videoName1 = 'video 1-' + server.serverNumber
50 await uploadVideo(server.url, accessToken, { name: videoName1 }) 43 await uploadVideo(server.url, accessToken, { name: videoName1 })
@@ -64,10 +57,10 @@ describe('Test users subscriptions', function () {
64 }) 57 })
65 58
66 it('User of server 1 should follow user of server 3 and root of server 1', async function () { 59 it('User of server 1 should follow user of server 3 and root of server 1', async function () {
67 this.timeout(30000) 60 this.timeout(60000)
68 61
69 await addUserSubscription(servers[0].url, users[0].accessToken, users[2].videoChannelName + '@localhost:9003') 62 await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')
70 await addUserSubscription(servers[0].url, users[0].accessToken, rootChannelNameServer1 + '@localhost:9001') 63 await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')
71 64
72 await waitJobs(servers) 65 await waitJobs(servers)
73 66
@@ -103,8 +96,8 @@ describe('Test users subscriptions', function () {
103 expect(subscriptions).to.be.an('array') 96 expect(subscriptions).to.be.an('array')
104 expect(subscriptions).to.have.lengthOf(2) 97 expect(subscriptions).to.have.lengthOf(2)
105 98
106 expect(subscriptions[0].name).to.equal(users[2].videoChannelName) 99 expect(subscriptions[0].name).to.equal('user3_channel')
107 expect(subscriptions[1].name).to.equal(rootChannelNameServer1) 100 expect(subscriptions[1].name).to.equal('root_channel')
108 } 101 }
109 }) 102 })
110 103
@@ -131,7 +124,7 @@ describe('Test users subscriptions', function () {
131 }) 124 })
132 125
133 it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { 126 it('Should upload a video by root on server 1 and see it in the subscription videos', async function () {
134 this.timeout(30000) 127 this.timeout(60000)
135 128
136 const videoName = 'video server 1 added after follow' 129 const videoName = 'video server 1 added after follow'
137 await uploadVideo(servers[0].url, servers[0].accessToken, { name: videoName }) 130 await uploadVideo(servers[0].url, servers[0].accessToken, { name: videoName })
@@ -172,7 +165,7 @@ describe('Test users subscriptions', function () {
172 }) 165 })
173 166
174 it('Should have server 1 follow server 3 and display server 3 videos', async function () { 167 it('Should have server 1 follow server 3 and display server 3 videos', async function () {
175 this.timeout(30000) 168 this.timeout(60000)
176 169
177 await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken) 170 await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken)
178 171
@@ -190,7 +183,7 @@ describe('Test users subscriptions', function () {
190 }) 183 })
191 184
192 it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { 185 it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
193 this.timeout(30000) 186 this.timeout(60000)
194 187
195 await unfollow(servers[0].url, servers[0].accessToken, servers[2]) 188 await unfollow(servers[0].url, servers[0].accessToken, servers[2])
196 189
@@ -230,7 +223,7 @@ describe('Test users subscriptions', function () {
230 }) 223 })
231 224
232 it('Should remove user of server 3 subscription', async function () { 225 it('Should remove user of server 3 subscription', async function () {
233 await removeUserSubscription(servers[0].url, users[0].accessToken, users[2].videoChannelName + '@localhost:9003') 226 await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')
234 227
235 await waitJobs(servers) 228 await waitJobs(servers)
236 }) 229 })
@@ -249,7 +242,7 @@ describe('Test users subscriptions', function () {
249 }) 242 })
250 243
251 it('Should remove the root subscription and not display the videos anymore', async function () { 244 it('Should remove the root subscription and not display the videos anymore', async function () {
252 await removeUserSubscription(servers[0].url, users[0].accessToken, rootChannelNameServer1 + '@localhost:9001') 245 await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')
253 246
254 await waitJobs(servers) 247 await waitJobs(servers)
255 248
@@ -275,9 +268,9 @@ describe('Test users subscriptions', function () {
275 }) 268 })
276 269
277 it('Should follow user of server 3 again', async function () { 270 it('Should follow user of server 3 again', async function () {
278 this.timeout(30000) 271 this.timeout(60000)
279 272
280 await addUserSubscription(servers[0].url, users[0].accessToken, users[2].videoChannelName + '@localhost:9003') 273 await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')
281 274
282 await waitJobs(servers) 275 await waitJobs(servers)
283 276
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 81489021b..575e04546 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -12,10 +12,9 @@ import {
12 getVideoChannelsList, 12 getVideoChannelsList,
13 removeUser, 13 removeUser,
14 updateMyUser, 14 updateMyUser,
15 userLogin, 15 userLogin
16 wait
17} from '../../utils' 16} from '../../utils'
18import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' 17import { getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index'
19import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' 18import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts'
20import { setAccessTokensToServers } from '../../utils/users/login' 19import { setAccessTokensToServers } from '../../utils/users/login'
21import { User } from '../../../../shared/models/users' 20import { User } from '../../../../shared/models/users'
@@ -172,7 +171,7 @@ describe('Test users with multiple servers', function () {
172 171
173 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) 172 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
174 const videoChannelDeleted = resVideoChannels.body.data.find(a => { 173 const videoChannelDeleted = resVideoChannels.body.data.find(a => {
175 return a.displayName === 'Default user1 channel' && a.host === 'localhost:9001' 174 return a.displayName === 'Main user1 channel' && a.host === 'localhost:9001'
176 }) as VideoChannel 175 }) as VideoChannel
177 expect(videoChannelDeleted).not.to.be.undefined 176 expect(videoChannelDeleted).not.to.be.undefined
178 } 177 }
@@ -189,7 +188,7 @@ describe('Test users with multiple servers', function () {
189 188
190 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) 189 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
191 const videoChannelDeleted = resVideoChannels.body.data.find(a => { 190 const videoChannelDeleted = resVideoChannels.body.data.find(a => {
192 return a.name === 'Default user1 channel' && a.host === 'localhost:9001' 191 return a.name === 'Main user1 channel' && a.host === 'localhost:9001'
193 }) as VideoChannel 192 }) as VideoChannel
194 expect(videoChannelDeleted).to.be.undefined 193 expect(videoChannelDeleted).to.be.undefined
195 } 194 }
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index cab096a12..3c3839338 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -6,7 +6,6 @@ import { join } from 'path'
6import * as request from 'supertest' 6import * as request from 'supertest'
7import { VideoPrivacy } from '../../../../shared/models/videos' 7import { VideoPrivacy } from '../../../../shared/models/videos'
8import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 8import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
9
10import { 9import {
11 addVideoChannel, 10 addVideoChannel,
12 checkVideoFilesWereRemoved, 11 checkVideoFilesWereRemoved,
@@ -60,6 +59,7 @@ describe('Test multiple servers', function () {
60 59
61 { 60 {
62 const videoChannel = { 61 const videoChannel = {
62 name: 'super_channel_name',
63 displayName: 'my channel', 63 displayName: 'my channel',
64 description: 'super channel' 64 description: 'super channel'
65 } 65 }
@@ -201,7 +201,7 @@ describe('Test multiple servers', function () {
201 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], 201 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
202 privacy: VideoPrivacy.PUBLIC, 202 privacy: VideoPrivacy.PUBLIC,
203 channel: { 203 channel: {
204 name: 'Default user1 channel', 204 name: 'Main user1 channel',
205 description: 'super channel', 205 description: 'super channel',
206 isLocal 206 isLocal
207 }, 207 },
@@ -307,7 +307,7 @@ describe('Test multiple servers', function () {
307 tags: [ 'tag1p3' ], 307 tags: [ 'tag1p3' ],
308 privacy: VideoPrivacy.PUBLIC, 308 privacy: VideoPrivacy.PUBLIC,
309 channel: { 309 channel: {
310 name: 'Default root channel', 310 name: 'Main root channel',
311 description: '', 311 description: '',
312 isLocal 312 isLocal
313 }, 313 },
@@ -339,7 +339,7 @@ describe('Test multiple servers', function () {
339 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 339 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
340 privacy: VideoPrivacy.PUBLIC, 340 privacy: VideoPrivacy.PUBLIC,
341 channel: { 341 channel: {
342 name: 'Default root channel', 342 name: 'Main root channel',
343 description: '', 343 description: '',
344 isLocal 344 isLocal
345 }, 345 },
@@ -647,7 +647,7 @@ describe('Test multiple servers', function () {
647 tags: [ 'tag_up_1', 'tag_up_2' ], 647 tags: [ 'tag_up_1', 'tag_up_2' ],
648 privacy: VideoPrivacy.PUBLIC, 648 privacy: VideoPrivacy.PUBLIC,
649 channel: { 649 channel: {
650 name: 'Default root channel', 650 name: 'Main root channel',
651 description: '', 651 description: '',
652 isLocal 652 isLocal
653 }, 653 },
@@ -967,7 +967,7 @@ describe('Test multiple servers', function () {
967 tags: [ ], 967 tags: [ ],
968 privacy: VideoPrivacy.PUBLIC, 968 privacy: VideoPrivacy.PUBLIC,
969 channel: { 969 channel: {
970 name: 'Default root channel', 970 name: 'Main root channel',
971 description: '', 971 description: '',
972 isLocal 972 isLocal
973 }, 973 },
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index ba4920d1b..12181ad67 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -56,7 +56,7 @@ describe('Test a single server', function () {
56 privacy: VideoPrivacy.PUBLIC, 56 privacy: VideoPrivacy.PUBLIC,
57 commentsEnabled: true, 57 commentsEnabled: true,
58 channel: { 58 channel: {
59 name: 'Default root channel', 59 name: 'Main root channel',
60 description: '', 60 description: '',
61 isLocal: true 61 isLocal: true
62 }, 62 },
@@ -87,7 +87,7 @@ describe('Test a single server', function () {
87 duration: 5, 87 duration: 5,
88 commentsEnabled: false, 88 commentsEnabled: false,
89 channel: { 89 channel: {
90 name: 'Default root channel', 90 name: 'Main root channel',
91 description: '', 91 description: '',
92 isLocal: true 92 isLocal: true
93 }, 93 },
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index e4e3ce9d9..8138c65d6 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -4,12 +4,13 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { User, Video } from '../../../../shared/index' 5import { User, Video } from '../../../../shared/index'
6import { 6import {
7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
9 getVideoChannelVideos, testImage, 10 getVideoChannelVideos, serverLogin, testImage,
10 updateVideo, 11 updateVideo,
11 updateVideoChannelAvatar, 12 updateVideoChannelAvatar,
12 uploadVideo, wait 13 uploadVideo, wait, userLogin
13} from '../../utils' 14} from '../../utils'
14import { 15import {
15 addVideoChannel, 16 addVideoChannel,
@@ -33,9 +34,7 @@ describe('Test video channels', function () {
33 let userInfo: User 34 let userInfo: User
34 let accountUUID: string 35 let accountUUID: string
35 let firstVideoChannelId: number 36 let firstVideoChannelId: number
36 let firstVideoChannelUUID: string
37 let secondVideoChannelId: number 37 let secondVideoChannelId: number
38 let secondVideoChannelUUID: string
39 let videoUUID: string 38 let videoUUID: string
40 39
41 before(async function () { 40 before(async function () {
@@ -54,7 +53,6 @@ describe('Test video channels', function () {
54 accountUUID = user.account.uuid 53 accountUUID = user.account.uuid
55 54
56 firstVideoChannelId = user.videoChannels[0].id 55 firstVideoChannelId = user.videoChannels[0].id
57 firstVideoChannelUUID = user.videoChannels[0].uuid
58 } 56 }
59 57
60 await waitJobs(servers) 58 await waitJobs(servers)
@@ -73,13 +71,13 @@ describe('Test video channels', function () {
73 71
74 { 72 {
75 const videoChannel = { 73 const videoChannel = {
74 name: 'second_video_channel',
76 displayName: 'second video channel', 75 displayName: 'second video channel',
77 description: 'super video channel description', 76 description: 'super video channel description',
78 support: 'super video channel support text' 77 support: 'super video channel support text'
79 } 78 }
80 const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) 79 const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
81 secondVideoChannelId = res.body.videoChannel.id 80 secondVideoChannelId = res.body.videoChannel.id
82 secondVideoChannelUUID = res.body.videoChannel.uuid
83 } 81 }
84 82
85 // The channel is 1 is propagated to servers 2 83 // The channel is 1 is propagated to servers 2
@@ -99,7 +97,10 @@ describe('Test video channels', function () {
99 expect(userInfo.videoChannels).to.have.lengthOf(2) 97 expect(userInfo.videoChannels).to.have.lengthOf(2)
100 98
101 const videoChannels = userInfo.videoChannels 99 const videoChannels = userInfo.videoChannels
102 expect(videoChannels[0].displayName).to.equal('Default root channel') 100 expect(videoChannels[0].name).to.equal('root_channel')
101 expect(videoChannels[0].displayName).to.equal('Main root channel')
102
103 expect(videoChannels[1].name).to.equal('second_video_channel')
103 expect(videoChannels[1].displayName).to.equal('second video channel') 104 expect(videoChannels[1].displayName).to.equal('second video channel')
104 expect(videoChannels[1].description).to.equal('super video channel description') 105 expect(videoChannels[1].description).to.equal('super video channel description')
105 expect(videoChannels[1].support).to.equal('super video channel support text') 106 expect(videoChannels[1].support).to.equal('super video channel support text')
@@ -112,7 +113,10 @@ describe('Test video channels', function () {
112 expect(res.body.data).to.have.lengthOf(2) 113 expect(res.body.data).to.have.lengthOf(2)
113 114
114 const videoChannels = res.body.data 115 const videoChannels = res.body.data
115 expect(videoChannels[0].displayName).to.equal('Default root channel') 116 expect(videoChannels[0].name).to.equal('root_channel')
117 expect(videoChannels[0].displayName).to.equal('Main root channel')
118
119 expect(videoChannels[1].name).to.equal('second_video_channel')
116 expect(videoChannels[1].displayName).to.equal('second video channel') 120 expect(videoChannels[1].displayName).to.equal('second video channel')
117 expect(videoChannels[1].description).to.equal('super video channel description') 121 expect(videoChannels[1].description).to.equal('super video channel description')
118 expect(videoChannels[1].support).to.equal('super video channel support text') 122 expect(videoChannels[1].support).to.equal('super video channel support text')
@@ -125,6 +129,7 @@ describe('Test video channels', function () {
125 expect(res.body.data).to.have.lengthOf(1) 129 expect(res.body.data).to.have.lengthOf(1)
126 130
127 const videoChannels = res.body.data 131 const videoChannels = res.body.data
132 expect(videoChannels[0].name).to.equal('second_video_channel')
128 expect(videoChannels[0].displayName).to.equal('second video channel') 133 expect(videoChannels[0].displayName).to.equal('second video channel')
129 expect(videoChannels[0].description).to.equal('super video channel description') 134 expect(videoChannels[0].description).to.equal('super video channel description')
130 expect(videoChannels[0].support).to.equal('super video channel support text') 135 expect(videoChannels[0].support).to.equal('super video channel support text')
@@ -136,7 +141,8 @@ describe('Test video channels', function () {
136 expect(res.body.total).to.equal(2) 141 expect(res.body.total).to.equal(2)
137 expect(res.body.data).to.be.an('array') 142 expect(res.body.data).to.be.an('array')
138 expect(res.body.data).to.have.lengthOf(1) 143 expect(res.body.data).to.have.lengthOf(1)
139 expect(res.body.data[0].displayName).to.equal('Default root channel') 144 expect(res.body.data[0].name).to.equal('root_channel')
145 expect(res.body.data[0].displayName).to.equal('Main root channel')
140 }) 146 })
141 147
142 it('Should update video channel', async function () { 148 it('Should update video channel', async function () {
@@ -148,7 +154,7 @@ describe('Test video channels', function () {
148 support: 'video channel support text updated' 154 support: 'video channel support text updated'
149 } 155 }
150 156
151 await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes) 157 await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes)
152 158
153 await waitJobs(servers) 159 await waitJobs(servers)
154 }) 160 })
@@ -160,6 +166,7 @@ describe('Test video channels', function () {
160 expect(res.body.total).to.equal(2) 166 expect(res.body.total).to.equal(2)
161 expect(res.body.data).to.be.an('array') 167 expect(res.body.data).to.be.an('array')
162 expect(res.body.data).to.have.lengthOf(1) 168 expect(res.body.data).to.have.lengthOf(1)
169 expect(res.body.data[0].name).to.equal('second_video_channel')
163 expect(res.body.data[0].displayName).to.equal('video channel updated') 170 expect(res.body.data[0].displayName).to.equal('video channel updated')
164 expect(res.body.data[0].description).to.equal('video channel description updated') 171 expect(res.body.data[0].description).to.equal('video channel description updated')
165 expect(res.body.data[0].support).to.equal('video channel support text updated') 172 expect(res.body.data[0].support).to.equal('video channel support text updated')
@@ -174,7 +181,7 @@ describe('Test video channels', function () {
174 await updateVideoChannelAvatar({ 181 await updateVideoChannelAvatar({
175 url: servers[0].url, 182 url: servers[0].url,
176 accessToken: servers[0].accessToken, 183 accessToken: servers[0].accessToken,
177 videoChannelId: secondVideoChannelId, 184 videoChannelName: 'second_video_channel',
178 fixture 185 fixture
179 }) 186 })
180 187
@@ -192,9 +199,10 @@ describe('Test video channels', function () {
192 }) 199 })
193 200
194 it('Should get video channel', async function () { 201 it('Should get video channel', async function () {
195 const res = await getVideoChannel(servers[0].url, secondVideoChannelId) 202 const res = await getVideoChannel(servers[0].url, 'second_video_channel')
196 203
197 const videoChannel = res.body 204 const videoChannel = res.body
205 expect(videoChannel.name).to.equal('second_video_channel')
198 expect(videoChannel.displayName).to.equal('video channel updated') 206 expect(videoChannel.displayName).to.equal('video channel updated')
199 expect(videoChannel.description).to.equal('video channel description updated') 207 expect(videoChannel.description).to.equal('video channel description updated')
200 expect(videoChannel.support).to.equal('video channel support text updated') 208 expect(videoChannel.support).to.equal('video channel support text updated')
@@ -204,7 +212,8 @@ describe('Test video channels', function () {
204 this.timeout(10000) 212 this.timeout(10000)
205 213
206 for (const server of servers) { 214 for (const server of servers) {
207 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) 215 const channelURI = 'second_video_channel@localhost:9001'
216 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
208 expect(res1.body.total).to.equal(1) 217 expect(res1.body.total).to.equal(1)
209 expect(res1.body.data).to.be.an('array') 218 expect(res1.body.data).to.be.an('array')
210 expect(res1.body.data).to.have.lengthOf(1) 219 expect(res1.body.data).to.have.lengthOf(1)
@@ -224,10 +233,12 @@ describe('Test video channels', function () {
224 this.timeout(10000) 233 this.timeout(10000)
225 234
226 for (const server of servers) { 235 for (const server of servers) {
227 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) 236 const secondChannelURI = 'second_video_channel@localhost:9001'
237 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
228 expect(res1.body.total).to.equal(0) 238 expect(res1.body.total).to.equal(0)
229 239
230 const res2 = await getVideoChannelVideos(server.url, server.accessToken, firstVideoChannelUUID, 0, 5) 240 const channelURI = 'root_channel@localhost:9001'
241 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
231 expect(res2.body.total).to.equal(1) 242 expect(res2.body.total).to.equal(1)
232 243
233 const videos: Video[] = res2.body.data 244 const videos: Video[] = res2.body.data
@@ -238,7 +249,7 @@ describe('Test video channels', function () {
238 }) 249 })
239 250
240 it('Should delete video channel', async function () { 251 it('Should delete video channel', async function () {
241 await deleteVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId) 252 await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel')
242 }) 253 })
243 254
244 it('Should have video channel deleted', async function () { 255 it('Should have video channel deleted', async function () {
@@ -247,7 +258,23 @@ describe('Test video channels', function () {
247 expect(res.body.total).to.equal(1) 258 expect(res.body.total).to.equal(1)
248 expect(res.body.data).to.be.an('array') 259 expect(res.body.data).to.be.an('array')
249 expect(res.body.data).to.have.lengthOf(1) 260 expect(res.body.data).to.have.lengthOf(1)
250 expect(res.body.data[0].displayName).to.equal('Default root channel') 261 expect(res.body.data[0].displayName).to.equal('Main root channel')
262 })
263
264 it('Should create the main channel with an uuid if there is a conflict', async function () {
265 {
266 const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
267 await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
268 }
269
270 {
271 await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, 'toto', 'password')
272 const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' })
273
274 const res = await getMyUserInformation(servers[ 0 ].url, accessToken)
275 const videoChannel = res.body.videoChannels[ 0 ]
276 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}/)
277 }
251 }) 278 })
252 279
253 after(async function () { 280 after(async function () {
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index 968b7bd7f..7f54c0e70 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -54,6 +54,7 @@ describe('Test update host scripts', function () {
54 54
55 // Create channel 55 // Create channel
56 const videoChannel = { 56 const videoChannel = {
57 name: 'second_channel',
57 displayName: 'second video channel', 58 displayName: 'second video channel',
58 description: 'super video channel description' 59 description: 'super video channel description'
59 } 60 }
diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.ts
index d41ac8d36..a7fdbd1dc 100644
--- a/server/tests/real-world/populate-database.ts
+++ b/server/tests/real-world/populate-database.ts
@@ -66,6 +66,7 @@ function getRandomInt (min, max) {
66 66
67function createCustomChannel (server: ServerInfo) { 67function createCustomChannel (server: ServerInfo) {
68 const videoChannel = { 68 const videoChannel = {
69 name: Date.now().toString(),
69 displayName: Date.now().toString(), 70 displayName: Date.now().toString(),
70 description: Date.now().toString() 71 description: Date.now().toString()
71 } 72 }
diff --git a/server/tests/utils/videos/video-channels.ts b/server/tests/utils/videos/video-channels.ts
index 3ca39469c..1eea22b31 100644
--- a/server/tests/utils/videos/video-channels.ts
+++ b/server/tests/utils/videos/video-channels.ts
@@ -97,10 +97,10 @@ function updateVideoChannelAvatar (options: {
97 url: string, 97 url: string,
98 accessToken: string, 98 accessToken: string,
99 fixture: string, 99 fixture: string,
100 videoChannelId: string | number 100 videoChannelName: string | number
101}) { 101}) {
102 102
103 const path = '/api/v1/video-channels/' + options.videoChannelId + '/avatar/pick' 103 const path = '/api/v1/video-channels/' + options.videoChannelName + '/avatar/pick'
104 104
105 return updateAvatarRequest(Object.assign(options, { path })) 105 return updateAvatarRequest(Object.assign(options, { path }))
106} 106}
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts
index b280cccda..592248144 100644
--- a/server/tests/utils/videos/videos.ts
+++ b/server/tests/utils/videos/videos.ts
@@ -199,13 +199,13 @@ function getAccountVideos (
199function getVideoChannelVideos ( 199function getVideoChannelVideos (
200 url: string, 200 url: string,
201 accessToken: string, 201 accessToken: string,
202 videoChannelId: number | string, 202 videoChannelName: string,
203 start: number, 203 start: number,
204 count: number, 204 count: number,
205 sort?: string, 205 sort?: string,
206 query: { nsfw?: boolean } = {} 206 query: { nsfw?: boolean } = {}
207) { 207) {
208 const path = '/api/v1/video-channels/' + videoChannelId + '/videos' 208 const path = '/api/v1/video-channels/' + videoChannelName + '/videos'
209 209
210 return makeGetRequest({ 210 return makeGetRequest({
211 url, 211 url,