aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-17 12:05:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a (patch)
tree87ee25f3033f0fe0da76ee3649bb24cae0509c0e /server/tests/api
parentafffe98839db7ccbfa9fb8b7d1413b97900fdc73 (diff)
downloadPeerTube-975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a.tar.gz
PeerTube-975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a.tar.zst
PeerTube-975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a.zip
Fix video full description
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/friends-advanced.ts292
-rw-r--r--server/tests/api/friends-basic.ts220
-rw-r--r--server/tests/api/index-fast.ts1
-rw-r--r--server/tests/api/index-slow.ts1
-rw-r--r--server/tests/api/video-blacklist-management.ts54
-rw-r--r--server/tests/api/video-blacklist.ts46
-rw-r--r--server/tests/api/video-channels.ts6
-rw-r--r--server/tests/api/video-description.ts37
-rw-r--r--server/tests/api/video-privacy.ts40
-rw-r--r--server/tests/api/video-transcoder.ts8
10 files changed, 95 insertions, 610 deletions
diff --git a/server/tests/api/friends-advanced.ts b/server/tests/api/friends-advanced.ts
deleted file mode 100644
index 654c959fd..000000000
--- a/server/tests/api/friends-advanced.ts
+++ /dev/null
@@ -1,292 +0,0 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5const expect = chai.expect
6
7import {
8 ServerInfo,
9 flushTests,
10 runServer,
11 uploadVideo,
12 quitFriends,
13 getVideosList,
14 wait,
15 setAccessTokensToServers,
16 flushAndRunMultipleServers,
17 killallServers,
18 makeFriends,
19 getFriendsList,
20 quitOneFriend
21} from '../utils'
22
23describe('Test advanced friends', function () {
24 let servers: ServerInfo[] = []
25
26 async function makeFriendsWrapper (podNumber: number) {
27 const server = servers[podNumber - 1]
28 return makeFriends(server.url, server.accessToken)
29 }
30
31 async function quitFriendsWrapper (podNumber: number) {
32 const server = servers[podNumber - 1]
33 return quitFriends(server.url, server.accessToken)
34 }
35
36 async function removeFriendWrapper (podNumber: number, podNumberToRemove: number) {
37 const server = servers[podNumber - 1]
38 const serverToRemove = servers[podNumberToRemove - 1]
39
40 const res = await getFriendsList(server.url)
41
42 let friendsList = res.body.data
43 let podToRemove = friendsList.find(friend => (friend.host === serverToRemove.host))
44
45 return quitOneFriend(server.url, server.accessToken, podToRemove.id)
46 }
47
48 async function getFriendsListWrapper (podNumber: number) {
49 const server = servers[podNumber - 1]
50 return getFriendsList(server.url)
51 }
52
53 async function uploadVideoWrapper (podNumber: number) {
54 const videoAttributes = {
55 tags: [ 'tag1', 'tag2' ]
56 }
57 const server = servers[podNumber - 1]
58
59 return uploadVideo(server.url, server.accessToken, videoAttributes)
60 }
61
62 async function getVideosWrapper (podNumber: number) {
63 return getVideosList(servers[podNumber - 1].url)
64 }
65
66 // ---------------------------------------------------------------
67
68 before(async function () {
69 this.timeout(120000)
70
71 servers = await flushAndRunMultipleServers(6)
72 await setAccessTokensToServers(servers)
73 })
74
75 it('Should not make friends with two different groups', async function () {
76 this.timeout(20000)
77
78 // Pod 3 makes friend with the first one
79 await makeFriendsWrapper(3)
80
81 // Pod 4 makes friend with the second one
82 await makeFriendsWrapper(4)
83
84 // Now if the fifth wants to make friends with the third and the first
85 await makeFriendsWrapper(5)
86
87 await wait(11000)
88
89 // It should have 0 friends
90 const res = await getFriendsListWrapper(5)
91 expect(res.body.data.length).to.equal(0)
92 })
93
94 it('Should quit all friends', async function () {
95 this.timeout(10000)
96
97 await quitFriendsWrapper(1)
98 await quitFriendsWrapper(2)
99
100 const serverNumbersToTest = [ 1, 2, 3, 4, 5, 6 ]
101 for (const i of serverNumbersToTest) {
102 const res = await getFriendsListWrapper(i)
103 expect(res.body.data.length).to.equal(0)
104 }
105 })
106
107 it('Should remove bad pod and new pod should not become friend with it', async function () {
108 this.timeout(200000)
109
110 // Pods 1, 2, 3 and 4 become friends
111 await makeFriendsWrapper(2)
112 await makeFriendsWrapper(1)
113 await makeFriendsWrapper(4)
114
115 // Check the pods 1, 2, 3 and 4 are friends
116 let serverNumbersToTest = [ 1, 2, 3, 4 ]
117 for (const i of serverNumbersToTest) {
118 const res = await getFriendsListWrapper(i)
119 expect(res.body.data.length).to.equal(3)
120 }
121
122 // Wait initial video channel requests
123 await wait(11000)
124
125 // Kill pod 4
126 servers[3].app.kill()
127
128 // Remove pod 4 from pod 1 and 2
129 await uploadVideoWrapper(1)
130 await uploadVideoWrapper(2)
131
132 await wait(11000)
133
134 await uploadVideoWrapper(1)
135 await uploadVideoWrapper(2)
136
137 await wait(11000)
138
139 await uploadVideoWrapper(1)
140 await uploadVideoWrapper(2)
141
142 await wait(11000)
143
144 await uploadVideoWrapper(1)
145 await uploadVideoWrapper(2)
146
147 await wait(11000)
148
149 serverNumbersToTest = [ 1, 2 ]
150
151 for (const i of serverNumbersToTest) {
152 const res = await getFriendsListWrapper(i)
153
154 // Pod 4 should not be our friend
155 const friends = res.body.data
156 expect(friends.length).to.equal(2)
157
158 for (const pod of friends) {
159 expect(pod.host).not.equal(servers[3].host)
160 }
161 }
162
163 // Rerun server 4
164 const newServer = await runServer(4)
165 servers[3].app = newServer.app
166 servers[3].app
167
168 // Pod 4 didn't know pod 1 and 2 removed it
169 const res1 = await getFriendsListWrapper(4)
170 expect(res1.body.data.length).to.equal(3)
171
172 // Pod 3 didn't upload video, it's still friend with pod 3
173 const res2 = await getFriendsListWrapper(3)
174 expect(res2.body.data.length).to.equal(3)
175
176 // Pod 6 asks pod 1, 2 and 3
177 await makeFriendsWrapper(6)
178
179 await wait(11000)
180
181 const res3 = await getFriendsListWrapper(6)
182
183 // Pod 4 should not be our friend
184 const friends = res3.body.data
185 expect(friends.length).to.equal(3)
186 for (const pod of friends) {
187 expect(pod.host).not.equal(servers[3].host)
188 }
189 })
190
191 // Pod 1 is friend with : 2 3 6
192 // Pod 2 is friend with : 1 3 6
193 // Pod 3 is friend with : 1 2 4 6
194 // Pod 4 is friend with : 1 2 3
195 // Pod 6 is friend with : 1 2 3
196 it('Should pod 1 quit friends', async function () {
197 this.timeout(25000)
198
199 // Upload a video on server 3 for additional tests
200 await uploadVideoWrapper(3)
201
202 await wait(15000)
203
204 // Pod 1 remove friends
205 await quitFriendsWrapper(1)
206
207 const res1 = await getVideosWrapper(1)
208 const videos1 = res1.body.data
209 expect(videos1).to.be.an('array')
210 expect(videos1.length).to.equal(4)
211
212 const res2 = await getVideosWrapper(2)
213 const videos2 = res2.body.data
214 expect(videos2).to.be.an('array')
215 expect(videos2.length).to.equal(5)
216 })
217
218 // Pod 1 is friend with nothing
219 // Pod 2 is friend with : 3 6
220 // Pod 3 is friend with : 2 4 6
221 // Pod 4 is friend with : 2 3
222 // Pod 6 is friend with : 2 3
223 it('Should make friends between pod 1, 2, 3 and 6 and exchange their videos', async function () {
224 this.timeout(30000)
225
226 await makeFriendsWrapper(1)
227
228 await wait(22000)
229
230 const res = await getVideosWrapper(1)
231 const videos = res.body.data
232 expect(videos).to.be.an('array')
233 expect(videos.length).to.equal(9)
234 })
235
236 // Pod 1 is friend with : 2 3 6
237 // Pod 2 is friend with : 1 3 6
238 // Pod 3 is friend with : 1 2 4 6
239 // Pod 4 is friend with : 2 3
240 // Pod 6 is friend with : 1 2 3
241 it('Should allow pod 6 to quit pod 1, 2 and 3 and be friend with pod 3', async function () {
242 this.timeout(30000)
243
244 // Pod 3 should have 4 friends
245 const res1 = await getFriendsListWrapper(3)
246 const friendsList1 = res1.body.data
247 expect(friendsList1).to.be.an('array')
248 expect(friendsList1.length).to.equal(4)
249
250 // Pod 1, 2, 6 should have 3 friends each
251 let serverNumbersToTest = [ 1, 2, 6 ]
252 for (const i of serverNumbersToTest) {
253 const res = await getFriendsListWrapper(i)
254 const friendsList = res.body.data
255 expect(friendsList).to.be.an('array')
256 expect(friendsList.length).to.equal(3)
257 }
258
259 await removeFriendWrapper(6, 1)
260 await removeFriendWrapper(6, 2)
261
262 // Pod 6 should now have only 1 friend (and it should be Pod 3)
263 const res2 = await getFriendsListWrapper(6)
264 const friendsList2 = res2.body.data
265 expect(friendsList2).to.be.an('array')
266 expect(friendsList2.length).to.equal(1)
267 expect(friendsList2[0].host).to.equal(servers[2].host)
268
269 // Pod 1 & 2 should not know friend 6 anymore
270 serverNumbersToTest = [ 1, 2 ]
271 for (const i of serverNumbersToTest) {
272 const res = await getFriendsListWrapper(i)
273 const friendsList = res.body.data
274 expect(friendsList).to.be.an('array')
275 expect(friendsList.length).to.equal(2)
276 }
277
278 // Pod 3 should know every pod
279 const res3 = await getFriendsListWrapper(3)
280 const friendsList3 = res3.body.data
281 expect(friendsList3).to.be.an('array')
282 expect(friendsList3.length).to.equal(4)
283 })
284
285 after(async function () {
286 killallServers(servers)
287
288 if (this['ok']) {
289 await flushTests()
290 }
291 })
292})
diff --git a/server/tests/api/friends-basic.ts b/server/tests/api/friends-basic.ts
deleted file mode 100644
index 31e180631..000000000
--- a/server/tests/api/friends-basic.ts
+++ /dev/null
@@ -1,220 +0,0 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5const expect = chai.expect
6
7import {
8 ServerInfo,
9 flushTests,
10 quitFriends,
11 wait,
12 setAccessTokensToServers,
13 flushAndRunMultipleServers,
14 killallServers,
15 makeFriends,
16 getFriendsList,
17 dateIsValid,
18 quitOneFriend,
19 getPodsListPaginationAndSort
20} from '../utils'
21
22describe('Test basic friends', function () {
23 let servers = []
24
25 function makeFriendsWrapper (podNumber: number) {
26 const server = servers[podNumber - 1]
27 return makeFriends(server.url, server.accessToken)
28 }
29
30 async function testMadeFriends (servers: ServerInfo[], serverToTest: ServerInfo) {
31 const friends = []
32 for (let i = 0; i < servers.length; i++) {
33 if (servers[i].url === serverToTest.url) continue
34 friends.push(servers[i].host)
35 }
36
37 const res = await getFriendsList(serverToTest.url)
38
39 const result = res.body.data
40 expect(result).to.be.an('array')
41 expect(result.length).to.equal(2)
42
43 const resultHosts = [ result[0].host, result[1].host ]
44 expect(resultHosts[0]).to.not.equal(resultHosts[1])
45
46 const errorString = 'Friends host do not correspond for ' + serverToTest.host
47 expect(friends).to.contain(resultHosts[0], errorString)
48 expect(friends).to.contain(resultHosts[1], errorString)
49 }
50
51 // ---------------------------------------------------------------
52
53 before(async function () {
54 this.timeout(120000)
55
56 servers = await flushAndRunMultipleServers(3)
57
58 await setAccessTokensToServers(servers)
59 })
60
61 it('Should not have friends', async function () {
62 for (const server of servers) {
63 const res = await getFriendsList(server.url)
64
65 const result = res.body.data
66 expect(result).to.be.an('array')
67 expect(result.length).to.equal(0)
68 }
69 })
70
71 it('Should make friends', async function () {
72 this.timeout(120000)
73
74 // The second pod make friend with the third
75 await makeFriendsWrapper(2)
76
77 // Wait for the request between pods
78 await wait(11000)
79
80 // The second pod should have the third as a friend
81 const res1 = await getFriendsList(servers[1].url)
82
83 const friends = res1.body.data
84 expect(friends).to.be.an('array')
85 expect(friends.length).to.equal(1)
86
87 const pod1 = friends[0]
88 expect(pod1.host).to.equal(servers[2].host)
89 expect(pod1.email).to.equal('admin3@example.com')
90 expect(pod1.score).to.be.at.least(20)
91 expect(dateIsValid(pod1.createdAt)).to.be.true
92
93 // Same here, the third pod should have the second pod as a friend
94 const res2 = await getFriendsList(servers[2].url)
95 const result = res2.body.data
96 expect(result).to.be.an('array')
97 expect(result.length).to.equal(1)
98
99 const pod2 = result[0]
100 expect(pod2.host).to.equal(servers[1].host)
101 expect(pod2.email).to.equal('admin2@example.com')
102 expect(pod2.score).to.be.at.least(20)
103 expect(dateIsValid(pod2.createdAt)).to.be.true
104
105 // Finally the first pod make friend with the second pod
106 await makeFriendsWrapper(1)
107
108 // Wait for the request between pods
109 await wait(11000)
110
111 // Now each pod should be friend with the other ones
112 for (const server of servers) {
113 await testMadeFriends(servers, server)
114 }
115 })
116
117 it('Should not be allowed to make friend again', async function () {
118 this.timeout(10000)
119
120 const server = servers[1]
121 await makeFriends(server.url, server.accessToken, 409)
122 })
123
124 it('Should list friends correctly', async function () {
125 const start = 1
126 const count = 1
127 const sort = '-host'
128
129 const res = await getPodsListPaginationAndSort(servers[0].url, start, count, sort)
130 expect(res.body.total).to.equal(2)
131 expect(res.body.data).to.have.lengthOf(1)
132
133 const pod = res.body.data[0]
134 expect(pod.host).to.equal('localhost:9002')
135 expect(pod.email).to.equal('admin2@example.com')
136 expect(pod.score).to.be.at.least(20)
137 expect(dateIsValid(pod.createdAt)).to.be.true
138 })
139
140 it('Should quit friends of pod 2', async function () {
141 this.timeout(10000)
142
143 // Pod 1 quit friends
144 await quitFriends(servers[1].url, servers[1].accessToken)
145
146 // Pod 1 should not have friends anymore
147 const res = await getFriendsList(servers[1].url)
148 const friends = res.body.data
149 expect(friends).to.be.an('array')
150 expect(friends).to.have.lengthOf(0)
151
152 // Other pods shouldn't have pod 1 too
153 const serversToTest = [ servers[0].url, servers[2].url ]
154 for (const url of serversToTest) {
155 const res = await getFriendsList(url)
156 const friends = res.body.data
157
158 expect(friends).to.be.an('array')
159 expect(friends.length).to.equal(1)
160 expect(friends[0].host).not.to.be.equal(servers[1].host)
161 }
162 })
163
164 it('Should allow pod 2 to make friend again', async function () {
165 this.timeout(120000)
166
167 const server = servers[1]
168 await makeFriends(server.url, server.accessToken)
169 await wait(11000)
170
171 for (const server of servers) {
172 await testMadeFriends(servers, server)
173 }
174 })
175
176 it('Should allow pod 1 to quit only pod 2', async function () {
177 // Pod 1 quits pod 2
178 const server = servers[0]
179
180 // Get pod 2 id so we can query it
181 const res1 = await getFriendsList(server.url)
182 const friends1 = res1.body.data
183 let pod1 = friends1.find(friend => (friend.host === servers[1].host))
184
185 // Remove it from the friends list
186 await quitOneFriend(server.url, server.accessToken, pod1.id)
187
188 // Pod 1 should have only pod 3 in its friends list
189 const res2 = await getFriendsList(servers[0].url)
190 const friends2 = res2.body.data
191 expect(friends2).to.be.an('array')
192 expect(friends2.length).to.equal(1)
193
194 const pod2 = friends2[0]
195 expect(pod2.host).to.equal(servers[2].host)
196
197 // Pod 2 should have only pod 3 in its friends list
198 const res3 = await getFriendsList(servers[1].url)
199 const friends3 = res3.body.data
200 expect(friends3).to.be.an('array')
201 expect(friends3.length).to.equal(1)
202
203 const pod = friends3[0]
204 expect(pod.host).to.equal(servers[2].host)
205
206 // Pod 3 should have both pods in its friends list
207 const res4 = await getFriendsList(servers[2].url)
208 const friends4 = res4.body.data
209 expect(friends4).to.be.an('array')
210 expect(friends4.length).to.equal(2)
211 })
212
213 after(async function () {
214 killallServers(servers)
215
216 if (this['ok']) {
217 await flushTests()
218 }
219 })
220})
diff --git a/server/tests/api/index-fast.ts b/server/tests/api/index-fast.ts
index ced973bc2..590b0d51c 100644
--- a/server/tests/api/index-fast.ts
+++ b/server/tests/api/index-fast.ts
@@ -1,7 +1,6 @@
1// Order of the tests we want to execute 1// Order of the tests we want to execute
2import './config' 2import './config'
3import './check-params' 3import './check-params'
4import './friends-basic'
5import './users' 4import './users'
6import './single-pod' 5import './single-pod'
7import './video-abuse' 6import './video-abuse'
diff --git a/server/tests/api/index-slow.ts b/server/tests/api/index-slow.ts
index e3b50e57a..a2faf8d0f 100644
--- a/server/tests/api/index-slow.ts
+++ b/server/tests/api/index-slow.ts
@@ -1,4 +1,3 @@
1// Order of the tests we want to execute 1// Order of the tests we want to execute
2import './multiple-pods' 2import './multiple-pods'
3import './friends-advanced'
4import './video-transcoder' 3import './video-transcoder'
diff --git a/server/tests/api/video-blacklist-management.ts b/server/tests/api/video-blacklist-management.ts
index 7057f4b23..718789318 100644
--- a/server/tests/api/video-blacklist-management.ts
+++ b/server/tests/api/video-blacklist-management.ts
@@ -1,31 +1,31 @@
1/* tslint:disable:no-unused-expressions */ 1/* tslint:disable:no-unused-expressions */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
5const expect = chai.expect
6import * as lodash from 'lodash' 4import * as lodash from 'lodash'
7const orderBy = lodash.orderBy 5import 'mocha'
8
9import { 6import {
10 ServerInfo, 7 addVideoToBlacklist,
11 flushTests,
12 wait,
13 setAccessTokensToServers,
14 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
15 killallServers, 9 flushTests,
16 makeFriends, 10 getBlacklistedVideosList,
11 getSortedBlacklistedVideosList,
17 getVideosList, 12 getVideosList,
18 uploadVideo, 13 killallServers,
19 addVideoToBlacklist,
20 removeVideoFromBlacklist, 14 removeVideoFromBlacklist,
21 getBlacklistedVideosList, 15 ServerInfo,
22 getSortedBlacklistedVideosList 16 setAccessTokensToServers,
17 uploadVideo,
18 wait
23} from '../utils' 19} from '../utils'
20import { doubleFollow } from '../utils/follows'
21
22const expect = chai.expect
23const orderBy = lodash.orderBy
24 24
25describe('Test video blacklist management', function () { 25describe('Test video blacklist management', function () {
26 let servers: ServerInfo[] = [] 26 let servers: ServerInfo[] = []
27 27
28 async function blacklistVideosOnPod (server: ServerInfo) { 28 async function blacklistVideosOnServer (server: ServerInfo) {
29 const res = await getVideosList(server.url) 29 const res = await getVideosList(server.url)
30 30
31 const videos = res.body.data 31 const videos = res.body.data
@@ -43,18 +43,18 @@ describe('Test video blacklist management', function () {
43 // Get the access tokens 43 // Get the access tokens
44 await setAccessTokensToServers(servers) 44 await setAccessTokensToServers(servers)
45 45
46 // Pod 1 makes friend with pod 2 46 // Server 1 and server 2 follow each other
47 await makeFriends(servers[0].url, servers[0].accessToken) 47 await doubleFollow(servers[0], servers[1])
48 48
49 // Upload 2 videos on pod 2 49 // Upload 2 videos on server 2
50 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 1st video', description: 'A video on pod 2' }) 50 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 1st video', description: 'A video on server 2' })
51 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on pod 2' }) 51 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on server 2' })
52 52
53 // Wait videos propagation 53 // Wait videos propagation
54 await wait(22000) 54 await wait(50000)
55 55
56 // Blacklist the two videos on pod 1 56 // Blacklist the two videos on server 1
57 await blacklistVideosOnPod(servers[0]) 57 await blacklistVideosOnServer(servers[0])
58 }) 58 })
59 59
60 describe('When listing blacklisted videos', function () { 60 describe('When listing blacklisted videos', function () {
@@ -112,14 +112,14 @@ describe('Test video blacklist management', function () {
112 let videoToRemove 112 let videoToRemove
113 let blacklist = [] 113 let blacklist = []
114 114
115 it('Should not have any video in videos list on pod 1', async function () { 115 it('Should not have any video in videos list on server 1', async function () {
116 const res = await getVideosList(servers[0].url) 116 const res = await getVideosList(servers[0].url)
117 expect(res.body.total).to.equal(0) 117 expect(res.body.total).to.equal(0)
118 expect(res.body.data).to.be.an('array') 118 expect(res.body.data).to.be.an('array')
119 expect(res.body.data.length).to.equal(0) 119 expect(res.body.data.length).to.equal(0)
120 }) 120 })
121 121
122 it('Should remove a video from the blacklist on pod 1', async function () { 122 it('Should remove a video from the blacklist on server 1', async function () {
123 // Get one video in the blacklist 123 // Get one video in the blacklist
124 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') 124 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name')
125 videoToRemove = res.body.data[0] 125 videoToRemove = res.body.data[0]
@@ -129,7 +129,7 @@ describe('Test video blacklist management', function () {
129 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.videoId) 129 await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.videoId)
130 }) 130 })
131 131
132 it('Should have the ex-blacklisted video in videos list on pod 1', async function () { 132 it('Should have the ex-blacklisted video in videos list on server 1', async function () {
133 const res = await getVideosList(servers[0].url) 133 const res = await getVideosList(servers[0].url)
134 expect(res.body.total).to.equal(1) 134 expect(res.body.total).to.equal(1)
135 135
@@ -141,7 +141,7 @@ describe('Test video blacklist management', function () {
141 expect(videos[0].id).to.equal(videoToRemove.videoId) 141 expect(videos[0].id).to.equal(videoToRemove.videoId)
142 }) 142 })
143 143
144 it('Should not have the ex-blacklisted video in videos blacklist list on pod 1', async function () { 144 it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () {
145 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') 145 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name')
146 expect(res.body.total).to.equal(1) 146 expect(res.body.total).to.equal(1)
147 147
diff --git a/server/tests/api/video-blacklist.ts b/server/tests/api/video-blacklist.ts
index e789611d0..235fdd7af 100644
--- a/server/tests/api/video-blacklist.ts
+++ b/server/tests/api/video-blacklist.ts
@@ -1,22 +1,22 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
5const expect = chai.expect 4import 'mocha'
6
7import { 5import {
8 ServerInfo, 6 addVideoToBlacklist,
7 flushAndRunMultipleServers,
9 flushTests, 8 flushTests,
10 uploadVideo,
11 makeFriends,
12 getVideosList, 9 getVideosList,
13 wait, 10 killallServers,
14 setAccessTokensToServers,
15 flushAndRunMultipleServers,
16 addVideoToBlacklist,
17 searchVideo, 11 searchVideo,
18 killallServers 12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo,
15 wait
19} from '../utils' 16} from '../utils'
17import { doubleFollow } from '../utils/follows'
18
19const expect = chai.expect
20 20
21describe('Test video blacklists', function () { 21describe('Test video blacklists', function () {
22 let servers: ServerInfo[] = [] 22 let servers: ServerInfo[] = []
@@ -30,32 +30,32 @@ describe('Test video blacklists', function () {
30 // Get the access tokens 30 // Get the access tokens
31 await setAccessTokensToServers(servers) 31 await setAccessTokensToServers(servers)
32 32
33 // Pod 1 makes friend with pod 2 33 // Server 1 and server 2 follow each other
34 await makeFriends(servers[0].url, servers[0].accessToken) 34 await doubleFollow(servers[0], servers[1])
35 35
36 // Upload a video on pod 2 36 // Upload a video on server 2
37 const videoAttributes = { 37 const videoAttributes = {
38 name: 'my super name for pod 2', 38 name: 'my super name for server 2',
39 description: 'my super description for pod 2' 39 description: 'my super description for server 2'
40 } 40 }
41 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 41 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
42 42
43 // Wait videos propagation 43 // Wait videos propagation
44 await wait(22000) 44 await wait(25000)
45 45
46 const res = await getVideosList(servers[0].url) 46 const res = await getVideosList(servers[0].url)
47 const videos = res.body.data 47 const videos = res.body.data
48 48
49 expect(videos.length).to.equal(1) 49 expect(videos.length).to.equal(1)
50 50
51 servers[0].remoteVideo = videos.find(video => video.name === 'my super name for pod 2') 51 servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2')
52 }) 52 })
53 53
54 it('Should blacklist a remote video on pod 1', async function () { 54 it('Should blacklist a remote video on server 1', async function () {
55 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id) 55 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
56 }) 56 })
57 57
58 it('Should not have the video blacklisted in videos list on pod 1', async function () { 58 it('Should not have the video blacklisted in videos list on server 1', async function () {
59 const res = await getVideosList(servers[0].url) 59 const res = await getVideosList(servers[0].url)
60 60
61 expect(res.body.total).to.equal(0) 61 expect(res.body.total).to.equal(0)
@@ -63,7 +63,7 @@ describe('Test video blacklists', function () {
63 expect(res.body.data.length).to.equal(0) 63 expect(res.body.data.length).to.equal(0)
64 }) 64 })
65 65
66 it('Should not have the video blacklisted in videos search on pod 1', async function () { 66 it('Should not have the video blacklisted in videos search on server 1', async function () {
67 const res = await searchVideo(servers[0].url, 'name') 67 const res = await searchVideo(servers[0].url, 'name')
68 68
69 expect(res.body.total).to.equal(0) 69 expect(res.body.total).to.equal(0)
@@ -71,7 +71,7 @@ describe('Test video blacklists', function () {
71 expect(res.body.data.length).to.equal(0) 71 expect(res.body.data.length).to.equal(0)
72 }) 72 })
73 73
74 it('Should have the blacklisted video in videos list on pod 2', async function () { 74 it('Should have the blacklisted video in videos list on server 2', async function () {
75 const res = await getVideosList(servers[1].url) 75 const res = await getVideosList(servers[1].url)
76 76
77 expect(res.body.total).to.equal(1) 77 expect(res.body.total).to.equal(1)
@@ -79,7 +79,7 @@ describe('Test video blacklists', function () {
79 expect(res.body.data.length).to.equal(1) 79 expect(res.body.data.length).to.equal(1)
80 }) 80 })
81 81
82 it('Should have the video blacklisted in videos search on pod 2', async function () { 82 it('Should have the video blacklisted in videos search on server 2', async function () {
83 const res = await searchVideo(servers[1].url, 'name') 83 const res = await searchVideo(servers[1].url, 'name')
84 84
85 expect(res.body.total).to.equal(1) 85 expect(res.body.total).to.equal(1)
diff --git a/server/tests/api/video-channels.ts b/server/tests/api/video-channels.ts
index b851d7185..de1807ef2 100644
--- a/server/tests/api/video-channels.ts
+++ b/server/tests/api/video-channels.ts
@@ -13,7 +13,7 @@ import {
13 getMyUserInformation, 13 getMyUserInformation,
14 getVideoChannelsList, 14 getVideoChannelsList,
15 addVideoChannel, 15 addVideoChannel,
16 getAuthorVideoChannelsList, 16 getAccountVideoChannelsList,
17 updateVideoChannel, 17 updateVideoChannel,
18 deleteVideoChannel, 18 deleteVideoChannel,
19 getVideoChannel 19 getVideoChannel
@@ -64,8 +64,8 @@ describe('Test a video channels', function () {
64 expect(videoChannels[1].description).to.equal('super video channel description') 64 expect(videoChannels[1].description).to.equal('super video channel description')
65 }) 65 })
66 66
67 it('Should have two video channels when getting author channels', async () => { 67 it('Should have two video channels when getting account channels', async () => {
68 const res = await getAuthorVideoChannelsList(server.url, userInfo.account.uuid) 68 const res = await getAccountVideoChannelsList(server.url, userInfo.account.uuid)
69 69
70 expect(res.body.total).to.equal(2) 70 expect(res.body.total).to.equal(2)
71 expect(res.body.data).to.be.an('array') 71 expect(res.body.data).to.be.an('array')
diff --git a/server/tests/api/video-description.ts b/server/tests/api/video-description.ts
index 43d99e9e6..187fd21f2 100644
--- a/server/tests/api/video-description.ts
+++ b/server/tests/api/video-description.ts
@@ -1,22 +1,21 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
5 4import 'mocha'
6import { 5import {
7 flushAndRunMultipleServers, 6 flushAndRunMultipleServers,
8 flushTests, 7 flushTests,
9 getVideo, 8 getVideo,
9 getVideoDescription,
10 getVideosList, 10 getVideosList,
11 killallServers, 11 killallServers,
12 makeFriends,
13 ServerInfo, 12 ServerInfo,
14 setAccessTokensToServers, 13 setAccessTokensToServers,
14 updateVideo,
15 uploadVideo, 15 uploadVideo,
16 wait, 16 wait
17 getVideoDescription,
18 updateVideo
19} from '../utils' 17} from '../utils'
18import { doubleFollow } from '../utils/follows'
20 19
21const expect = chai.expect 20const expect = chai.expect
22 21
@@ -24,10 +23,10 @@ describe('Test video description', function () {
24 let servers: ServerInfo[] = [] 23 let servers: ServerInfo[] = []
25 let videoUUID = '' 24 let videoUUID = ''
26 let videoId: number 25 let videoId: number
27 let longDescription = 'my super description for pod 1'.repeat(50) 26 let longDescription = 'my super description for server 1'.repeat(50)
28 27
29 before(async function () { 28 before(async function () {
30 this.timeout(10000) 29 this.timeout(30000)
31 30
32 // Run servers 31 // Run servers
33 servers = await flushAndRunMultipleServers(2) 32 servers = await flushAndRunMultipleServers(2)
@@ -35,19 +34,19 @@ describe('Test video description', function () {
35 // Get the access tokens 34 // Get the access tokens
36 await setAccessTokensToServers(servers) 35 await setAccessTokensToServers(servers)
37 36
38 // Pod 1 makes friend with pod 2 37 // Server 1 and server 2 follow each other
39 await makeFriends(servers[0].url, servers[0].accessToken) 38 await doubleFollow(servers[0], servers[1])
40 }) 39 })
41 40
42 it('Should upload video with long description', async function () { 41 it('Should upload video with long description', async function () {
43 this.timeout(15000) 42 this.timeout(30000)
44 43
45 const attributes = { 44 const attributes = {
46 description: longDescription 45 description: longDescription
47 } 46 }
48 await uploadVideo(servers[0].url, servers[0].accessToken, attributes) 47 await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
49 48
50 await wait(11000) 49 await wait(25000)
51 50
52 const res = await getVideosList(servers[0].url) 51 const res = await getVideosList(servers[0].url)
53 52
@@ -55,20 +54,20 @@ describe('Test video description', function () {
55 videoUUID = res.body.data[0].uuid 54 videoUUID = res.body.data[0].uuid
56 }) 55 })
57 56
58 it('Should have a truncated description on each pod', async function () { 57 it('Should have a truncated description on each server', async function () {
59 for (const server of servers) { 58 for (const server of servers) {
60 const res = await getVideo(server.url, videoUUID) 59 const res = await getVideo(server.url, videoUUID)
61 const video = res.body 60 const video = res.body
62 61
63 // 30 characters * 6 -> 240 characters 62 // 30 characters * 6 -> 240 characters
64 const truncatedDescription = 'my super description for pod 1'.repeat(8) + 63 const truncatedDescription = 'my super description for server 1'.repeat(7) +
65 'my supe...' 64 'my super descrip...'
66 65
67 expect(video.description).to.equal(truncatedDescription) 66 expect(video.description).to.equal(truncatedDescription)
68 } 67 }
69 }) 68 })
70 69
71 it('Should fetch long description on each pod', async function () { 70 it('Should fetch long description on each server', async function () {
72 for (const server of servers) { 71 for (const server of servers) {
73 const res = await getVideo(server.url, videoUUID) 72 const res = await getVideo(server.url, videoUUID)
74 const video = res.body 73 const video = res.body
@@ -79,17 +78,17 @@ describe('Test video description', function () {
79 }) 78 })
80 79
81 it('Should update with a short description', async function () { 80 it('Should update with a short description', async function () {
82 this.timeout(15000) 81 this.timeout(30000)
83 82
84 const attributes = { 83 const attributes = {
85 description: 'short description' 84 description: 'short description'
86 } 85 }
87 await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes) 86 await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes)
88 87
89 await wait(11000) 88 await wait(25000)
90 }) 89 })
91 90
92 it('Should have a small description on each pod', async function () { 91 it('Should have a small description on each server', async function () {
93 for (const server of servers) { 92 for (const server of servers) {
94 const res = await getVideo(server.url, videoUUID) 93 const res = await getVideo(server.url, videoUUID)
95 const video = res.body 94 const video = res.body
diff --git a/server/tests/api/video-privacy.ts b/server/tests/api/video-privacy.ts
index beac1613e..eb1e4f873 100644
--- a/server/tests/api/video-privacy.ts
+++ b/server/tests/api/video-privacy.ts
@@ -1,24 +1,24 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
5const expect = chai.expect 4import 'mocha'
6 5import { VideoPrivacy } from '../../../shared/models/videos/video-privacy.enum'
7import { 6import {
8 ServerInfo, 7 flushAndRunMultipleServers,
9 flushTests, 8 flushTests,
10 uploadVideo,
11 makeFriends,
12 getVideosList, 9 getVideosList,
13 wait, 10 killallServers,
11 ServerInfo,
14 setAccessTokensToServers, 12 setAccessTokensToServers,
15 flushAndRunMultipleServers, 13 uploadVideo,
16 killallServers 14 wait
17} from '../utils' 15} from '../utils'
18import { VideoPrivacy } from '../../../shared/models/videos/video-privacy.enum' 16import { doubleFollow } from '../utils/follows'
19import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../utils/videos'
20import { createUser } from '../utils/users'
21import { getUserAccessToken } from '../utils/login' 17import { getUserAccessToken } from '../utils/login'
18import { createUser } from '../utils/users'
19import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../utils/videos'
20
21const expect = chai.expect
22 22
23describe('Test video privacy', function () { 23describe('Test video privacy', function () {
24 let servers: ServerInfo[] = [] 24 let servers: ServerInfo[] = []
@@ -35,11 +35,11 @@ describe('Test video privacy', function () {
35 // Get the access tokens 35 // Get the access tokens
36 await setAccessTokensToServers(servers) 36 await setAccessTokensToServers(servers)
37 37
38 // Pod 1 makes friend with pod 2 38 // Server 1 and server 2 follow each other
39 await makeFriends(servers[0].url, servers[0].accessToken) 39 await doubleFollow(servers[0], servers[1])
40 }) 40 })
41 41
42 it('Should upload a private video on pod 1', async function () { 42 it('Should upload a private video on server 1', async function () {
43 this.timeout(15000) 43 this.timeout(15000)
44 44
45 const attributes = { 45 const attributes = {
@@ -50,7 +50,7 @@ describe('Test video privacy', function () {
50 await wait(11000) 50 await wait(11000)
51 }) 51 })
52 52
53 it('Should not have this private video on pod 2', async function () { 53 it('Should not have this private video on server 2', async function () {
54 const res = await getVideosList(servers[1].url) 54 const res = await getVideosList(servers[1].url)
55 55
56 expect(res.body.total).to.equal(0) 56 expect(res.body.total).to.equal(0)
@@ -86,7 +86,7 @@ describe('Test video privacy', function () {
86 await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID) 86 await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID)
87 }) 87 })
88 88
89 it('Should upload a unlisted video on pod 2', async function () { 89 it('Should upload a unlisted video on server 2', async function () {
90 this.timeout(30000) 90 this.timeout(30000)
91 91
92 const attributes = { 92 const attributes = {
@@ -98,7 +98,7 @@ describe('Test video privacy', function () {
98 await wait(22000) 98 await wait(22000)
99 }) 99 })
100 100
101 it('Should not have this unlisted video listed on pod 1 and 2', async function () { 101 it('Should not have this unlisted video listed on server 1 and 2', async function () {
102 for (const server of servers) { 102 for (const server of servers) {
103 const res = await getVideosList(server.url) 103 const res = await getVideosList(server.url)
104 104
@@ -124,7 +124,7 @@ describe('Test video privacy', function () {
124 } 124 }
125 }) 125 })
126 126
127 it('Should update the private video to public on pod 1', async function () { 127 it('Should update the private video to public on server 1', async function () {
128 this.timeout(15000) 128 this.timeout(15000)
129 129
130 const attribute = { 130 const attribute = {
@@ -137,7 +137,7 @@ describe('Test video privacy', function () {
137 await wait(11000) 137 await wait(11000)
138 }) 138 })
139 139
140 it('Should not have this new unlisted video listed on pod 1 and 2', async function () { 140 it('Should not have this new unlisted video listed on server 1 and 2', async function () {
141 for (const server of servers) { 141 for (const server of servers) {
142 const res = await getVideosList(server.url) 142 const res = await getVideosList(server.url)
143 143
diff --git a/server/tests/api/video-transcoder.ts b/server/tests/api/video-transcoder.ts
index cafcc037d..e80b099d1 100644
--- a/server/tests/api/video-transcoder.ts
+++ b/server/tests/api/video-transcoder.ts
@@ -33,8 +33,8 @@ describe('Test video transcoding', function () {
33 this.timeout(60000) 33 this.timeout(60000)
34 34
35 const videoAttributes = { 35 const videoAttributes = {
36 name: 'my super name for pod 1', 36 name: 'my super name for server 1',
37 description: 'my super description for pod 1', 37 description: 'my super description for server 1',
38 fixture: 'video_short.webm' 38 fixture: 'video_short.webm'
39 } 39 }
40 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 40 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
@@ -61,8 +61,8 @@ describe('Test video transcoding', function () {
61 this.timeout(60000) 61 this.timeout(60000)
62 62
63 const videoAttributes = { 63 const videoAttributes = {
64 name: 'my super name for pod 2', 64 name: 'my super name for server 2',
65 description: 'my super description for pod 2', 65 description: 'my super description for server 2',
66 fixture: 'video_short.webm' 66 fixture: 'video_short.webm'
67 } 67 }
68 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 68 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)