aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/users.js3
-rw-r--r--server/tests/api/check-params/video-abuses.js3
-rw-r--r--server/tests/api/check-params/videos.js58
-rw-r--r--server/tests/api/friends-advanced.js3
-rw-r--r--server/tests/api/multiple-pods.js25
-rw-r--r--server/tests/api/requests.js3
-rw-r--r--server/tests/api/single-pod.js42
-rw-r--r--server/tests/api/users.js12
-rw-r--r--server/tests/api/video-abuse.js6
9 files changed, 134 insertions, 21 deletions
diff --git a/server/tests/api/check-params/users.js b/server/tests/api/check-params/users.js
index 11e2bada4..f6fbcf555 100644
--- a/server/tests/api/check-params/users.js
+++ b/server/tests/api/check-params/users.js
@@ -51,10 +51,11 @@ describe('Test users API validators', function () {
51 }, 51 },
52 function (next) { 52 function (next) {
53 const name = 'my super name for pod' 53 const name = 'my super name for pod'
54 const category = 5
54 const description = 'my super description for pod' 55 const description = 'my super description for pod'
55 const tags = [ 'tag' ] 56 const tags = [ 'tag' ]
56 const file = 'video_short2.webm' 57 const file = 'video_short2.webm'
57 videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, file, next) 58 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, next)
58 }, 59 },
59 function (next) { 60 function (next) {
60 videosUtils.getVideosList(server.url, function (err, res) { 61 videosUtils.getVideosList(server.url, function (err, res) {
diff --git a/server/tests/api/check-params/video-abuses.js b/server/tests/api/check-params/video-abuses.js
index 7308637e2..061b80be8 100644
--- a/server/tests/api/check-params/video-abuses.js
+++ b/server/tests/api/check-params/video-abuses.js
@@ -62,10 +62,11 @@ describe('Test video abuses API validators', function () {
62 // Upload some videos on each pods 62 // Upload some videos on each pods
63 function (next) { 63 function (next) {
64 const name = 'my super name for pod' 64 const name = 'my super name for pod'
65 const category = 2
65 const description = 'my super description for pod' 66 const description = 'my super description for pod'
66 const tags = [ 'tag' ] 67 const tags = [ 'tag' ]
67 const file = 'video_short2.webm' 68 const file = 'video_short2.webm'
68 videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, file, next) 69 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, next)
69 }, 70 },
70 function (next) { 71 function (next) {
71 videosUtils.getVideosList(server.url, function (err, res) { 72 videosUtils.getVideosList(server.url, function (err, res) {
diff --git a/server/tests/api/check-params/videos.js b/server/tests/api/check-params/videos.js
index 0f5f40b8e..fbfe6f137 100644
--- a/server/tests/api/check-params/videos.js
+++ b/server/tests/api/check-params/videos.js
@@ -112,6 +112,7 @@ describe('Test videos API validator', function () {
112 112
113 it('Should fail without name', function (done) { 113 it('Should fail without name', function (done) {
114 const data = { 114 const data = {
115 category: 5,
115 description: 'my super description', 116 description: 'my super description',
116 tags: [ 'tag1', 'tag2' ] 117 tags: [ 'tag1', 'tag2' ]
117 } 118 }
@@ -124,6 +125,32 @@ describe('Test videos API validator', function () {
124 it('Should fail with a long name', function (done) { 125 it('Should fail with a long name', function (done) {
125 const data = { 126 const data = {
126 name: 'My very very very very very very very very very very very very very very very very long name', 127 name: 'My very very very very very very very very very very very very very very very very long name',
128 category: 5,
129 description: 'my super description',
130 tags: [ 'tag1', 'tag2' ]
131 }
132 const attach = {
133 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
134 }
135 requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
136 })
137
138 it('Should fail without a category', function (done) {
139 const data = {
140 name: 'my super name',
141 description: 'my super description',
142 tags: [ 'tag1', 'tag2' ]
143 }
144 const attach = {
145 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
146 }
147 requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
148 })
149
150 it('Should fail with a bad category', function (done) {
151 const data = {
152 name: 'my super name',
153 category: 125,
127 description: 'my super description', 154 description: 'my super description',
128 tags: [ 'tag1', 'tag2' ] 155 tags: [ 'tag1', 'tag2' ]
129 } 156 }
@@ -136,6 +163,7 @@ describe('Test videos API validator', function () {
136 it('Should fail without description', function (done) { 163 it('Should fail without description', function (done) {
137 const data = { 164 const data = {
138 name: 'my super name', 165 name: 'my super name',
166 category: 5,
139 tags: [ 'tag1', 'tag2' ] 167 tags: [ 'tag1', 'tag2' ]
140 } 168 }
141 const attach = { 169 const attach = {
@@ -147,6 +175,7 @@ describe('Test videos API validator', function () {
147 it('Should fail with a long description', function (done) { 175 it('Should fail with a long description', function (done) {
148 const data = { 176 const data = {
149 name: 'my super name', 177 name: 'my super name',
178 category: 5,
150 description: 'my super description which is very very very very very very very very very very very very very very' + 179 description: 'my super description which is very very very very very very very very very very very very very very' +
151 'very very very very very very very very very very very very very very very very very very very very very' + 180 'very very very very very very very very very very very very very very very very very very very very very' +
152 'very very very very very very very very very very very very very very very long', 181 'very very very very very very very very very very very very very very very long',
@@ -161,6 +190,7 @@ describe('Test videos API validator', function () {
161 it('Should fail without tags', function (done) { 190 it('Should fail without tags', function (done) {
162 const data = { 191 const data = {
163 name: 'my super name', 192 name: 'my super name',
193 category: 5,
164 description: 'my super description' 194 description: 'my super description'
165 } 195 }
166 const attach = { 196 const attach = {
@@ -172,6 +202,7 @@ describe('Test videos API validator', function () {
172 it('Should fail with too many tags', function (done) { 202 it('Should fail with too many tags', function (done) {
173 const data = { 203 const data = {
174 name: 'my super name', 204 name: 'my super name',
205 category: 5,
175 description: 'my super description', 206 description: 'my super description',
176 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] 207 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
177 } 208 }
@@ -184,6 +215,7 @@ describe('Test videos API validator', function () {
184 it('Should fail with not enough tags', function (done) { 215 it('Should fail with not enough tags', function (done) {
185 const data = { 216 const data = {
186 name: 'my super name', 217 name: 'my super name',
218 category: 5,
187 description: 'my super description', 219 description: 'my super description',
188 tags: [ ] 220 tags: [ ]
189 } 221 }
@@ -196,6 +228,7 @@ describe('Test videos API validator', function () {
196 it('Should fail with a tag length too low', function (done) { 228 it('Should fail with a tag length too low', function (done) {
197 const data = { 229 const data = {
198 name: 'my super name', 230 name: 'my super name',
231 category: 5,
199 description: 'my super description', 232 description: 'my super description',
200 tags: [ 'tag1', 't' ] 233 tags: [ 'tag1', 't' ]
201 } 234 }
@@ -208,6 +241,7 @@ describe('Test videos API validator', function () {
208 it('Should fail with a tag length too big', function (done) { 241 it('Should fail with a tag length too big', function (done) {
209 const data = { 242 const data = {
210 name: 'my super name', 243 name: 'my super name',
244 category: 5,
211 description: 'my super description', 245 description: 'my super description',
212 tags: [ 'mysupertagtoolong', 'tag1' ] 246 tags: [ 'mysupertagtoolong', 'tag1' ]
213 } 247 }
@@ -220,6 +254,7 @@ describe('Test videos API validator', function () {
220 it('Should fail with malformed tags', function (done) { 254 it('Should fail with malformed tags', function (done) {
221 const data = { 255 const data = {
222 name: 'my super name', 256 name: 'my super name',
257 category: 5,
223 description: 'my super description', 258 description: 'my super description',
224 tags: [ 'my tag' ] 259 tags: [ 'my tag' ]
225 } 260 }
@@ -232,6 +267,7 @@ describe('Test videos API validator', function () {
232 it('Should fail without an input file', function (done) { 267 it('Should fail without an input file', function (done) {
233 const data = { 268 const data = {
234 name: 'my super name', 269 name: 'my super name',
270 category: 5,
235 description: 'my super description', 271 description: 'my super description',
236 tags: [ 'tag1', 'tag2' ] 272 tags: [ 'tag1', 'tag2' ]
237 } 273 }
@@ -242,6 +278,7 @@ describe('Test videos API validator', function () {
242 it('Should fail without an incorrect input file', function (done) { 278 it('Should fail without an incorrect input file', function (done) {
243 const data = { 279 const data = {
244 name: 'my super name', 280 name: 'my super name',
281 category: 5,
245 description: 'my super description', 282 description: 'my super description',
246 tags: [ 'tag1', 'tag2' ] 283 tags: [ 'tag1', 'tag2' ]
247 } 284 }
@@ -254,6 +291,7 @@ describe('Test videos API validator', function () {
254 it('Should fail with a too big duration', function (done) { 291 it('Should fail with a too big duration', function (done) {
255 const data = { 292 const data = {
256 name: 'my super name', 293 name: 'my super name',
294 category: 5,
257 description: 'my super description', 295 description: 'my super description',
258 tags: [ 'tag1', 'tag2' ] 296 tags: [ 'tag1', 'tag2' ]
259 } 297 }
@@ -266,6 +304,7 @@ describe('Test videos API validator', function () {
266 it('Should succeed with the correct parameters', function (done) { 304 it('Should succeed with the correct parameters', function (done) {
267 const data = { 305 const data = {
268 name: 'my super name', 306 name: 'my super name',
307 category: 5,
269 description: 'my super description', 308 description: 'my super description',
270 tags: [ 'tag1', 'tag2' ] 309 tags: [ 'tag1', 'tag2' ]
271 } 310 }
@@ -302,6 +341,7 @@ describe('Test videos API validator', function () {
302 341
303 it('Should fail without a valid uuid', function (done) { 342 it('Should fail without a valid uuid', function (done) {
304 const data = { 343 const data = {
344 category: 5,
305 description: 'my super description', 345 description: 'my super description',
306 tags: [ 'tag1', 'tag2' ] 346 tags: [ 'tag1', 'tag2' ]
307 } 347 }
@@ -310,6 +350,7 @@ describe('Test videos API validator', function () {
310 350
311 it('Should fail with an unknown id', function (done) { 351 it('Should fail with an unknown id', function (done) {
312 const data = { 352 const data = {
353 category: 5,
313 description: 'my super description', 354 description: 'my super description',
314 tags: [ 'tag1', 'tag2' ] 355 tags: [ 'tag1', 'tag2' ]
315 } 356 }
@@ -319,6 +360,17 @@ describe('Test videos API validator', function () {
319 it('Should fail with a long name', function (done) { 360 it('Should fail with a long name', function (done) {
320 const data = { 361 const data = {
321 name: 'My very very very very very very very very very very very very very very very very long name', 362 name: 'My very very very very very very very very very very very very very very very very long name',
363 category: 5,
364 description: 'my super description',
365 tags: [ 'tag1', 'tag2' ]
366 }
367 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
368 })
369
370 it('Should fail with a bad category', function (done) {
371 const data = {
372 name: 'my super name',
373 category: 128,
322 description: 'my super description', 374 description: 'my super description',
323 tags: [ 'tag1', 'tag2' ] 375 tags: [ 'tag1', 'tag2' ]
324 } 376 }
@@ -328,6 +380,7 @@ describe('Test videos API validator', function () {
328 it('Should fail with a long description', function (done) { 380 it('Should fail with a long description', function (done) {
329 const data = { 381 const data = {
330 name: 'my super name', 382 name: 'my super name',
383 category: 5,
331 description: 'my super description which is very very very very very very very very very very very very very very' + 384 description: 'my super description which is very very very very very very very very very very very very very very' +
332 'very very very very very very very very very very very very very very very very very very very very very' + 385 'very very very very very very very very very very very very very very very very very very very very very' +
333 'very very very very very very very very very very very very very very very long', 386 'very very very very very very very very very very very very very very very long',
@@ -339,6 +392,7 @@ describe('Test videos API validator', function () {
339 it('Should fail with too many tags', function (done) { 392 it('Should fail with too many tags', function (done) {
340 const data = { 393 const data = {
341 name: 'my super name', 394 name: 'my super name',
395 category: 5,
342 description: 'my super description', 396 description: 'my super description',
343 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] 397 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
344 } 398 }
@@ -348,6 +402,7 @@ describe('Test videos API validator', function () {
348 it('Should fail with not enough tags', function (done) { 402 it('Should fail with not enough tags', function (done) {
349 const data = { 403 const data = {
350 name: 'my super name', 404 name: 'my super name',
405 category: 5,
351 description: 'my super description', 406 description: 'my super description',
352 tags: [ ] 407 tags: [ ]
353 } 408 }
@@ -357,6 +412,7 @@ describe('Test videos API validator', function () {
357 it('Should fail with a tag length too low', function (done) { 412 it('Should fail with a tag length too low', function (done) {
358 const data = { 413 const data = {
359 name: 'my super name', 414 name: 'my super name',
415 category: 5,
360 description: 'my super description', 416 description: 'my super description',
361 tags: [ 'tag1', 't' ] 417 tags: [ 'tag1', 't' ]
362 } 418 }
@@ -366,6 +422,7 @@ describe('Test videos API validator', function () {
366 it('Should fail with a tag length too big', function (done) { 422 it('Should fail with a tag length too big', function (done) {
367 const data = { 423 const data = {
368 name: 'my super name', 424 name: 'my super name',
425 category: 5,
369 description: 'my super description', 426 description: 'my super description',
370 tags: [ 'mysupertagtoolong', 'tag1' ] 427 tags: [ 'mysupertagtoolong', 'tag1' ]
371 } 428 }
@@ -375,6 +432,7 @@ describe('Test videos API validator', function () {
375 it('Should fail with malformed tags', function (done) { 432 it('Should fail with malformed tags', function (done) {
376 const data = { 433 const data = {
377 name: 'my super name', 434 name: 'my super name',
435 category: 5,
378 description: 'my super description', 436 description: 'my super description',
379 tags: [ 'my tag' ] 437 tags: [ 'my tag' ]
380 } 438 }
diff --git a/server/tests/api/friends-advanced.js b/server/tests/api/friends-advanced.js
index 15ca1a37c..584c38c24 100644
--- a/server/tests/api/friends-advanced.js
+++ b/server/tests/api/friends-advanced.js
@@ -32,12 +32,13 @@ describe('Test advanced friends', function () {
32 32
33 function uploadVideo (podNumber, callback) { 33 function uploadVideo (podNumber, callback) {
34 const name = 'my super video' 34 const name = 'my super video'
35 const category = 5
35 const description = 'my super description' 36 const description = 'my super description'
36 const tags = [ 'tag1', 'tag2' ] 37 const tags = [ 'tag1', 'tag2' ]
37 const fixture = 'video_short.webm' 38 const fixture = 'video_short.webm'
38 const server = servers[podNumber - 1] 39 const server = servers[podNumber - 1]
39 40
40 return videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, fixture, callback) 41 return videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, fixture, callback)
41 } 42 }
42 43
43 function getVideos (podNumber, callback) { 44 function getVideos (podNumber, callback) {
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index 552f10c6f..eccc9ecef 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -81,10 +81,11 @@ describe('Test multiple pods', function () {
81 series([ 81 series([
82 function (next) { 82 function (next) {
83 const name = 'my super name for pod 1' 83 const name = 'my super name for pod 1'
84 const category = 5
84 const description = 'my super description for pod 1' 85 const description = 'my super description for pod 1'
85 const tags = [ 'tag1p1', 'tag2p1' ] 86 const tags = [ 'tag1p1', 'tag2p1' ]
86 const file = 'video_short1.webm' 87 const file = 'video_short1.webm'
87 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, description, tags, file, next) 88 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, category, description, tags, file, next)
88 }, 89 },
89 function (next) { 90 function (next) {
90 setTimeout(next, 11000) 91 setTimeout(next, 11000)
@@ -104,6 +105,8 @@ describe('Test multiple pods', function () {
104 expect(videos.length).to.equal(1) 105 expect(videos.length).to.equal(1)
105 const video = videos[0] 106 const video = videos[0]
106 expect(video.name).to.equal('my super name for pod 1') 107 expect(video.name).to.equal('my super name for pod 1')
108 expect(video.category).to.equal(5)
109 expect(video.categoryLabel).to.equal('Sports')
107 expect(video.description).to.equal('my super description for pod 1') 110 expect(video.description).to.equal('my super description for pod 1')
108 expect(video.podHost).to.equal('localhost:9001') 111 expect(video.podHost).to.equal('localhost:9001')
109 expect(video.magnetUri).to.exist 112 expect(video.magnetUri).to.exist
@@ -144,10 +147,11 @@ describe('Test multiple pods', function () {
144 series([ 147 series([
145 function (next) { 148 function (next) {
146 const name = 'my super name for pod 2' 149 const name = 'my super name for pod 2'
150 const category = 4
147 const description = 'my super description for pod 2' 151 const description = 'my super description for pod 2'
148 const tags = [ 'tag1p2', 'tag2p2', 'tag3p2' ] 152 const tags = [ 'tag1p2', 'tag2p2', 'tag3p2' ]
149 const file = 'video_short2.webm' 153 const file = 'video_short2.webm'
150 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, description, tags, file, next) 154 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, category, description, tags, file, next)
151 }, 155 },
152 function (next) { 156 function (next) {
153 setTimeout(next, 11000) 157 setTimeout(next, 11000)
@@ -167,6 +171,8 @@ describe('Test multiple pods', function () {
167 expect(videos.length).to.equal(2) 171 expect(videos.length).to.equal(2)
168 const video = videos[1] 172 const video = videos[1]
169 expect(video.name).to.equal('my super name for pod 2') 173 expect(video.name).to.equal('my super name for pod 2')
174 expect(video.category).to.equal(4)
175 expect(video.categoryLabel).to.equal('Art')
170 expect(video.description).to.equal('my super description for pod 2') 176 expect(video.description).to.equal('my super description for pod 2')
171 expect(video.podHost).to.equal('localhost:9002') 177 expect(video.podHost).to.equal('localhost:9002')
172 expect(video.magnetUri).to.exist 178 expect(video.magnetUri).to.exist
@@ -207,17 +213,19 @@ describe('Test multiple pods', function () {
207 series([ 213 series([
208 function (next) { 214 function (next) {
209 const name = 'my super name for pod 3' 215 const name = 'my super name for pod 3'
216 const category = 6
210 const description = 'my super description for pod 3' 217 const description = 'my super description for pod 3'
211 const tags = [ 'tag1p3' ] 218 const tags = [ 'tag1p3' ]
212 const file = 'video_short3.webm' 219 const file = 'video_short3.webm'
213 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, description, tags, file, next) 220 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, category, description, tags, file, next)
214 }, 221 },
215 function (next) { 222 function (next) {
216 const name = 'my super name for pod 3-2' 223 const name = 'my super name for pod 3-2'
224 const category = 7
217 const description = 'my super description for pod 3-2' 225 const description = 'my super description for pod 3-2'
218 const tags = [ 'tag2p3', 'tag3p3', 'tag4p3' ] 226 const tags = [ 'tag2p3', 'tag3p3', 'tag4p3' ]
219 const file = 'video_short.webm' 227 const file = 'video_short.webm'
220 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, description, tags, file, next) 228 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, category, description, tags, file, next)
221 }, 229 },
222 function (next) { 230 function (next) {
223 setTimeout(next, 22000) 231 setTimeout(next, 22000)
@@ -247,6 +255,8 @@ describe('Test multiple pods', function () {
247 } 255 }
248 256
249 expect(video1.name).to.equal('my super name for pod 3') 257 expect(video1.name).to.equal('my super name for pod 3')
258 expect(video1.category).to.equal(6)
259 expect(video1.categoryLabel).to.equal('Travels')
250 expect(video1.description).to.equal('my super description for pod 3') 260 expect(video1.description).to.equal('my super description for pod 3')
251 expect(video1.podHost).to.equal('localhost:9003') 261 expect(video1.podHost).to.equal('localhost:9003')
252 expect(video1.magnetUri).to.exist 262 expect(video1.magnetUri).to.exist
@@ -257,6 +267,8 @@ describe('Test multiple pods', function () {
257 expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true 267 expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true
258 268
259 expect(video2.name).to.equal('my super name for pod 3-2') 269 expect(video2.name).to.equal('my super name for pod 3-2')
270 expect(video2.category).to.equal(7)
271 expect(video2.categoryLabel).to.equal('Gaming')
260 expect(video2.description).to.equal('my super description for pod 3-2') 272 expect(video2.description).to.equal('my super description for pod 3-2')
261 expect(video2.podHost).to.equal('localhost:9003') 273 expect(video2.podHost).to.equal('localhost:9003')
262 expect(video2.magnetUri).to.exist 274 expect(video2.magnetUri).to.exist
@@ -603,10 +615,11 @@ describe('Test multiple pods', function () {
603 this.timeout(15000) 615 this.timeout(15000)
604 616
605 const name = 'my super video updated' 617 const name = 'my super video updated'
618 const category = 10
606 const description = 'my super description updated' 619 const description = 'my super description updated'
607 const tags = [ 'tagup1', 'tagup2' ] 620 const tags = [ 'tagup1', 'tagup2' ]
608 621
609 videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, name, description, tags, function (err) { 622 videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, name, category, description, tags, function (err) {
610 if (err) throw err 623 if (err) throw err
611 624
612 setTimeout(done, 11000) 625 setTimeout(done, 11000)
@@ -629,6 +642,8 @@ describe('Test multiple pods', function () {
629 }) 642 })
630 643
631 expect(!!videoUpdated).to.be.true 644 expect(!!videoUpdated).to.be.true
645 expect(videoUpdated.category).to.equal(10)
646 expect(videoUpdated.categoryLabel).to.equal('Entertainment')
632 expect(videoUpdated.description).to.equal('my super description updated') 647 expect(videoUpdated.description).to.equal('my super description updated')
633 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) 648 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
634 expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true 649 expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
diff --git a/server/tests/api/requests.js b/server/tests/api/requests.js
index 215c2a8f3..b4b8393e3 100644
--- a/server/tests/api/requests.js
+++ b/server/tests/api/requests.js
@@ -18,11 +18,12 @@ describe('Test requests stats', function () {
18 18
19 function uploadVideo (server, callback) { 19 function uploadVideo (server, callback) {
20 const name = 'my super video' 20 const name = 'my super video'
21 const category = 5
21 const description = 'my super description' 22 const description = 'my super description'
22 const tags = [ 'tag1', 'tag2' ] 23 const tags = [ 'tag1', 'tag2' ]
23 const fixture = 'video_short.webm' 24 const fixture = 'video_short.webm'
24 25
25 videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, fixture, callback) 26 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, fixture, callback)
26 } 27 }
27 28
28 function getRequestsStats (server, callback) { 29 function getRequestsStats (server, callback) {
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js
index 96e4aff9e..d583592d8 100644
--- a/server/tests/api/single-pod.js
+++ b/server/tests/api/single-pod.js
@@ -44,6 +44,19 @@ describe('Test a single pod', function () {
44 ], done) 44 ], done)
45 }) 45 })
46 46
47 it('Should list video categories', function (done) {
48 videosUtils.getVideoCategories(server.url, function (err, res) {
49 if (err) throw err
50
51 const categories = res.body
52 expect(Object.keys(categories)).to.have.length.above(10)
53
54 expect(categories[11]).to.equal('News')
55
56 done()
57 })
58 })
59
47 it('Should not have videos', function (done) { 60 it('Should not have videos', function (done) {
48 videosUtils.getVideosList(server.url, function (err, res) { 61 videosUtils.getVideosList(server.url, function (err, res) {
49 if (err) throw err 62 if (err) throw err
@@ -60,9 +73,10 @@ describe('Test a single pod', function () {
60 this.timeout(5000) 73 this.timeout(5000)
61 const name = 'my super name' 74 const name = 'my super name'
62 const description = 'my super description' 75 const description = 'my super description'
76 const category = 2
63 const tags = [ 'tag1', 'tag2', 'tag3' ] 77 const tags = [ 'tag1', 'tag2', 'tag3' ]
64 const file = 'video_short.webm' 78 const file = 'video_short.webm'
65 videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, file, done) 79 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, done)
66 }) 80 })
67 81
68 it('Should seed the uploaded video', function (done) { 82 it('Should seed the uploaded video', function (done) {
@@ -78,6 +92,8 @@ describe('Test a single pod', function () {
78 92
79 const video = res.body.data[0] 93 const video = res.body.data[0]
80 expect(video.name).to.equal('my super name') 94 expect(video.name).to.equal('my super name')
95 expect(video.category).to.equal(2)
96 expect(video.categoryLabel).to.equal('Films')
81 expect(video.description).to.equal('my super description') 97 expect(video.description).to.equal('my super description')
82 expect(video.podHost).to.equal('localhost:9001') 98 expect(video.podHost).to.equal('localhost:9001')
83 expect(video.magnetUri).to.exist 99 expect(video.magnetUri).to.exist
@@ -113,6 +129,8 @@ describe('Test a single pod', function () {
113 129
114 const video = res.body 130 const video = res.body
115 expect(video.name).to.equal('my super name') 131 expect(video.name).to.equal('my super name')
132 expect(video.category).to.equal(2)
133 expect(video.categoryLabel).to.equal('Films')
116 expect(video.description).to.equal('my super description') 134 expect(video.description).to.equal('my super description')
117 expect(video.podHost).to.equal('localhost:9001') 135 expect(video.podHost).to.equal('localhost:9001')
118 expect(video.magnetUri).to.exist 136 expect(video.magnetUri).to.exist
@@ -152,6 +170,8 @@ describe('Test a single pod', function () {
152 170
153 const video = res.body.data[0] 171 const video = res.body.data[0]
154 expect(video.name).to.equal('my super name') 172 expect(video.name).to.equal('my super name')
173 expect(video.category).to.equal(2)
174 expect(video.categoryLabel).to.equal('Films')
155 expect(video.description).to.equal('my super description') 175 expect(video.description).to.equal('my super description')
156 expect(video.podHost).to.equal('localhost:9001') 176 expect(video.podHost).to.equal('localhost:9001')
157 expect(video.author).to.equal('root') 177 expect(video.author).to.equal('root')
@@ -207,6 +227,8 @@ describe('Test a single pod', function () {
207 227
208 const video = res.body.data[0] 228 const video = res.body.data[0]
209 expect(video.name).to.equal('my super name') 229 expect(video.name).to.equal('my super name')
230 expect(video.category).to.equal(2)
231 expect(video.categoryLabel).to.equal('Films')
210 expect(video.description).to.equal('my super description') 232 expect(video.description).to.equal('my super description')
211 expect(video.podHost).to.equal('localhost:9001') 233 expect(video.podHost).to.equal('localhost:9001')
212 expect(video.author).to.equal('root') 234 expect(video.author).to.equal('root')
@@ -301,9 +323,10 @@ describe('Test a single pod', function () {
301 each(videos, function (video, callbackEach) { 323 each(videos, function (video, callbackEach) {
302 const name = video + ' name' 324 const name = video + ' name'
303 const description = video + ' description' 325 const description = video + ' description'
326 const category = 2
304 const tags = [ 'tag1', 'tag2', 'tag3' ] 327 const tags = [ 'tag1', 'tag2', 'tag3' ]
305 328
306 videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, video, callbackEach) 329 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, video, callbackEach)
307 }, done) 330 }, done)
308 }) 331 })
309 332
@@ -468,7 +491,7 @@ describe('Test a single pod', function () {
468 // }) 491 // })
469 // }) 492 // })
470 493
471 it('Should search the good magnetUri video', function (done) { 494 it('Should search the right magnetUri video', function (done) {
472 const video = videosListBase[0] 495 const video = videosListBase[0]
473 videosUtils.searchVideoWithPagination(server.url, encodeURIComponent(video.magnetUri), 'magnetUri', 0, 15, function (err, res) { 496 videosUtils.searchVideoWithPagination(server.url, encodeURIComponent(video.magnetUri), 'magnetUri', 0, 15, function (err, res) {
474 if (err) throw err 497 if (err) throw err
@@ -521,10 +544,11 @@ describe('Test a single pod', function () {
521 544
522 it('Should update a video', function (done) { 545 it('Should update a video', function (done) {
523 const name = 'my super video updated' 546 const name = 'my super video updated'
547 const category = 4
524 const description = 'my super description updated' 548 const description = 'my super description updated'
525 const tags = [ 'tagup1', 'tagup2' ] 549 const tags = [ 'tagup1', 'tagup2' ]
526 550
527 videosUtils.updateVideo(server.url, server.accessToken, videoId, name, description, tags, done) 551 videosUtils.updateVideo(server.url, server.accessToken, videoId, name, category, description, tags, done)
528 }) 552 })
529 553
530 it('Should have the video updated', function (done) { 554 it('Should have the video updated', function (done) {
@@ -536,6 +560,8 @@ describe('Test a single pod', function () {
536 const video = res.body 560 const video = res.body
537 561
538 expect(video.name).to.equal('my super video updated') 562 expect(video.name).to.equal('my super video updated')
563 expect(video.category).to.equal(4)
564 expect(video.categoryLabel).to.equal('Art')
539 expect(video.description).to.equal('my super description updated') 565 expect(video.description).to.equal('my super description updated')
540 expect(video.podHost).to.equal('localhost:9001') 566 expect(video.podHost).to.equal('localhost:9001')
541 expect(video.author).to.equal('root') 567 expect(video.author).to.equal('root')
@@ -562,7 +588,7 @@ describe('Test a single pod', function () {
562 it('Should update only the tags of a video', function (done) { 588 it('Should update only the tags of a video', function (done) {
563 const tags = [ 'tag1', 'tag2', 'supertag' ] 589 const tags = [ 'tag1', 'tag2', 'supertag' ]
564 590
565 videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, tags, function (err) { 591 videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, null, tags, function (err) {
566 if (err) throw err 592 if (err) throw err
567 593
568 videosUtils.getVideo(server.url, videoId, function (err, res) { 594 videosUtils.getVideo(server.url, videoId, function (err, res) {
@@ -571,6 +597,8 @@ describe('Test a single pod', function () {
571 const video = res.body 597 const video = res.body
572 598
573 expect(video.name).to.equal('my super video updated') 599 expect(video.name).to.equal('my super video updated')
600 expect(video.category).to.equal(4)
601 expect(video.categoryLabel).to.equal('Art')
574 expect(video.description).to.equal('my super description updated') 602 expect(video.description).to.equal('my super description updated')
575 expect(video.podHost).to.equal('localhost:9001') 603 expect(video.podHost).to.equal('localhost:9001')
576 expect(video.author).to.equal('root') 604 expect(video.author).to.equal('root')
@@ -587,7 +615,7 @@ describe('Test a single pod', function () {
587 it('Should update only the description of a video', function (done) { 615 it('Should update only the description of a video', function (done) {
588 const description = 'hello everybody' 616 const description = 'hello everybody'
589 617
590 videosUtils.updateVideo(server.url, server.accessToken, videoId, null, description, null, function (err) { 618 videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, description, null, function (err) {
591 if (err) throw err 619 if (err) throw err
592 620
593 videosUtils.getVideo(server.url, videoId, function (err, res) { 621 videosUtils.getVideo(server.url, videoId, function (err, res) {
@@ -596,6 +624,8 @@ describe('Test a single pod', function () {
596 const video = res.body 624 const video = res.body
597 625
598 expect(video.name).to.equal('my super video updated') 626 expect(video.name).to.equal('my super video updated')
627 expect(video.category).to.equal(4)
628 expect(video.categoryLabel).to.equal('Art')
599 expect(video.description).to.equal('hello everybody') 629 expect(video.description).to.equal('hello everybody')
600 expect(video.podHost).to.equal('localhost:9001') 630 expect(video.podHost).to.equal('localhost:9001')
601 expect(video.author).to.equal('root') 631 expect(video.author).to.equal('root')
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index f9568b874..0f062c11f 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -87,9 +87,10 @@ describe('Test users', function () {
87 87
88 const name = 'my super name' 88 const name = 'my super name'
89 const description = 'my super description' 89 const description = 'my super description'
90 const category = 5
90 const tags = [ 'tag1', 'tag2' ] 91 const tags = [ 'tag1', 'tag2' ]
91 const video = 'video_short.webm' 92 const video = 'video_short.webm'
92 videosUtils.uploadVideo(server.url, accessToken, name, description, tags, video, 401, done) 93 videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 401, done)
93 }) 94 })
94 95
95 it('Should not be able to make friends', function (done) { 96 it('Should not be able to make friends', function (done) {
@@ -113,10 +114,11 @@ describe('Test users', function () {
113 114
114 it('Should upload the video with the correct token', function (done) { 115 it('Should upload the video with the correct token', function (done) {
115 const name = 'my super name' 116 const name = 'my super name'
117 const category = 5
116 const description = 'my super description' 118 const description = 'my super description'
117 const tags = [ 'tag1', 'tag2' ] 119 const tags = [ 'tag1', 'tag2' ]
118 const video = 'video_short.webm' 120 const video = 'video_short.webm'
119 videosUtils.uploadVideo(server.url, accessToken, name, description, tags, video, 204, function (err, res) { 121 videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 204, function (err, res) {
120 if (err) throw err 122 if (err) throw err
121 123
122 videosUtils.getVideosList(server.url, function (err, res) { 124 videosUtils.getVideosList(server.url, function (err, res) {
@@ -133,10 +135,11 @@ describe('Test users', function () {
133 135
134 it('Should upload the video again with the correct token', function (done) { 136 it('Should upload the video again with the correct token', function (done) {
135 const name = 'my super name 2' 137 const name = 'my super name 2'
138 const category = 5
136 const description = 'my super description 2' 139 const description = 'my super description 2'
137 const tags = [ 'tag1' ] 140 const tags = [ 'tag1' ]
138 const video = 'video_short.webm' 141 const video = 'video_short.webm'
139 videosUtils.uploadVideo(server.url, accessToken, name, description, tags, video, 204, done) 142 videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 204, done)
140 }) 143 })
141 144
142 it('Should retrieve a video rating', function (done) { 145 it('Should retrieve a video rating', function (done) {
@@ -228,10 +231,11 @@ describe('Test users', function () {
228 this.timeout(5000) 231 this.timeout(5000)
229 232
230 const name = 'my super name' 233 const name = 'my super name'
234 const category = 5
231 const description = 'my super description' 235 const description = 'my super description'
232 const tags = [ 'tag1', 'tag2', 'tag3' ] 236 const tags = [ 'tag1', 'tag2', 'tag3' ]
233 const file = 'video_short.webm' 237 const file = 'video_short.webm'
234 videosUtils.uploadVideo(server.url, accessTokenUser, name, description, tags, file, done) 238 videosUtils.uploadVideo(server.url, accessTokenUser, name, category, description, tags, file, done)
235 }) 239 })
236 240
237 it('Should list all the users', function (done) { 241 it('Should list all the users', function (done) {
diff --git a/server/tests/api/video-abuse.js b/server/tests/api/video-abuse.js
index 0c4341860..871054788 100644
--- a/server/tests/api/video-abuse.js
+++ b/server/tests/api/video-abuse.js
@@ -46,17 +46,19 @@ describe('Test video abuses', function () {
46 // Upload some videos on each pods 46 // Upload some videos on each pods
47 function (next) { 47 function (next) {
48 const name = 'my super name for pod 1' 48 const name = 'my super name for pod 1'
49 const category = 5
49 const description = 'my super description for pod 1' 50 const description = 'my super description for pod 1'
50 const tags = [ 'tag' ] 51 const tags = [ 'tag' ]
51 const file = 'video_short2.webm' 52 const file = 'video_short2.webm'
52 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, description, tags, file, next) 53 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, category, description, tags, file, next)
53 }, 54 },
54 function (next) { 55 function (next) {
55 const name = 'my super name for pod 2' 56 const name = 'my super name for pod 2'
57 const category = 5
56 const description = 'my super description for pod 2' 58 const description = 'my super description for pod 2'
57 const tags = [ 'tag' ] 59 const tags = [ 'tag' ]
58 const file = 'video_short2.webm' 60 const file = 'video_short2.webm'
59 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, description, tags, file, next) 61 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, category, description, tags, file, next)
60 }, 62 },
61 // Wait videos propagation 63 // Wait videos propagation
62 function (next) { 64 function (next) {