@@ -253,7 +253,7 @@ describe('ConfigLoader', () => {
253
253
path : tempConfigFile ,
254
254
} ,
255
255
] ,
256
- reloadIntervalSeconds : 0.001 ,
256
+ reloadIntervalSeconds : 0.01 ,
257
257
} ,
258
258
} ;
259
259
@@ -262,7 +262,7 @@ describe('ConfigLoader', () => {
262
262
await configLoader . start ( ) ;
263
263
264
264
// Make sure the reload interval is triggered
265
- await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
265
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) ) ;
266
266
267
267
expect ( spy . callCount ) . to . greaterThan ( 1 ) ;
268
268
} ) ;
@@ -313,7 +313,7 @@ describe('ConfigLoader', () => {
313
313
enabled : true ,
314
314
} ;
315
315
316
- const config = await configLoader . loadFromGit ( source ) ;
316
+ const config = await configLoader . loadFromSource ( source ) ;
317
317
318
318
// Verify the loaded config has expected structure
319
319
expect ( config ) . to . be . an ( 'object' ) ;
@@ -331,7 +331,7 @@ describe('ConfigLoader', () => {
331
331
} ;
332
332
333
333
try {
334
- await configLoader . loadFromGit ( source ) ;
334
+ await configLoader . loadFromSource ( source ) ;
335
335
throw new Error ( 'Expected error was not thrown' ) ;
336
336
} catch ( error ) {
337
337
expect ( error . message ) . to . equal ( 'Invalid configuration file path in repository' ) ;
@@ -348,13 +348,48 @@ describe('ConfigLoader', () => {
348
348
enabled : true ,
349
349
} ;
350
350
351
- const config = await configLoader . loadFromHttp ( source ) ;
351
+ const config = await configLoader . loadFromSource ( source ) ;
352
352
353
353
// Verify the loaded config has expected structure
354
354
expect ( config ) . to . be . an ( 'object' ) ;
355
355
expect ( config ) . to . have . property ( 'proxyUrl' ) ;
356
356
expect ( config ) . to . have . property ( 'cookieSecret' ) ;
357
357
} ) ;
358
+
359
+ it ( 'should throw error if repository is invalid' , async function ( ) {
360
+ const source = {
361
+ type : 'git' ,
362
+ repository : 'invalid-repository' ,
363
+ path : 'proxy.config.json' ,
364
+ branch : 'main' ,
365
+ enabled : true ,
366
+ } ;
367
+
368
+ try {
369
+ await configLoader . loadFromSource ( source ) ;
370
+ throw new Error ( 'Expected error was not thrown' ) ;
371
+ } catch ( error ) {
372
+ expect ( error . message ) . to . equal ( 'Invalid repository URL format' ) ;
373
+ }
374
+ } ) ;
375
+
376
+ it ( 'should throw error if branch name is invalid' , async function ( ) {
377
+ const source = {
378
+ type : 'git' ,
379
+ repository : 'https://github.com/finos/git-proxy.git' ,
380
+ path : 'proxy.config.json' ,
381
+ branch : '..' , // invalid branch pattern
382
+ enabled : true ,
383
+ } ;
384
+
385
+ try {
386
+ await configLoader . loadFromSource ( source ) ;
387
+ throw new Error ( 'Expected error was not thrown' ) ;
388
+ } catch ( error ) {
389
+ expect ( error . message ) . to . equal ( 'Invalid branch name format' ) ;
390
+ }
391
+ } ) ;
392
+
358
393
} ) ;
359
394
360
395
describe ( 'deepMerge' , ( ) => {
0 commit comments