aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/remote/videos.js2
-rw-r--r--server/controllers/api/videos.js7
-rw-r--r--server/helpers/custom-validators/remote/videos.js1
-rw-r--r--server/helpers/custom-validators/videos.js5
-rw-r--r--server/initializers/constants.js21
-rw-r--r--server/initializers/migrations/0050-video-language.js19
-rw-r--r--server/middlewares/validators/videos.js2
-rw-r--r--server/models/video.js19
-rw-r--r--server/tests/api/check-params/videos.js56
-rw-r--r--server/tests/api/multiple-pods.js15
-rw-r--r--server/tests/api/single-pod.js29
-rw-r--r--server/tests/real-world/real-world.js3
-rw-r--r--server/tests/real-world/tools/upload.js6
-rw-r--r--server/tests/utils/videos.js15
14 files changed, 197 insertions, 3 deletions
diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js
index ea1eeb146..e54793628 100644
--- a/server/controllers/api/remote/videos.js
+++ b/server/controllers/api/remote/videos.js
@@ -296,6 +296,7 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
296 infoHash: videoToCreateData.infoHash, 296 infoHash: videoToCreateData.infoHash,
297 category: videoToCreateData.category, 297 category: videoToCreateData.category,
298 licence: videoToCreateData.licence, 298 licence: videoToCreateData.licence,
299 language: videoToCreateData.language,
299 nsfw: videoToCreateData.nsfw, 300 nsfw: videoToCreateData.nsfw,
300 description: videoToCreateData.description, 301 description: videoToCreateData.description,
301 authorId: author.id, 302 authorId: author.id,
@@ -395,6 +396,7 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) {
395 videoInstance.set('name', videoAttributesToUpdate.name) 396 videoInstance.set('name', videoAttributesToUpdate.name)
396 videoInstance.set('category', videoAttributesToUpdate.category) 397 videoInstance.set('category', videoAttributesToUpdate.category)
397 videoInstance.set('licence', videoAttributesToUpdate.licence) 398 videoInstance.set('licence', videoAttributesToUpdate.licence)
399 videoInstance.set('language', videoAttributesToUpdate.language)
398 videoInstance.set('nsfw', videoAttributesToUpdate.nsfw) 400 videoInstance.set('nsfw', videoAttributesToUpdate.nsfw)
399 videoInstance.set('description', videoAttributesToUpdate.description) 401 videoInstance.set('description', videoAttributesToUpdate.description)
400 videoInstance.set('infoHash', videoAttributesToUpdate.infoHash) 402 videoInstance.set('infoHash', videoAttributesToUpdate.infoHash)
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js
index 3d616e33d..5e9ff482f 100644
--- a/server/controllers/api/videos.js
+++ b/server/controllers/api/videos.js
@@ -47,6 +47,7 @@ const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCo
47 47
48router.get('/categories', listVideoCategories) 48router.get('/categories', listVideoCategories)
49router.get('/licences', listVideoLicences) 49router.get('/licences', listVideoLicences)
50router.get('/languages', listVideoLanguages)
50 51
51router.get('/abuse', 52router.get('/abuse',
52 oAuth.authenticate, 53 oAuth.authenticate,
@@ -121,6 +122,10 @@ function listVideoLicences (req, res, next) {
121 res.json(constants.VIDEO_LICENCES) 122 res.json(constants.VIDEO_LICENCES)
122} 123}
123 124
125function listVideoLanguages (req, res, next) {
126 res.json(constants.VIDEO_LANGUAGES)
127}
128
124function rateVideoRetryWrapper (req, res, next) { 129function rateVideoRetryWrapper (req, res, next) {
125 const options = { 130 const options = {
126 arguments: [ req, res ], 131 arguments: [ req, res ],
@@ -313,6 +318,7 @@ function addVideo (req, res, videoFile, finalCallback) {
313 extname: path.extname(videoFile.filename), 318 extname: path.extname(videoFile.filename),
314 category: videoInfos.category, 319 category: videoInfos.category,
315 licence: videoInfos.licence, 320 licence: videoInfos.licence,
321 language: videoInfos.language,
316 nsfw: videoInfos.nsfw, 322 nsfw: videoInfos.nsfw,
317 description: videoInfos.description, 323 description: videoInfos.description,
318 duration: videoFile.duration, 324 duration: videoFile.duration,
@@ -429,6 +435,7 @@ function updateVideo (req, res, finalCallback) {
429 if (videoInfosToUpdate.name) videoInstance.set('name', videoInfosToUpdate.name) 435 if (videoInfosToUpdate.name) videoInstance.set('name', videoInfosToUpdate.name)
430 if (videoInfosToUpdate.category) videoInstance.set('category', videoInfosToUpdate.category) 436 if (videoInfosToUpdate.category) videoInstance.set('category', videoInfosToUpdate.category)
431 if (videoInfosToUpdate.licence) videoInstance.set('licence', videoInfosToUpdate.licence) 437 if (videoInfosToUpdate.licence) videoInstance.set('licence', videoInfosToUpdate.licence)
438 if (videoInfosToUpdate.language) videoInstance.set('language', videoInfosToUpdate.language)
432 if (videoInfosToUpdate.nsfw) videoInstance.set('nsfw', videoInfosToUpdate.nsfw) 439 if (videoInfosToUpdate.nsfw) videoInstance.set('nsfw', videoInfosToUpdate.nsfw)
433 if (videoInfosToUpdate.description) videoInstance.set('description', videoInfosToUpdate.description) 440 if (videoInfosToUpdate.description) videoInstance.set('description', videoInfosToUpdate.description)
434 441
diff --git a/server/helpers/custom-validators/remote/videos.js b/server/helpers/custom-validators/remote/videos.js
index df8f8a22e..24715b4b3 100644
--- a/server/helpers/custom-validators/remote/videos.js
+++ b/server/helpers/custom-validators/remote/videos.js
@@ -87,6 +87,7 @@ function isCommonVideoAttributesValid (video) {
87 videosValidators.isVideoDateValid(video.updatedAt) && 87 videosValidators.isVideoDateValid(video.updatedAt) &&
88 videosValidators.isVideoCategoryValid(video.category) && 88 videosValidators.isVideoCategoryValid(video.category) &&
89 videosValidators.isVideoLicenceValid(video.licence) && 89 videosValidators.isVideoLicenceValid(video.licence) &&
90 videosValidators.isVideoLanguageValid(video.language) &&
90 videosValidators.isVideoNSFWValid(video.nsfw) && 91 videosValidators.isVideoNSFWValid(video.nsfw) &&
91 videosValidators.isVideoDescriptionValid(video.description) && 92 videosValidators.isVideoDescriptionValid(video.description) &&
92 videosValidators.isVideoDurationValid(video.duration) && 93 videosValidators.isVideoDurationValid(video.duration) &&
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js
index d0b08e7ac..8dabb828d 100644
--- a/server/helpers/custom-validators/videos.js
+++ b/server/helpers/custom-validators/videos.js
@@ -15,6 +15,7 @@ const videosValidators = {
15 isVideoDateValid, 15 isVideoDateValid,
16 isVideoCategoryValid, 16 isVideoCategoryValid,
17 isVideoLicenceValid, 17 isVideoLicenceValid,
18 isVideoLanguageValid,
18 isVideoNSFWValid, 19 isVideoNSFWValid,
19 isVideoDescriptionValid, 20 isVideoDescriptionValid,
20 isVideoDurationValid, 21 isVideoDurationValid,
@@ -51,6 +52,10 @@ function isVideoLicenceValid (value) {
51 return constants.VIDEO_LICENCES[value] !== undefined 52 return constants.VIDEO_LICENCES[value] !== undefined
52} 53}
53 54
55function isVideoLanguageValid (value) {
56 return constants.VIDEO_LANGUAGES[value] !== undefined
57}
58
54function isVideoNSFWValid (value) { 59function isVideoNSFWValid (value) {
55 return validator.isBoolean(value) 60 return validator.isBoolean(value)
56} 61}
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 6352d7c46..d6da20982 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -5,7 +5,7 @@ const path = require('path')
5 5
6// --------------------------------------------------------------------------- 6// ---------------------------------------------------------------------------
7 7
8const LAST_MIGRATION_VERSION = 45 8const LAST_MIGRATION_VERSION = 50
9 9
10// --------------------------------------------------------------------------- 10// ---------------------------------------------------------------------------
11 11
@@ -135,6 +135,24 @@ const VIDEO_LICENCES = {
135 7: 'Public Domain Dedication' 135 7: 'Public Domain Dedication'
136} 136}
137 137
138// See https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers#Nationalencyklopedin
139const VIDEO_LANGUAGES = {
140 1: 'English',
141 2: 'Spanish',
142 3: 'Mandarin',
143 4: 'Hindi',
144 5: 'Arabic',
145 6: 'Portuguese',
146 7: 'Bengali',
147 8: 'Russian',
148 9: 'Japanese',
149 10: 'Punjabi',
150 11: 'German',
151 12: 'Korean',
152 13: 'French',
153 14: 'Italien'
154}
155
138// --------------------------------------------------------------------------- 156// ---------------------------------------------------------------------------
139 157
140// Score a pod has when we create it as a friend 158// Score a pod has when we create it as a friend
@@ -291,6 +309,7 @@ module.exports = {
291 THUMBNAILS_SIZE, 309 THUMBNAILS_SIZE,
292 USER_ROLES, 310 USER_ROLES,
293 VIDEO_CATEGORIES, 311 VIDEO_CATEGORIES,
312 VIDEO_LANGUAGES,
294 VIDEO_LICENCES, 313 VIDEO_LICENCES,
295 VIDEO_RATE_TYPES 314 VIDEO_RATE_TYPES
296} 315}
diff --git a/server/initializers/migrations/0050-video-language.js b/server/initializers/migrations/0050-video-language.js
new file mode 100644
index 000000000..1c978758d
--- /dev/null
+++ b/server/initializers/migrations/0050-video-language.js
@@ -0,0 +1,19 @@
1'use strict'
2
3// utils = { transaction, queryInterface, sequelize, Sequelize }
4exports.up = function (utils, finalCallback) {
5 const q = utils.queryInterface
6 const Sequelize = utils.Sequelize
7
8 const data = {
9 type: Sequelize.INTEGER,
10 allowNull: true,
11 defaultValue: null
12 }
13
14 q.addColumn('Videos', 'language', data, { transaction: utils.transaction }).asCallback(finalCallback)
15}
16
17exports.down = function (options, callback) {
18 throw new Error('Not implemented.')
19}
diff --git a/server/middlewares/validators/videos.js b/server/middlewares/validators/videos.js
index 095fc382b..c07825e50 100644
--- a/server/middlewares/validators/videos.js
+++ b/server/middlewares/validators/videos.js
@@ -23,6 +23,7 @@ function videosAdd (req, res, next) {
23 req.checkBody('name', 'Should have a valid name').isVideoNameValid() 23 req.checkBody('name', 'Should have a valid name').isVideoNameValid()
24 req.checkBody('category', 'Should have a valid category').isVideoCategoryValid() 24 req.checkBody('category', 'Should have a valid category').isVideoCategoryValid()
25 req.checkBody('licence', 'Should have a valid licence').isVideoLicenceValid() 25 req.checkBody('licence', 'Should have a valid licence').isVideoLicenceValid()
26 req.checkBody('language', 'Should have a valid language').optional().isVideoLanguageValid()
26 req.checkBody('nsfw', 'Should have a valid NSFW attribute').isVideoNSFWValid() 27 req.checkBody('nsfw', 'Should have a valid NSFW attribute').isVideoNSFWValid()
27 req.checkBody('description', 'Should have a valid description').isVideoDescriptionValid() 28 req.checkBody('description', 'Should have a valid description').isVideoDescriptionValid()
28 req.checkBody('tags', 'Should have correct tags').optional().isVideoTagsValid() 29 req.checkBody('tags', 'Should have correct tags').optional().isVideoTagsValid()
@@ -52,6 +53,7 @@ function videosUpdate (req, res, next) {
52 req.checkBody('name', 'Should have a valid name').optional().isVideoNameValid() 53 req.checkBody('name', 'Should have a valid name').optional().isVideoNameValid()
53 req.checkBody('category', 'Should have a valid category').optional().isVideoCategoryValid() 54 req.checkBody('category', 'Should have a valid category').optional().isVideoCategoryValid()
54 req.checkBody('licence', 'Should have a valid licence').optional().isVideoLicenceValid() 55 req.checkBody('licence', 'Should have a valid licence').optional().isVideoLicenceValid()
56 req.checkBody('language', 'Should have a valid language').optional().isVideoLanguageValid()
55 req.checkBody('nsfw', 'Should have a valid NSFW attribute').optional().isVideoNSFWValid() 57 req.checkBody('nsfw', 'Should have a valid NSFW attribute').optional().isVideoNSFWValid()
56 req.checkBody('description', 'Should have a valid description').optional().isVideoDescriptionValid() 58 req.checkBody('description', 'Should have a valid description').optional().isVideoDescriptionValid()
57 req.checkBody('tags', 'Should have correct tags').optional().isVideoTagsValid() 59 req.checkBody('tags', 'Should have correct tags').optional().isVideoTagsValid()
diff --git a/server/models/video.js b/server/models/video.js
index 86d6438c8..39eb28ed9 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -64,6 +64,7 @@ module.exports = function (sequelize, DataTypes) {
64 licence: { 64 licence: {
65 type: DataTypes.INTEGER, 65 type: DataTypes.INTEGER,
66 allowNull: false, 66 allowNull: false,
67 defaultValue: null,
67 validate: { 68 validate: {
68 licenceValid: function (value) { 69 licenceValid: function (value) {
69 const res = customVideosValidators.isVideoLicenceValid(value) 70 const res = customVideosValidators.isVideoLicenceValid(value)
@@ -71,6 +72,16 @@ module.exports = function (sequelize, DataTypes) {
71 } 72 }
72 } 73 }
73 }, 74 },
75 language: {
76 type: DataTypes.INTEGER,
77 allowNull: true,
78 validate: {
79 languageValid: function (value) {
80 const res = customVideosValidators.isVideoLanguageValid(value)
81 if (res === false) throw new Error('Video language is not valid.')
82 }
83 }
84 },
74 nsfw: { 85 nsfw: {
75 type: DataTypes.BOOLEAN, 86 type: DataTypes.BOOLEAN,
76 allowNull: false, 87 allowNull: false,
@@ -398,6 +409,10 @@ function toFormatedJSON () {
398 let licenceLabel = constants.VIDEO_LICENCES[this.licence] 409 let licenceLabel = constants.VIDEO_LICENCES[this.licence]
399 if (!licenceLabel) licenceLabel = 'Unknown' 410 if (!licenceLabel) licenceLabel = 'Unknown'
400 411
412 // Language is an optional attribute
413 let languageLabel = constants.VIDEO_LANGUAGES[this.language]
414 if (!languageLabel) languageLabel = 'Unknown'
415
401 const json = { 416 const json = {
402 id: this.id, 417 id: this.id,
403 name: this.name, 418 name: this.name,
@@ -405,6 +420,8 @@ function toFormatedJSON () {
405 categoryLabel, 420 categoryLabel,
406 licence: this.licence, 421 licence: this.licence,
407 licenceLabel, 422 licenceLabel,
423 language: this.language,
424 languageLabel,
408 nsfw: this.nsfw, 425 nsfw: this.nsfw,
409 description: this.description, 426 description: this.description,
410 podHost, 427 podHost,
@@ -439,6 +456,7 @@ function toAddRemoteJSON (callback) {
439 name: self.name, 456 name: self.name,
440 category: self.category, 457 category: self.category,
441 licence: self.licence, 458 licence: self.licence,
459 language: self.language,
442 nsfw: self.nsfw, 460 nsfw: self.nsfw,
443 description: self.description, 461 description: self.description,
444 infoHash: self.infoHash, 462 infoHash: self.infoHash,
@@ -464,6 +482,7 @@ function toUpdateRemoteJSON (callback) {
464 name: this.name, 482 name: this.name,
465 category: this.category, 483 category: this.category,
466 licence: this.licence, 484 licence: this.licence,
485 language: this.language,
467 nsfw: this.nsfw, 486 nsfw: this.nsfw,
468 description: this.description, 487 description: this.description,
469 infoHash: this.infoHash, 488 infoHash: this.infoHash,
diff --git a/server/tests/api/check-params/videos.js b/server/tests/api/check-params/videos.js
index 551fe687b..1a24d26cc 100644
--- a/server/tests/api/check-params/videos.js
+++ b/server/tests/api/check-params/videos.js
@@ -114,6 +114,7 @@ describe('Test videos API validator', function () {
114 const data = { 114 const data = {
115 category: 5, 115 category: 5,
116 licence: 1, 116 licence: 1,
117 language: 6,
117 nsfw: false, 118 nsfw: false,
118 description: 'my super description', 119 description: 'my super description',
119 tags: [ 'tag1', 'tag2' ] 120 tags: [ 'tag1', 'tag2' ]
@@ -129,6 +130,7 @@ describe('Test videos API validator', function () {
129 name: 'My very very very very very very very very very very very very very very very very long name', 130 name: 'My very very very very very very very very very very very very very very very very long name',
130 category: 5, 131 category: 5,
131 licence: 1, 132 licence: 1,
133 language: 6,
132 nsfw: false, 134 nsfw: false,
133 description: 'my super description', 135 description: 'my super description',
134 tags: [ 'tag1', 'tag2' ] 136 tags: [ 'tag1', 'tag2' ]
@@ -143,6 +145,7 @@ describe('Test videos API validator', function () {
143 const data = { 145 const data = {
144 name: 'my super name', 146 name: 'my super name',
145 licence: 1, 147 licence: 1,
148 language: 6,
146 nsfw: false, 149 nsfw: false,
147 description: 'my super description', 150 description: 'my super description',
148 tags: [ 'tag1', 'tag2' ] 151 tags: [ 'tag1', 'tag2' ]
@@ -158,6 +161,7 @@ describe('Test videos API validator', function () {
158 name: 'my super name', 161 name: 'my super name',
159 category: 125, 162 category: 125,
160 licence: 1, 163 licence: 1,
164 language: 6,
161 nsfw: false, 165 nsfw: false,
162 description: 'my super description', 166 description: 'my super description',
163 tags: [ 'tag1', 'tag2' ] 167 tags: [ 'tag1', 'tag2' ]
@@ -172,6 +176,7 @@ describe('Test videos API validator', function () {
172 const data = { 176 const data = {
173 name: 'my super name', 177 name: 'my super name',
174 category: 5, 178 category: 5,
179 language: 6,
175 nsfw: false, 180 nsfw: false,
176 description: 'my super description', 181 description: 'my super description',
177 tags: [ 'tag1', 'tag2' ] 182 tags: [ 'tag1', 'tag2' ]
@@ -187,6 +192,23 @@ describe('Test videos API validator', function () {
187 name: 'my super name', 192 name: 'my super name',
188 category: 5, 193 category: 5,
189 licence: 125, 194 licence: 125,
195 language: 6,
196 nsfw: false,
197 description: 'my super description',
198 tags: [ 'tag1', 'tag2' ]
199 }
200 const attach = {
201 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
202 }
203 requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
204 })
205
206 it('Should fail with a bad language', function (done) {
207 const data = {
208 name: 'my super name',
209 category: 5,
210 licence: 4,
211 language: 563,
190 nsfw: false, 212 nsfw: false,
191 description: 'my super description', 213 description: 'my super description',
192 tags: [ 'tag1', 'tag2' ] 214 tags: [ 'tag1', 'tag2' ]
@@ -202,6 +224,7 @@ describe('Test videos API validator', function () {
202 name: 'my super name', 224 name: 'my super name',
203 category: 5, 225 category: 5,
204 licence: 4, 226 licence: 4,
227 language: 6,
205 description: 'my super description', 228 description: 'my super description',
206 tags: [ 'tag1', 'tag2' ] 229 tags: [ 'tag1', 'tag2' ]
207 } 230 }
@@ -216,6 +239,7 @@ describe('Test videos API validator', function () {
216 name: 'my super name', 239 name: 'my super name',
217 category: 5, 240 category: 5,
218 licence: 4, 241 licence: 4,
242 language: 6,
219 nsfw: 2, 243 nsfw: 2,
220 description: 'my super description', 244 description: 'my super description',
221 tags: [ 'tag1', 'tag2' ] 245 tags: [ 'tag1', 'tag2' ]
@@ -231,6 +255,7 @@ describe('Test videos API validator', function () {
231 name: 'my super name', 255 name: 'my super name',
232 category: 5, 256 category: 5,
233 licence: 1, 257 licence: 1,
258 language: 6,
234 nsfw: false, 259 nsfw: false,
235 tags: [ 'tag1', 'tag2' ] 260 tags: [ 'tag1', 'tag2' ]
236 } 261 }
@@ -245,6 +270,7 @@ describe('Test videos API validator', function () {
245 name: 'my super name', 270 name: 'my super name',
246 category: 5, 271 category: 5,
247 licence: 1, 272 licence: 1,
273 language: 6,
248 nsfw: false, 274 nsfw: false,
249 description: 'my super description which is very very very very very very very very very very very very very very' + 275 description: 'my super description which is very very very very very very very very very very very very very very' +
250 'very very very very very very very very very very very very very very very very very very very very very' + 276 'very very very very very very very very very very very very very very very very very very very very very' +
@@ -262,6 +288,7 @@ describe('Test videos API validator', function () {
262 name: 'my super name', 288 name: 'my super name',
263 category: 5, 289 category: 5,
264 licence: 1, 290 licence: 1,
291 language: 6,
265 nsfw: false, 292 nsfw: false,
266 description: 'my super description', 293 description: 'my super description',
267 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] 294 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
@@ -277,6 +304,7 @@ describe('Test videos API validator', function () {
277 name: 'my super name', 304 name: 'my super name',
278 category: 5, 305 category: 5,
279 licence: 1, 306 licence: 1,
307 language: 6,
280 nsfw: false, 308 nsfw: false,
281 description: 'my super description', 309 description: 'my super description',
282 tags: [ 'tag1', 't' ] 310 tags: [ 'tag1', 't' ]
@@ -292,6 +320,7 @@ describe('Test videos API validator', function () {
292 name: 'my super name', 320 name: 'my super name',
293 category: 5, 321 category: 5,
294 licence: 1, 322 licence: 1,
323 language: 6,
295 nsfw: false, 324 nsfw: false,
296 description: 'my super description', 325 description: 'my super description',
297 tags: [ 'mysupertagtoolong', 'tag1' ] 326 tags: [ 'mysupertagtoolong', 'tag1' ]
@@ -307,6 +336,7 @@ describe('Test videos API validator', function () {
307 name: 'my super name', 336 name: 'my super name',
308 category: 5, 337 category: 5,
309 licence: 1, 338 licence: 1,
339 language: 6,
310 nsfw: false, 340 nsfw: false,
311 description: 'my super description', 341 description: 'my super description',
312 tags: [ 'tag1', 'tag2' ] 342 tags: [ 'tag1', 'tag2' ]
@@ -320,6 +350,7 @@ describe('Test videos API validator', function () {
320 name: 'my super name', 350 name: 'my super name',
321 category: 5, 351 category: 5,
322 licence: 1, 352 licence: 1,
353 language: 6,
323 nsfw: false, 354 nsfw: false,
324 description: 'my super description', 355 description: 'my super description',
325 tags: [ 'tag1', 'tag2' ] 356 tags: [ 'tag1', 'tag2' ]
@@ -335,6 +366,7 @@ describe('Test videos API validator', function () {
335 name: 'my super name', 366 name: 'my super name',
336 category: 5, 367 category: 5,
337 licence: 1, 368 licence: 1,
369 language: 6,
338 nsfw: false, 370 nsfw: false,
339 description: 'my super description', 371 description: 'my super description',
340 tags: [ 'tag1', 'tag2' ] 372 tags: [ 'tag1', 'tag2' ]
@@ -350,6 +382,7 @@ describe('Test videos API validator', function () {
350 name: 'my super name', 382 name: 'my super name',
351 category: 5, 383 category: 5,
352 licence: 1, 384 licence: 1,
385 language: 6,
353 nsfw: false, 386 nsfw: false,
354 description: 'my super description', 387 description: 'my super description',
355 tags: [ 'tag1', 'tag2' ] 388 tags: [ 'tag1', 'tag2' ]
@@ -389,6 +422,7 @@ describe('Test videos API validator', function () {
389 const data = { 422 const data = {
390 category: 5, 423 category: 5,
391 licence: 2, 424 licence: 2,
425 language: 6,
392 nsfw: false, 426 nsfw: false,
393 description: 'my super description', 427 description: 'my super description',
394 tags: [ 'tag1', 'tag2' ] 428 tags: [ 'tag1', 'tag2' ]
@@ -400,6 +434,7 @@ describe('Test videos API validator', function () {
400 const data = { 434 const data = {
401 category: 5, 435 category: 5,
402 licence: 2, 436 licence: 2,
437 language: 6,
403 nsfw: false, 438 nsfw: false,
404 description: 'my super description', 439 description: 'my super description',
405 tags: [ 'tag1', 'tag2' ] 440 tags: [ 'tag1', 'tag2' ]
@@ -412,6 +447,7 @@ describe('Test videos API validator', function () {
412 name: 'My very very very very very very very very very very very very very very very very long name', 447 name: 'My very very very very very very very very very very very very very very very very long name',
413 category: 5, 448 category: 5,
414 licence: 2, 449 licence: 2,
450 language: 6,
415 nsfw: false, 451 nsfw: false,
416 description: 'my super description', 452 description: 'my super description',
417 tags: [ 'tag1', 'tag2' ] 453 tags: [ 'tag1', 'tag2' ]
@@ -424,6 +460,7 @@ describe('Test videos API validator', function () {
424 name: 'my super name', 460 name: 'my super name',
425 category: 128, 461 category: 128,
426 licence: 2, 462 licence: 2,
463 language: 6,
427 nsfw: false, 464 nsfw: false,
428 description: 'my super description', 465 description: 'my super description',
429 tags: [ 'tag1', 'tag2' ] 466 tags: [ 'tag1', 'tag2' ]
@@ -436,6 +473,20 @@ describe('Test videos API validator', function () {
436 name: 'my super name', 473 name: 'my super name',
437 category: 5, 474 category: 5,
438 licence: 128, 475 licence: 128,
476 language: 6,
477 nsfw: false,
478 description: 'my super description',
479 tags: [ 'tag1', 'tag2' ]
480 }
481 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
482 })
483
484 it('Should fail with a bad language', function (done) {
485 const data = {
486 name: 'my super name',
487 category: 5,
488 licence: 3,
489 language: 896,
439 nsfw: false, 490 nsfw: false,
440 description: 'my super description', 491 description: 'my super description',
441 tags: [ 'tag1', 'tag2' ] 492 tags: [ 'tag1', 'tag2' ]
@@ -448,6 +499,7 @@ describe('Test videos API validator', function () {
448 name: 'my super name', 499 name: 'my super name',
449 category: 5, 500 category: 5,
450 licence: 5, 501 licence: 5,
502 language: 6,
451 nsfw: -4, 503 nsfw: -4,
452 description: 'my super description', 504 description: 'my super description',
453 tags: [ 'tag1', 'tag2' ] 505 tags: [ 'tag1', 'tag2' ]
@@ -460,6 +512,7 @@ describe('Test videos API validator', function () {
460 name: 'my super name', 512 name: 'my super name',
461 category: 5, 513 category: 5,
462 licence: 2, 514 licence: 2,
515 language: 6,
463 nsfw: false, 516 nsfw: false,
464 description: 'my super description which is very very very very very very very very very very very very very very' + 517 description: 'my super description which is very very very very very very very very very very very very very very' +
465 'very very very very very very very very very very very very very very very very very very very very very' + 518 'very very very very very very very very very very very very very very very very very very very very very' +
@@ -474,6 +527,7 @@ describe('Test videos API validator', function () {
474 name: 'my super name', 527 name: 'my super name',
475 category: 5, 528 category: 5,
476 licence: 2, 529 licence: 2,
530 language: 6,
477 nsfw: false, 531 nsfw: false,
478 description: 'my super description', 532 description: 'my super description',
479 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] 533 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
@@ -486,6 +540,7 @@ describe('Test videos API validator', function () {
486 name: 'my super name', 540 name: 'my super name',
487 category: 5, 541 category: 5,
488 licence: 2, 542 licence: 2,
543 language: 6,
489 nsfw: false, 544 nsfw: false,
490 description: 'my super description', 545 description: 'my super description',
491 tags: [ 'tag1', 't' ] 546 tags: [ 'tag1', 't' ]
@@ -498,6 +553,7 @@ describe('Test videos API validator', function () {
498 name: 'my super name', 553 name: 'my super name',
499 category: 5, 554 category: 5,
500 licence: 2, 555 licence: 2,
556 language: 6,
501 nsfw: false, 557 nsfw: false,
502 description: 'my super description', 558 description: 'my super description',
503 tags: [ 'mysupertagtoolong', 'tag1' ] 559 tags: [ 'mysupertagtoolong', 'tag1' ]
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index cc4f7be70..45969e83a 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -84,6 +84,7 @@ describe('Test multiple pods', function () {
84 name: 'my super name for pod 1', 84 name: 'my super name for pod 1',
85 category: 5, 85 category: 5,
86 licence: 4, 86 licence: 4,
87 language: 9,
87 nsfw: true, 88 nsfw: true,
88 description: 'my super description for pod 1', 89 description: 'my super description for pod 1',
89 tags: [ 'tag1p1', 'tag2p1' ], 90 tags: [ 'tag1p1', 'tag2p1' ],
@@ -113,6 +114,8 @@ describe('Test multiple pods', function () {
113 expect(video.categoryLabel).to.equal('Sports') 114 expect(video.categoryLabel).to.equal('Sports')
114 expect(video.licence).to.equal(4) 115 expect(video.licence).to.equal(4)
115 expect(video.licenceLabel).to.equal('Attribution - Non Commercial') 116 expect(video.licenceLabel).to.equal('Attribution - Non Commercial')
117 expect(video.language).to.equal(9)
118 expect(video.languageLabel).to.equal('Japanese')
116 expect(video.nsfw).to.be.truthy 119 expect(video.nsfw).to.be.truthy
117 expect(video.description).to.equal('my super description for pod 1') 120 expect(video.description).to.equal('my super description for pod 1')
118 expect(video.podHost).to.equal('localhost:9001') 121 expect(video.podHost).to.equal('localhost:9001')
@@ -157,6 +160,7 @@ describe('Test multiple pods', function () {
157 name: 'my super name for pod 2', 160 name: 'my super name for pod 2',
158 category: 4, 161 category: 4,
159 licence: 3, 162 licence: 3,
163 language: 11,
160 nsfw: true, 164 nsfw: true,
161 description: 'my super description for pod 2', 165 description: 'my super description for pod 2',
162 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], 166 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
@@ -186,6 +190,8 @@ describe('Test multiple pods', function () {
186 expect(video.categoryLabel).to.equal('Art') 190 expect(video.categoryLabel).to.equal('Art')
187 expect(video.licence).to.equal(3) 191 expect(video.licence).to.equal(3)
188 expect(video.licenceLabel).to.equal('Attribution - No Derivatives') 192 expect(video.licenceLabel).to.equal('Attribution - No Derivatives')
193 expect(video.language).to.equal(11)
194 expect(video.languageLabel).to.equal('German')
189 expect(video.nsfw).to.be.falsy 195 expect(video.nsfw).to.be.falsy
190 expect(video.description).to.equal('my super description for pod 2') 196 expect(video.description).to.equal('my super description for pod 2')
191 expect(video.podHost).to.equal('localhost:9002') 197 expect(video.podHost).to.equal('localhost:9002')
@@ -230,6 +236,7 @@ describe('Test multiple pods', function () {
230 name: 'my super name for pod 3', 236 name: 'my super name for pod 3',
231 category: 6, 237 category: 6,
232 licence: 5, 238 licence: 5,
239 language: 11,
233 nsfw: true, 240 nsfw: true,
234 description: 'my super description for pod 3', 241 description: 'my super description for pod 3',
235 tags: [ 'tag1p3' ], 242 tags: [ 'tag1p3' ],
@@ -242,6 +249,7 @@ describe('Test multiple pods', function () {
242 name: 'my super name for pod 3-2', 249 name: 'my super name for pod 3-2',
243 category: 7, 250 category: 7,
244 licence: 6, 251 licence: 6,
252 language: 12,
245 nsfw: false, 253 nsfw: false,
246 description: 'my super description for pod 3-2', 254 description: 'my super description for pod 3-2',
247 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 255 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
@@ -281,6 +289,8 @@ describe('Test multiple pods', function () {
281 expect(video1.categoryLabel).to.equal('Travels') 289 expect(video1.categoryLabel).to.equal('Travels')
282 expect(video1.licence).to.equal(5) 290 expect(video1.licence).to.equal(5)
283 expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike') 291 expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike')
292 expect(video1.language).to.equal(11)
293 expect(video1.languageLabel).to.equal('German')
284 expect(video1.nsfw).to.be.truthy 294 expect(video1.nsfw).to.be.truthy
285 expect(video1.description).to.equal('my super description for pod 3') 295 expect(video1.description).to.equal('my super description for pod 3')
286 expect(video1.podHost).to.equal('localhost:9003') 296 expect(video1.podHost).to.equal('localhost:9003')
@@ -296,6 +306,8 @@ describe('Test multiple pods', function () {
296 expect(video2.categoryLabel).to.equal('Gaming') 306 expect(video2.categoryLabel).to.equal('Gaming')
297 expect(video2.licence).to.equal(6) 307 expect(video2.licence).to.equal(6)
298 expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') 308 expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
309 expect(video2.language).to.equal(12)
310 expect(video2.languageLabel).to.equal('Korean')
299 expect(video2.nsfw).to.be.falsy 311 expect(video2.nsfw).to.be.falsy
300 expect(video2.description).to.equal('my super description for pod 3-2') 312 expect(video2.description).to.equal('my super description for pod 3-2')
301 expect(video2.podHost).to.equal('localhost:9003') 313 expect(video2.podHost).to.equal('localhost:9003')
@@ -646,6 +658,7 @@ describe('Test multiple pods', function () {
646 name: 'my super video updated', 658 name: 'my super video updated',
647 category: 10, 659 category: 10,
648 licence: 7, 660 licence: 7,
661 language: 13,
649 nsfw: true, 662 nsfw: true,
650 description: 'my super description updated', 663 description: 'my super description updated',
651 tags: [ 'tagup1', 'tagup2' ] 664 tags: [ 'tagup1', 'tagup2' ]
@@ -677,6 +690,8 @@ describe('Test multiple pods', function () {
677 expect(videoUpdated.categoryLabel).to.equal('Entertainment') 690 expect(videoUpdated.categoryLabel).to.equal('Entertainment')
678 expect(videoUpdated.licence).to.equal(7) 691 expect(videoUpdated.licence).to.equal(7)
679 expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication') 692 expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication')
693 expect(videoUpdated.language).to.equal(13)
694 expect(videoUpdated.languageLabel).to.equal('French')
680 expect(videoUpdated.nsfw).to.be.truthy 695 expect(videoUpdated.nsfw).to.be.truthy
681 expect(videoUpdated.description).to.equal('my super description updated') 696 expect(videoUpdated.description).to.equal('my super description updated')
682 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) 697 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js
index aff6d56ec..fe388698f 100644
--- a/server/tests/api/single-pod.js
+++ b/server/tests/api/single-pod.js
@@ -70,6 +70,19 @@ describe('Test a single pod', function () {
70 }) 70 })
71 }) 71 })
72 72
73 it('Should list video languages', function (done) {
74 videosUtils.getVideoLanguages(server.url, function (err, res) {
75 if (err) throw err
76
77 const languages = res.body
78 expect(Object.keys(languages)).to.have.length.above(5)
79
80 expect(languages[3]).to.equal('Mandarin')
81
82 done()
83 })
84 })
85
73 it('Should not have videos', function (done) { 86 it('Should not have videos', function (done) {
74 videosUtils.getVideosList(server.url, function (err, res) { 87 videosUtils.getVideosList(server.url, function (err, res) {
75 if (err) throw err 88 if (err) throw err
@@ -110,6 +123,8 @@ describe('Test a single pod', function () {
110 expect(video.categoryLabel).to.equal('Films') 123 expect(video.categoryLabel).to.equal('Films')
111 expect(video.licence).to.equal(6) 124 expect(video.licence).to.equal(6)
112 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') 125 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
126 expect(video.language).to.equal(3)
127 expect(video.languageLabel).to.equal('Mandarin')
113 expect(video.nsfw).to.be.truthy 128 expect(video.nsfw).to.be.truthy
114 expect(video.description).to.equal('my super description') 129 expect(video.description).to.equal('my super description')
115 expect(video.podHost).to.equal('localhost:9001') 130 expect(video.podHost).to.equal('localhost:9001')
@@ -150,6 +165,8 @@ describe('Test a single pod', function () {
150 expect(video.categoryLabel).to.equal('Films') 165 expect(video.categoryLabel).to.equal('Films')
151 expect(video.licence).to.equal(6) 166 expect(video.licence).to.equal(6)
152 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') 167 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
168 expect(video.language).to.equal(3)
169 expect(video.languageLabel).to.equal('Mandarin')
153 expect(video.nsfw).to.be.truthy 170 expect(video.nsfw).to.be.truthy
154 expect(video.description).to.equal('my super description') 171 expect(video.description).to.equal('my super description')
155 expect(video.podHost).to.equal('localhost:9001') 172 expect(video.podHost).to.equal('localhost:9001')
@@ -194,6 +211,8 @@ describe('Test a single pod', function () {
194 expect(video.categoryLabel).to.equal('Films') 211 expect(video.categoryLabel).to.equal('Films')
195 expect(video.licence).to.equal(6) 212 expect(video.licence).to.equal(6)
196 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') 213 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
214 expect(video.language).to.equal(3)
215 expect(video.languageLabel).to.equal('Mandarin')
197 expect(video.nsfw).to.be.truthy 216 expect(video.nsfw).to.be.truthy
198 expect(video.description).to.equal('my super description') 217 expect(video.description).to.equal('my super description')
199 expect(video.podHost).to.equal('localhost:9001') 218 expect(video.podHost).to.equal('localhost:9001')
@@ -254,6 +273,8 @@ describe('Test a single pod', function () {
254 expect(video.categoryLabel).to.equal('Films') 273 expect(video.categoryLabel).to.equal('Films')
255 expect(video.licence).to.equal(6) 274 expect(video.licence).to.equal(6)
256 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') 275 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
276 expect(video.language).to.equal(3)
277 expect(video.languageLabel).to.equal('Mandarin')
257 expect(video.nsfw).to.be.truthy 278 expect(video.nsfw).to.be.truthy
258 expect(video.description).to.equal('my super description') 279 expect(video.description).to.equal('my super description')
259 expect(video.podHost).to.equal('localhost:9001') 280 expect(video.podHost).to.equal('localhost:9001')
@@ -352,6 +373,7 @@ describe('Test a single pod', function () {
352 description: video + ' description', 373 description: video + ' description',
353 category: 2, 374 category: 2,
354 licence: 1, 375 licence: 1,
376 language: 1,
355 nsfw: true, 377 nsfw: true,
356 tags: [ 'tag1', 'tag2', 'tag3' ], 378 tags: [ 'tag1', 'tag2', 'tag3' ],
357 fixture: video 379 fixture: video
@@ -578,6 +600,7 @@ describe('Test a single pod', function () {
578 name: 'my super video updated', 600 name: 'my super video updated',
579 category: 4, 601 category: 4,
580 licence: 2, 602 licence: 2,
603 language: 5,
581 nsfw: false, 604 nsfw: false,
582 description: 'my super description updated', 605 description: 'my super description updated',
583 tags: [ 'tagup1', 'tagup2' ] 606 tags: [ 'tagup1', 'tagup2' ]
@@ -598,6 +621,8 @@ describe('Test a single pod', function () {
598 expect(video.categoryLabel).to.equal('Art') 621 expect(video.categoryLabel).to.equal('Art')
599 expect(video.licence).to.equal(2) 622 expect(video.licence).to.equal(2)
600 expect(video.licenceLabel).to.equal('Attribution - Share Alike') 623 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
624 expect(video.language).to.equal(5)
625 expect(video.languageLabel).to.equal('Arabic')
601 expect(video.nsfw).to.be.truthy 626 expect(video.nsfw).to.be.truthy
602 expect(video.description).to.equal('my super description updated') 627 expect(video.description).to.equal('my super description updated')
603 expect(video.podHost).to.equal('localhost:9001') 628 expect(video.podHost).to.equal('localhost:9001')
@@ -640,6 +665,8 @@ describe('Test a single pod', function () {
640 expect(video.categoryLabel).to.equal('Art') 665 expect(video.categoryLabel).to.equal('Art')
641 expect(video.licence).to.equal(2) 666 expect(video.licence).to.equal(2)
642 expect(video.licenceLabel).to.equal('Attribution - Share Alike') 667 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
668 expect(video.language).to.equal(5)
669 expect(video.languageLabel).to.equal('Arabic')
643 expect(video.nsfw).to.be.truthy 670 expect(video.nsfw).to.be.truthy
644 expect(video.description).to.equal('my super description updated') 671 expect(video.description).to.equal('my super description updated')
645 expect(video.podHost).to.equal('localhost:9001') 672 expect(video.podHost).to.equal('localhost:9001')
@@ -672,6 +699,8 @@ describe('Test a single pod', function () {
672 expect(video.categoryLabel).to.equal('Art') 699 expect(video.categoryLabel).to.equal('Art')
673 expect(video.licence).to.equal(2) 700 expect(video.licence).to.equal(2)
674 expect(video.licenceLabel).to.equal('Attribution - Share Alike') 701 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
702 expect(video.language).to.equal(5)
703 expect(video.languageLabel).to.equal('Arabic')
675 expect(video.nsfw).to.be.truthy 704 expect(video.nsfw).to.be.truthy
676 expect(video.description).to.equal('hello everybody') 705 expect(video.description).to.equal('hello everybody')
677 expect(video.podHost).to.equal('localhost:9001') 706 expect(video.podHost).to.equal('localhost:9001')
diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js
index ddce45cde..21f0732d0 100644
--- a/server/tests/real-world/real-world.js
+++ b/server/tests/real-world/real-world.js
@@ -21,7 +21,7 @@ program
21 .option('-u, --update [weight]', 'Weight for updating videos') 21 .option('-u, --update [weight]', 'Weight for updating videos')
22 .option('-v, --view [weight]', 'Weight for viewing videos') 22 .option('-v, --view [weight]', 'Weight for viewing videos')
23 .option('-l, --like [weight]', 'Weight for liking videos') 23 .option('-l, --like [weight]', 'Weight for liking videos')
24 .option('-s --dislike [weight]', 'Weight for disliking videos') 24 .option('-s, --dislike [weight]', 'Weight for disliking videos')
25 .option('-p, --pods [n]', 'Number of pods to run (3 or 6)', /^3|6$/, 3) 25 .option('-p, --pods [n]', 'Number of pods to run (3 or 6)', /^3|6$/, 3)
26 .option('-a, --action [interval]', 'Interval in ms for an action') 26 .option('-a, --action [interval]', 'Interval in ms for an action')
27 .option('-i, --integrity [interval]', 'Interval in ms for an integrity check') 27 .option('-i, --integrity [interval]', 'Interval in ms for an integrity check')
@@ -207,6 +207,7 @@ function upload (servers, numServer, callback) {
207 category: 4, 207 category: 4,
208 nsfw: false, 208 nsfw: false,
209 licence: 2, 209 licence: 2,
210 language: 1,
210 description: Date.now() + ' description', 211 description: Date.now() + ' description',
211 tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ], 212 tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ],
212 fixture: 'video_short1.webm' 213 fixture: 'video_short1.webm'
diff --git a/server/tests/real-world/tools/upload.js b/server/tests/real-world/tools/upload.js
index 4b6dbe603..efb91e228 100644
--- a/server/tests/real-world/tools/upload.js
+++ b/server/tests/real-world/tools/upload.js
@@ -12,6 +12,7 @@ program
12 .option('-x, --nsfw', 'Video is Not Safe For Work') 12 .option('-x, --nsfw', 'Video is Not Safe For Work')
13 .option('-c, --category <category number>', 'Category number') 13 .option('-c, --category <category number>', 'Category number')
14 .option('-l, --licence <licence number>', 'Licence number') 14 .option('-l, --licence <licence number>', 'Licence number')
15 .option('-g, --language <language number>', 'Language number')
15 .option('-d, --description <description>', 'Video description') 16 .option('-d, --description <description>', 'Video description')
16 .option('-t, --tags <tags>', 'Video tags', list) 17 .option('-t, --tags <tags>', 'Video tags', list)
17 .option('-f, --file <file>', 'Video absolute file path') 18 .option('-f, --file <file>', 'Video absolute file path')
@@ -23,6 +24,7 @@ if (
23 !program.name || 24 !program.name ||
24 !program.category || 25 !program.category ||
25 !program.licence || 26 !program.licence ||
27 !program.language ||
26 !program.nsfw || 28 !program.nsfw ||
27 !program.description || 29 !program.description ||
28 !program.tags || 30 !program.tags ||
@@ -42,6 +44,7 @@ fs.access(program.file, fs.F_OK, function (err) {
42 program.name, 44 program.name,
43 program.category, 45 program.category,
44 program.licence, 46 program.licence,
47 program.language,
45 program.nsfw, 48 program.nsfw,
46 program.description, 49 program.description,
47 program.tags, 50 program.tags,
@@ -55,13 +58,14 @@ function list (val) {
55 return val.split(',') 58 return val.split(',')
56} 59}
57 60
58function upload (url, accessToken, name, category, licence, nsfw, description, tags, fixture) { 61function upload (url, accessToken, name, category, licence, language, nsfw, description, tags, fixture) {
59 console.log('Uploading %s video...', program.name) 62 console.log('Uploading %s video...', program.name)
60 63
61 const videoAttributes = { 64 const videoAttributes = {
62 name, 65 name,
63 category, 66 category,
64 licence, 67 licence,
68 language,
65 nsfw, 69 nsfw,
66 description, 70 description,
67 tags, 71 tags,
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js
index 3c7d99eec..f0eeec497 100644
--- a/server/tests/utils/videos.js
+++ b/server/tests/utils/videos.js
@@ -7,6 +7,7 @@ const request = require('supertest')
7const videosUtils = { 7const videosUtils = {
8 getVideoCategories, 8 getVideoCategories,
9 getVideoLicences, 9 getVideoLicences,
10 getVideoLanguages,
10 getAllVideosListBy, 11 getAllVideosListBy,
11 getVideo, 12 getVideo,
12 getVideosList, 13 getVideosList,
@@ -46,6 +47,17 @@ function getVideoLicences (url, end) {
46 .end(end) 47 .end(end)
47} 48}
48 49
50function getVideoLanguages (url, end) {
51 const path = '/api/v1/videos/languages'
52
53 request(url)
54 .get(path)
55 .set('Accept', 'application/json')
56 .expect(200)
57 .expect('Content-Type', /json/)
58 .end(end)
59}
60
49function getAllVideosListBy (url, end) { 61function getAllVideosListBy (url, end) {
50 const path = '/api/v1/videos' 62 const path = '/api/v1/videos'
51 63
@@ -218,6 +230,7 @@ function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end)
218 name: 'my super video', 230 name: 'my super video',
219 category: 5, 231 category: 5,
220 licence: 4, 232 licence: 4,
233 language: 3,
221 nsfw: true, 234 nsfw: true,
222 description: 'my super description', 235 description: 'my super description',
223 tags: [ 'tag' ], 236 tags: [ 'tag' ],
@@ -232,6 +245,7 @@ function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end)
232 .field('name', attributes.name) 245 .field('name', attributes.name)
233 .field('category', attributes.category) 246 .field('category', attributes.category)
234 .field('licence', attributes.licence) 247 .field('licence', attributes.licence)
248 .field('language', attributes.language)
235 .field('nsfw', attributes.nsfw) 249 .field('nsfw', attributes.nsfw)
236 .field('description', attributes.description) 250 .field('description', attributes.description)
237 251
@@ -267,6 +281,7 @@ function updateVideo (url, accessToken, id, attributes, specialStatus, end) {
267 if (attributes.name) req.field('name', attributes.name) 281 if (attributes.name) req.field('name', attributes.name)
268 if (attributes.category) req.field('category', attributes.category) 282 if (attributes.category) req.field('category', attributes.category)
269 if (attributes.licence) req.field('licence', attributes.licence) 283 if (attributes.licence) req.field('licence', attributes.licence)
284 if (attributes.language) req.field('language', attributes.language)
270 if (attributes.nsfw) req.field('nsfw', attributes.nsfw) 285 if (attributes.nsfw) req.field('nsfw', attributes.nsfw)
271 if (attributes.description) req.field('description', attributes.description) 286 if (attributes.description) req.field('description', attributes.description)
272 287