@@ -11,7 +11,7 @@ describe('default configuration', function () {
1111 it ( 'should use default values if no user-settings.json file exists' , function ( ) {
1212 const config = require ( '../src/config' ) ;
1313 config . logConfiguration ( ) ;
14- const enabledMethods = defaultSettings . authentication . filter ( method => method . enabled ) ;
14+ const enabledMethods = defaultSettings . authentication . filter ( ( method ) => method . enabled ) ;
1515
1616 expect ( config . getAuthMethods ( ) ) . to . deep . equal ( enabledMethods ) ;
1717 expect ( config . getDatabase ( ) ) . to . be . eql ( defaultSettings . sink [ 0 ] ) ;
@@ -62,7 +62,7 @@ describe('user configuration', function () {
6262 // Invalidate cache to force reload
6363 const config = require ( '../src/config' ) ;
6464 config . invalidateCache ( ) ;
65- const enabledMethods = defaultSettings . authentication . filter ( method => method . enabled ) ;
65+ const enabledMethods = defaultSettings . authentication . filter ( ( method ) => method . enabled ) ;
6666
6767 expect ( config . getAuthorisedList ( ) ) . to . be . eql ( user . authorisedList ) ;
6868 expect ( config . getAuthMethods ( ) ) . to . deep . equal ( enabledMethods ) ;
@@ -81,8 +81,8 @@ describe('user configuration', function () {
8181 clientID : 'test-client-id' ,
8282 clientSecret : 'test-client-secret' ,
8383 callbackURL : 'https://example.com/callback' ,
84- scope : 'openid email profile'
85- }
84+ scope : 'openid email profile' ,
85+ } ,
8686 } ,
8787 ] ,
8888 } ;
@@ -92,7 +92,7 @@ describe('user configuration', function () {
9292 const config = require ( '../src/config' ) ;
9393 config . invalidateCache ( ) ;
9494 const authMethods = config . getAuthMethods ( ) ;
95- const oidcAuth = authMethods . find ( method => method . type === 'openidconnect' ) ;
95+ const oidcAuth = authMethods . find ( ( method ) => method . type === 'openidconnect' ) ;
9696
9797 expect ( oidcAuth ) . to . not . be . undefined ;
9898 expect ( oidcAuth . enabled ) . to . be . true ;
@@ -114,7 +114,7 @@ describe('user configuration', function () {
114114 fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
115115
116116 const config = require ( '../src/config' ) ;
117- const enabledMethods = defaultSettings . authentication . filter ( method => method . enabled ) ;
117+ const enabledMethods = defaultSettings . authentication . filter ( ( method ) => method . enabled ) ;
118118
119119 expect ( config . getDatabase ( ) ) . to . be . eql ( user . sink [ 0 ] ) ;
120120 expect ( config . getDatabase ( ) ) . to . not . be . eql ( defaultSettings . sink [ 0 ] ) ;
@@ -217,7 +217,7 @@ describe('user configuration', function () {
217217 enabled : true ,
218218 key : 'my-key.pem' ,
219219 cert : 'my-cert.pem' ,
220- }
220+ } ,
221221 } ;
222222
223223 fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
@@ -240,7 +240,7 @@ describe('user configuration', function () {
240240 sslCertPemPath : 'bad-cert.pem' ,
241241 } ;
242242 fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
243-
243+
244244 // Invalidate cache to force reload
245245 const config = require ( '../src/config' ) ;
246246 config . invalidateCache ( ) ;
@@ -275,7 +275,7 @@ describe('user configuration', function () {
275275 } ,
276276 } ;
277277 fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
278-
278+
279279 // Invalidate cache to force reload
280280 const config = require ( '../src/config' ) ;
281281 config . invalidateCache ( ) ;
@@ -285,7 +285,7 @@ describe('user configuration', function () {
285285
286286 it ( 'should override default settings for cookieSecret if env var is used' , function ( ) {
287287 fs . writeFileSync ( tempUserFile , '{}' ) ;
288- process . env . GIT_PROXY_COOKIE_SECRET = 'test-cookie-secret'
288+ process . env . GIT_PROXY_COOKIE_SECRET = 'test-cookie-secret' ;
289289
290290 const config = require ( '../src/config' ) ;
291291 expect ( config . getCookieSecret ( ) ) . to . equal ( 'test-cookie-secret' ) ;
@@ -297,8 +297,8 @@ describe('user configuration', function () {
297297 {
298298 type : 'mongo' ,
299299 enabled : true ,
300- }
301- ]
300+ } ,
301+ ] ,
302302 } ;
303303 fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
304304 process . env . GIT_PROXY_MONGO_CONNECTION_STRING = 'mongodb://example.com:27017/test' ;
@@ -307,6 +307,53 @@ describe('user configuration', function () {
307307 expect ( config . getDatabase ( ) . connectionString ) . to . equal ( 'mongodb://example.com:27017/test' ) ;
308308 } ) ;
309309
310+ it ( 'should test cache invalidation function' , function ( ) {
311+ fs . writeFileSync ( tempUserFile , '{}' ) ;
312+
313+ const config = require ( '../src/config' ) ;
314+
315+ // Load config first time
316+ const firstLoad = config . getAuthorisedList ( ) ;
317+
318+ // Invalidate cache and load again
319+ config . invalidateCache ( ) ;
320+ const secondLoad = config . getAuthorisedList ( ) ;
321+
322+ expect ( firstLoad ) . to . deep . equal ( secondLoad ) ;
323+ } ) ;
324+
325+ it ( 'should test reloadConfiguration function' , async function ( ) {
326+ fs . writeFileSync ( tempUserFile , '{}' ) ;
327+
328+ const config = require ( '../src/config' ) ;
329+
330+ // reloadConfiguration doesn't throw
331+ await config . reloadConfiguration ( ) ;
332+ } ) ;
333+
334+ it ( 'should handle configuration errors during initialization' , function ( ) {
335+ const user = {
336+ invalidConfig : 'this should cause validation error' ,
337+ } ;
338+ fs . writeFileSync ( tempUserFile , JSON . stringify ( user ) ) ;
339+
340+ const config = require ( '../src/config' ) ;
341+ expect ( ( ) => config . getAuthorisedList ( ) ) . to . not . throw ( ) ;
342+ } ) ;
343+
344+ it ( 'should test all getter functions for coverage' , function ( ) {
345+ fs . writeFileSync ( tempUserFile , '{}' ) ;
346+
347+ const config = require ( '../src/config' ) ;
348+
349+ expect ( ( ) => config . getProxyUrl ( ) ) . to . not . throw ( ) ;
350+ expect ( ( ) => config . getCookieSecret ( ) ) . to . not . throw ( ) ;
351+ expect ( ( ) => config . getSessionMaxAgeHours ( ) ) . to . not . throw ( ) ;
352+ expect ( ( ) => config . getCommitConfig ( ) ) . to . not . throw ( ) ;
353+ expect ( ( ) => config . getPrivateOrganizations ( ) ) . to . not . throw ( ) ;
354+ expect ( ( ) => config . getUIRouteAuth ( ) ) . to . not . throw ( ) ;
355+ } ) ;
356+
310357 afterEach ( function ( ) {
311358 fs . rmSync ( tempUserFile ) ;
312359 fs . rmdirSync ( tempDir ) ;
0 commit comments