]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
fd206f0b | 5 | import { deleteCustomConfig, killallServers, reRunServer } from '../../utils' |
0e1dc3e7 C |
6 | const expect = chai.expect |
7 | ||
8 | import { | |
9 | getConfig, | |
10 | flushTests, | |
11 | runServer, | |
fd206f0b | 12 | registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig |
c5d31dba | 13 | } from '../../utils/index' |
0e1dc3e7 C |
14 | |
15 | describe('Test config', function () { | |
16 | let server = null | |
17 | ||
18 | before(async function () { | |
e212f887 | 19 | this.timeout(30000) |
0e1dc3e7 C |
20 | |
21 | await flushTests() | |
22 | server = await runServer(1) | |
fd206f0b | 23 | await setAccessTokensToServers([ server ]) |
0e1dc3e7 C |
24 | }) |
25 | ||
26 | it('Should have a correct config on a server with registration enabled', async function () { | |
27 | const res = await getConfig(server.url) | |
28 | const data = res.body | |
29 | ||
30 | expect(data.signup.allowed).to.be.true | |
31 | }) | |
32 | ||
33 | it('Should have a correct config on a server with registration enabled and a users limit', async function () { | |
652b3056 C |
34 | this.timeout(5000) |
35 | ||
47e0652b C |
36 | await Promise.all([ |
37 | registerUser(server.url, 'user1', 'super password'), | |
38 | registerUser(server.url, 'user2', 'super password'), | |
39 | registerUser(server.url, 'user3', 'super password') | |
40 | ]) | |
0e1dc3e7 C |
41 | |
42 | const res = await getConfig(server.url) | |
43 | const data = res.body | |
44 | ||
45 | expect(data.signup.allowed).to.be.false | |
46 | }) | |
47 | ||
fd206f0b C |
48 | it('Should get the customized configuration', async function () { |
49 | const res = await getCustomConfig(server.url, server.accessToken) | |
50 | const data = res.body | |
51 | ||
66b16caf C |
52 | expect(data.instance.name).to.equal('PeerTube') |
53 | expect(data.instance.description).to.be.empty | |
54 | expect(data.instance.terms).to.be.empty | |
fd206f0b C |
55 | expect(data.cache.previews.size).to.equal(1) |
56 | expect(data.signup.enabled).to.be.true | |
57 | expect(data.signup.limit).to.equal(4) | |
58 | expect(data.admin.email).to.equal('admin1@example.com') | |
59 | expect(data.user.videoQuota).to.equal(5242880) | |
60 | expect(data.transcoding.enabled).to.be.false | |
61 | expect(data.transcoding.threads).to.equal(2) | |
62 | expect(data.transcoding.resolutions['240p']).to.be.true | |
63 | expect(data.transcoding.resolutions['360p']).to.be.true | |
64 | expect(data.transcoding.resolutions['480p']).to.be.true | |
65 | expect(data.transcoding.resolutions['720p']).to.be.true | |
66 | expect(data.transcoding.resolutions['1080p']).to.be.true | |
67 | }) | |
68 | ||
69 | it('Should update the customized configuration', async function () { | |
70 | const newCustomConfig = { | |
66b16caf C |
71 | instance: { |
72 | name: 'PeerTube updated', | |
73 | description: 'my super description', | |
74 | terms: 'my super terms' | |
75 | }, | |
fd206f0b C |
76 | cache: { |
77 | previews: { | |
78 | size: 2 | |
79 | } | |
80 | }, | |
81 | signup: { | |
82 | enabled: false, | |
83 | limit: 5 | |
84 | }, | |
85 | admin: { | |
86 | email: 'superadmin1@example.com' | |
87 | }, | |
88 | user: { | |
89 | videoQuota: 5242881 | |
90 | }, | |
91 | transcoding: { | |
92 | enabled: true, | |
93 | threads: 1, | |
94 | resolutions: { | |
95 | '240p': false, | |
96 | '360p': true, | |
97 | '480p': true, | |
98 | '720p': false, | |
99 | '1080p': false | |
100 | } | |
101 | } | |
102 | } | |
103 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) | |
104 | ||
105 | const res = await getCustomConfig(server.url, server.accessToken) | |
106 | const data = res.body | |
107 | ||
66b16caf C |
108 | expect(data.instance.name).to.equal('PeerTube updated') |
109 | expect(data.instance.description).to.equal('my super description') | |
110 | expect(data.instance.terms).to.equal('my super terms') | |
fd206f0b C |
111 | expect(data.signup.enabled).to.be.false |
112 | expect(data.signup.limit).to.equal(5) | |
113 | expect(data.admin.email).to.equal('superadmin1@example.com') | |
114 | expect(data.user.videoQuota).to.equal(5242881) | |
115 | expect(data.transcoding.enabled).to.be.true | |
116 | expect(data.transcoding.threads).to.equal(1) | |
117 | expect(data.transcoding.resolutions['240p']).to.be.false | |
118 | expect(data.transcoding.resolutions['360p']).to.be.true | |
119 | expect(data.transcoding.resolutions['480p']).to.be.true | |
120 | expect(data.transcoding.resolutions['720p']).to.be.false | |
121 | expect(data.transcoding.resolutions['1080p']).to.be.false | |
122 | }) | |
123 | ||
124 | it('Should have the configuration updated after a restart', async function () { | |
23e27dd5 C |
125 | this.timeout(10000) |
126 | ||
fd206f0b C |
127 | killallServers([ server ]) |
128 | ||
129 | await reRunServer(server) | |
130 | ||
131 | const res = await getCustomConfig(server.url, server.accessToken) | |
132 | const data = res.body | |
133 | ||
134 | expect(data.cache.previews.size).to.equal(2) | |
135 | expect(data.signup.enabled).to.be.false | |
136 | expect(data.signup.limit).to.equal(5) | |
137 | expect(data.admin.email).to.equal('superadmin1@example.com') | |
138 | expect(data.user.videoQuota).to.equal(5242881) | |
139 | expect(data.transcoding.enabled).to.be.true | |
140 | expect(data.transcoding.threads).to.equal(1) | |
141 | expect(data.transcoding.resolutions['240p']).to.be.false | |
142 | expect(data.transcoding.resolutions['360p']).to.be.true | |
143 | expect(data.transcoding.resolutions['480p']).to.be.true | |
144 | expect(data.transcoding.resolutions['720p']).to.be.false | |
145 | expect(data.transcoding.resolutions['1080p']).to.be.false | |
146 | }) | |
147 | ||
148 | it('Should remove the custom configuration', async function () { | |
23e27dd5 C |
149 | this.timeout(10000) |
150 | ||
fd206f0b C |
151 | await deleteCustomConfig(server.url, server.accessToken) |
152 | ||
153 | const res = await getCustomConfig(server.url, server.accessToken) | |
154 | const data = res.body | |
155 | ||
156 | expect(data.cache.previews.size).to.equal(1) | |
157 | expect(data.signup.enabled).to.be.true | |
158 | expect(data.signup.limit).to.equal(4) | |
159 | expect(data.admin.email).to.equal('admin1@example.com') | |
160 | expect(data.user.videoQuota).to.equal(5242880) | |
161 | expect(data.transcoding.enabled).to.be.false | |
162 | expect(data.transcoding.threads).to.equal(2) | |
163 | expect(data.transcoding.resolutions['240p']).to.be.true | |
164 | expect(data.transcoding.resolutions['360p']).to.be.true | |
165 | expect(data.transcoding.resolutions['480p']).to.be.true | |
166 | expect(data.transcoding.resolutions['720p']).to.be.true | |
167 | expect(data.transcoding.resolutions['1080p']).to.be.true | |
168 | }) | |
169 | ||
0e1dc3e7 C |
170 | after(async function () { |
171 | process.kill(-server.app.pid) | |
172 | ||
173 | // Keep the logs if the test failed | |
174 | if (this['ok']) { | |
175 | await flushTests() | |
176 | } | |
177 | }) | |
178 | }) |