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/config.ts1
-rw-r--r--server/tests/api/check-params/videos.ts7
-rw-r--r--server/tests/api/server/config.ts30
-rw-r--r--server/tests/api/videos/video-transcoder.ts31
4 files changed, 64 insertions, 5 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index ffae380c1..b7bf41b58 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -54,6 +54,7 @@ describe('Test config API validators', function () {
54 }, 54 },
55 transcoding: { 55 transcoding: {
56 enabled: true, 56 enabled: true,
57 allowAdditionalExtensions: true,
57 threads: 1, 58 threads: 1,
58 resolutions: { 59 resolutions: {
59 '240p': false, 60 '240p': false,
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index d94eccf8e..f26b91435 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -320,10 +320,15 @@ describe('Test videos API validator', function () {
320 320
321 it('Should fail without an incorrect input file', async function () { 321 it('Should fail without an incorrect input file', async function () {
322 const fields = baseCorrectParams 322 const fields = baseCorrectParams
323 const attaches = { 323 let attaches = {
324 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') 324 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
325 } 325 }
326 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 326 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
327
328 attaches = {
329 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mkv')
330 }
331 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
327 }) 332 })
328 333
329 it('Should fail with an incorrect thumbnail file', async function () { 334 it('Should fail with an incorrect thumbnail file', async function () {
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index c5c360a17..4c163d47d 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -17,6 +17,7 @@ import {
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 updateCustomConfig 18 updateCustomConfig
19} from '../../../../shared/utils' 19} from '../../../../shared/utils'
20import { ServerConfig } from '../../../../shared/models'
20 21
21const expect = chai.expect 22const expect = chai.expect
22 23
@@ -43,6 +44,7 @@ function checkInitialConfig (data: CustomConfig) {
43 expect(data.user.videoQuota).to.equal(5242880) 44 expect(data.user.videoQuota).to.equal(5242880)
44 expect(data.user.videoQuotaDaily).to.equal(-1) 45 expect(data.user.videoQuotaDaily).to.equal(-1)
45 expect(data.transcoding.enabled).to.be.false 46 expect(data.transcoding.enabled).to.be.false
47 expect(data.transcoding.allowAdditionalExtensions).to.be.false
46 expect(data.transcoding.threads).to.equal(2) 48 expect(data.transcoding.threads).to.equal(2)
47 expect(data.transcoding.resolutions['240p']).to.be.true 49 expect(data.transcoding.resolutions['240p']).to.be.true
48 expect(data.transcoding.resolutions['360p']).to.be.true 50 expect(data.transcoding.resolutions['360p']).to.be.true
@@ -74,6 +76,7 @@ function checkUpdatedConfig (data: CustomConfig) {
74 expect(data.user.videoQuotaDaily).to.equal(318742) 76 expect(data.user.videoQuotaDaily).to.equal(318742)
75 expect(data.transcoding.enabled).to.be.true 77 expect(data.transcoding.enabled).to.be.true
76 expect(data.transcoding.threads).to.equal(1) 78 expect(data.transcoding.threads).to.equal(1)
79 expect(data.transcoding.allowAdditionalExtensions).to.be.true
77 expect(data.transcoding.resolutions['240p']).to.be.false 80 expect(data.transcoding.resolutions['240p']).to.be.false
78 expect(data.transcoding.resolutions['360p']).to.be.true 81 expect(data.transcoding.resolutions['360p']).to.be.true
79 expect(data.transcoding.resolutions['480p']).to.be.true 82 expect(data.transcoding.resolutions['480p']).to.be.true
@@ -96,7 +99,7 @@ describe('Test config', function () {
96 99
97 it('Should have a correct config on a server with registration enabled', async function () { 100 it('Should have a correct config on a server with registration enabled', async function () {
98 const res = await getConfig(server.url) 101 const res = await getConfig(server.url)
99 const data = res.body 102 const data: ServerConfig = res.body
100 103
101 expect(data.signup.allowed).to.be.true 104 expect(data.signup.allowed).to.be.true
102 }) 105 })
@@ -111,11 +114,21 @@ describe('Test config', function () {
111 ]) 114 ])
112 115
113 const res = await getConfig(server.url) 116 const res = await getConfig(server.url)
114 const data = res.body 117 const data: ServerConfig = res.body
115 118
116 expect(data.signup.allowed).to.be.false 119 expect(data.signup.allowed).to.be.false
117 }) 120 })
118 121
122 it('Should have the correct video allowed extensions', async function () {
123 const res = await getConfig(server.url)
124 const data: ServerConfig = res.body
125
126 expect(data.video.file.extensions).to.have.lengthOf(3)
127 expect(data.video.file.extensions).to.contain('.mp4')
128 expect(data.video.file.extensions).to.contain('.webm')
129 expect(data.video.file.extensions).to.contain('.ogv')
130 })
131
119 it('Should get the customized configuration', async function () { 132 it('Should get the customized configuration', async function () {
120 const res = await getCustomConfig(server.url, server.accessToken) 133 const res = await getCustomConfig(server.url, server.accessToken)
121 const data = res.body as CustomConfig 134 const data = res.body as CustomConfig
@@ -165,6 +178,7 @@ describe('Test config', function () {
165 }, 178 },
166 transcoding: { 179 transcoding: {
167 enabled: true, 180 enabled: true,
181 allowAdditionalExtensions: true,
168 threads: 1, 182 threads: 1,
169 resolutions: { 183 resolutions: {
170 '240p': false, 184 '240p': false,
@@ -193,6 +207,18 @@ describe('Test config', function () {
193 checkUpdatedConfig(data) 207 checkUpdatedConfig(data)
194 }) 208 })
195 209
210 it('Should have the correct updated video allowed extensions', async function () {
211 const res = await getConfig(server.url)
212 const data: ServerConfig = res.body
213
214 expect(data.video.file.extensions).to.have.length.above(3)
215 expect(data.video.file.extensions).to.contain('.mp4')
216 expect(data.video.file.extensions).to.contain('.webm')
217 expect(data.video.file.extensions).to.contain('.ogv')
218 expect(data.video.file.extensions).to.contain('.flv')
219 expect(data.video.file.extensions).to.contain('.mkv')
220 })
221
196 it('Should have the configuration updated after a restart', async function () { 222 it('Should have the configuration updated after a restart', async function () {
197 this.timeout(10000) 223 this.timeout(10000)
198 224
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 68cf00194..eefd32ef8 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -20,9 +20,8 @@ import {
20 uploadVideo, 20 uploadVideo,
21 webtorrentAdd 21 webtorrentAdd
22} from '../../../../shared/utils' 22} from '../../../../shared/utils'
23import { join } from 'path' 23import { extname, join } from 'path'
24import { waitJobs } from '../../../../shared/utils/server/jobs' 24import { waitJobs } from '../../../../shared/utils/server/jobs'
25import { pathExists } from 'fs-extra'
26import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 25import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
27 26
28const expect = chai.expect 27const expect = chai.expect
@@ -322,6 +321,34 @@ describe('Test video transcoding', function () {
322 } 321 }
323 }) 322 })
324 323
324 it('Should accept and transcode additional extensions', async function () {
325 this.timeout(300000)
326
327 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
328 const videoAttributes = {
329 name: fixture,
330 fixture
331 }
332
333 await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes)
334
335 await waitJobs(servers)
336
337 for (const server of servers) {
338 const res = await getVideosList(server.url)
339
340 const video = res.body.data.find(v => v.name === videoAttributes.name)
341 const res2 = await getVideo(server.url, video.id)
342 const videoDetails = res2.body
343
344 expect(videoDetails.files).to.have.lengthOf(4)
345
346 const magnetUri = videoDetails.files[ 0 ].magnetUri
347 expect(magnetUri).to.contain('.mp4')
348 }
349 }
350 })
351
325 after(async function () { 352 after(async function () {
326 killallServers(servers) 353 killallServers(servers)
327 }) 354 })