@@ -123,6 +123,111 @@ describe('user configuration', function () {
123123 expect ( config . getRateLimit ( ) . limit ) . to . be . eql ( limitConfig . rateLimit . limit ) ;
124124 } ) ;
125125
126+ it ( 'should override default settings for attestation config' , function ( ) {
127+ const user = {
128+ attestationConfig : {
129+ questions : [
130+ {
131+ label : 'Testing Label Change' ,
132+ tooltip : {
133+ text : 'Testing Tooltip Change' ,
134+ links : [ ] ,
135+ } ,
136+ } ,
137+ ] ,
138+ } ,
139+ } ;
140+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
141+
142+ const config = require ( '../src/config' ) ;
143+
144+ expect ( config . getAttestationConfig ( ) ) . to . be . eql ( user . attestationConfig ) ;
145+ } ) ;
146+
147+ it ( 'should override default settings for url shortener' , function ( ) {
148+ const user = {
149+ urlShortener : 'https://url-shortener.com' ,
150+ } ;
151+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
152+
153+ const config = require ( '../src/config' ) ;
154+
155+ expect ( config . getURLShortener ( ) ) . to . be . eql ( user . urlShortener ) ;
156+ } ) ;
157+
158+ it ( 'should override default settings for contact email' , function ( ) {
159+ const user = {
160+ contactEmail : 'test@example.com' ,
161+ } ;
162+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
163+
164+ const config = require ( '../src/config' ) ;
165+
166+ expect ( config . getContactEmail ( ) ) . to . be . eql ( user . contactEmail ) ;
167+ } ) ;
168+
169+ it ( 'should override default settings for plugins' , function ( ) {
170+ const user = {
171+ plugins : [ 'plugin1' , 'plugin2' ] ,
172+ } ;
173+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
174+
175+ const config = require ( '../src/config' ) ;
176+
177+ expect ( config . getPlugins ( ) ) . to . be . eql ( user . plugins ) ;
178+ } ) ;
179+
180+ it ( 'should override default settings for sslCertPemPath' , function ( ) {
181+ const user = {
182+ tls : {
183+ enabled : true ,
184+ key : 'my-key.pem' ,
185+ cert : 'my-cert.pem' ,
186+ }
187+ } ;
188+
189+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
190+
191+ const config = require ( '../src/config' ) ;
192+
193+ expect ( config . getTLSCertPemPath ( ) ) . to . be . eql ( user . tls . cert ) ;
194+ expect ( config . getTLSKeyPemPath ( ) ) . to . be . eql ( user . tls . key ) ;
195+ expect ( config . getTLSEnabled ( ) ) . to . be . eql ( user . tls . enabled ) ;
196+ } ) ;
197+
198+ it ( 'should prioritize tls.key and tls.cert over sslKeyPemPath and sslCertPemPath' , function ( ) {
199+ const user = {
200+ tls : {
201+ enabled : true ,
202+ key : 'good-key.pem' ,
203+ cert : 'good-cert.pem' ,
204+ } ,
205+ sslKeyPemPath : 'bad-key.pem' ,
206+ sslCertPemPath : 'bad-cert.pem' ,
207+ } ;
208+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
209+
210+ const config = require ( '../src/config' ) ;
211+
212+ expect ( config . getTLSCertPemPath ( ) ) . to . be . eql ( user . tls . cert ) ;
213+ expect ( config . getTLSKeyPemPath ( ) ) . to . be . eql ( user . tls . key ) ;
214+ expect ( config . getTLSEnabled ( ) ) . to . be . eql ( user . tls . enabled ) ;
215+ } ) ;
216+
217+ it ( 'should use sslKeyPemPath and sslCertPemPath if tls.key and tls.cert are not present' , function ( ) {
218+ const user = {
219+ sslKeyPemPath : 'good-key.pem' ,
220+ sslCertPemPath : 'good-cert.pem' ,
221+ } ;
222+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
223+
224+ const config = require ( '../src/config' ) ;
225+
226+ expect ( config . getTLSCertPemPath ( ) ) . to . be . eql ( user . sslCertPemPath ) ;
227+ expect ( config . getTLSKeyPemPath ( ) ) . to . be . eql ( user . sslKeyPemPath ) ;
228+ expect ( config . getTLSEnabled ( ) ) . to . be . eql ( false ) ;
229+ } ) ;
230+
126231 afterEach ( function ( ) {
127232 fs . rmSync ( tempUserFile ) ;
128233 fs . rmdirSync ( tempDir ) ;
0 commit comments