aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-14 17:17:01 +0100
committerChocobozzz <me@florianbigard.com>2021-12-14 17:17:01 +0100
commit3cf68b869decf07ff7435fe1436d4f3134df1bf4 (patch)
tree836efe5ddc626fef3ba4c96269efbca305f46256 /server/tests/api
parenta6f919e455f2c6ae8f2194da4aa66824a6bfd09e (diff)
downloadPeerTube-3cf68b869decf07ff7435fe1436d4f3134df1bf4.tar.gz
PeerTube-3cf68b869decf07ff7435fe1436d4f3134df1bf4.tar.zst
PeerTube-3cf68b869decf07ff7435fe1436d4f3134df1bf4.zip
Ability for admins to set default upload values
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/config-defaults.ts116
-rw-r--r--server/tests/api/server/index.ts2
2 files changed, 118 insertions, 0 deletions
diff --git a/server/tests/api/server/config-defaults.ts b/server/tests/api/server/config-defaults.ts
new file mode 100644
index 000000000..2433d3119
--- /dev/null
+++ b/server/tests/api/server/config-defaults.ts
@@ -0,0 +1,116 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import * as chai from 'chai'
5import { cleanupTests, createSingleServer, FIXTURE_URLS, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils'
6import { VideoDetails, VideoPrivacy } from '@shared/models'
7
8const expect = chai.expect
9
10describe('Test config defaults', function () {
11 let server: PeerTubeServer
12 let channelId: number
13
14 before(async function () {
15 this.timeout(30000)
16
17 const overrideConfig = {
18 defaults: {
19 publish: {
20 comments_enabled: false,
21 download_enabled: false,
22 privacy: VideoPrivacy.INTERNAL,
23 licence: 4
24 }
25 }
26 }
27
28 server = await createSingleServer(1, overrideConfig)
29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ])
31
32 channelId = server.store.channel.id
33 })
34
35 describe('Default publish values', function () {
36 const attributes = {
37 name: 'video',
38 downloadEnabled: undefined,
39 commentsEnabled: undefined,
40 licence: undefined,
41 privacy: VideoPrivacy.PUBLIC // Privacy is mandatory for server
42 }
43
44 function checkVideo (video: VideoDetails) {
45 expect(video.downloadEnabled).to.be.false
46 expect(video.commentsEnabled).to.be.false
47 expect(video.licence.id).to.equal(4)
48 }
49
50 before(async function () {
51 await server.config.disableTranscoding()
52 await server.config.enableImports()
53 await server.config.enableLive({ allowReplay: false, transcoding: false })
54 })
55
56 it('Should have the correct server configuration', async function () {
57 const config = await server.config.getConfig()
58
59 expect(config.defaults.publish.commentsEnabled).to.be.false
60 expect(config.defaults.publish.downloadEnabled).to.be.false
61 expect(config.defaults.publish.licence).to.equal(4)
62 expect(config.defaults.publish.privacy).to.equal(VideoPrivacy.INTERNAL)
63 })
64
65 it('Should respect default values when uploading a video', async function () {
66 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
67 const { id } = await server.videos.upload({ attributes, mode })
68
69 const video = await server.videos.get({ id })
70 checkVideo(video)
71 }
72 })
73
74 it('Should respect default values when importing a video using URL', async function () {
75 const { video: { id } } = await server.imports.importVideo({
76 attributes: {
77 ...attributes,
78 channelId,
79 targetUrl: FIXTURE_URLS.goodVideo
80 }
81 })
82
83 const video = await server.videos.get({ id })
84 checkVideo(video)
85 })
86
87 it('Should respect default values when importing a video using magnet URI', async function () {
88 const { video: { id } } = await server.imports.importVideo({
89 attributes: {
90 ...attributes,
91 channelId,
92 magnetUri: FIXTURE_URLS.magnet
93 }
94 })
95
96 const video = await server.videos.get({ id })
97 checkVideo(video)
98 })
99
100 it('Should respect default values when creating a live', async function () {
101 const { id } = await server.live.create({
102 fields: {
103 ...attributes,
104 channelId
105 }
106 })
107
108 const video = await server.videos.get({ id })
109 checkVideo(video)
110 })
111 })
112
113 after(async function () {
114 await cleanupTests([ server ])
115 })
116})
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts
index 8136fc3c6..45be107ce 100644
--- a/server/tests/api/server/index.ts
+++ b/server/tests/api/server/index.ts
@@ -1,4 +1,6 @@
1import './auto-follows' 1import './auto-follows'
2import './bulk'
3import './config-defaults'
2import './config' 4import './config'
3import './contact-form' 5import './contact-form'
4import './email' 6import './email'