@@ -447,7 +447,7 @@ describe('API Gateway', () => {
447447
448448 const scheduledRefreshTimeZonesFactory = ( ) => ( [ 'UTC' , 'America/Los_Angeles' ] ) ;
449449
450- const appPrepareFactory = ( ) => {
450+ const appPrepareFactory = ( scope ?: string [ ] ) => {
451451 const playgroundAuthSecret = 'test12345' ;
452452 const { app } = createApiGateway (
453453 new AdapterApiMock ( ) ,
@@ -460,7 +460,7 @@ describe('API Gateway', () => {
460460 scheduledRefreshTimeZones : scheduledRefreshTimeZonesFactory ( )
461461 }
462462 ) ;
463- const token = generateAuthToken ( { uid : 5 , } , { } , playgroundAuthSecret ) ;
463+ const token = generateAuthToken ( { uid : 5 , scope } , { } , playgroundAuthSecret ) ;
464464 const tokenUser = generateAuthToken ( { uid : 5 , } , { } , API_SECRET ) ;
465465
466466 return { app, token, tokenUser } ;
@@ -490,8 +490,8 @@ describe('API Gateway', () => {
490490 . expect ( 404 ) ;
491491 } ;
492492
493- const successTestFactory = ( { route, method = 'get' , successBody = { } , successResult } ) => async ( ) => {
494- const { app, token } = appPrepareFactory ( ) ;
493+ const successTestFactory = ( { route, method = 'get' , successBody = { } , successResult, scope = [ '' ] } ) => async ( ) => {
494+ const { app, token } = appPrepareFactory ( scope ) ;
495495
496496 const req = request ( app ) [ method ] ( `/cubejs-system/v1/${ route } ` )
497497 . set ( 'Content-type' , 'application/json' )
@@ -504,18 +504,19 @@ describe('API Gateway', () => {
504504 expect ( res . body ) . toMatchObject ( successResult ) ;
505505 } ;
506506
507- const wrongPayloadsTestFactory = ( { route, wrongPayloads } : {
507+ const wrongPayloadsTestFactory = ( { route, wrongPayloads, scope } : {
508508 route : string ,
509509 method : string ,
510+ scope ?: string [ ] ,
510511 wrongPayloads : {
511512 result : {
512513 status : number ,
513514 error : string
514515 } ,
515- body : { }
516+ body : { } ,
516517 } [ ]
517518 } ) => async ( ) => {
518- const { app, token } = appPrepareFactory ( ) ;
519+ const { app, token } = appPrepareFactory ( scope ) ;
519520
520521 for ( const payload of wrongPayloads ) {
521522 const req = request ( app ) . post ( `/cubejs-system/v1/${ route } ` )
@@ -551,6 +552,7 @@ describe('API Gateway', () => {
551552 } ,
552553 {
553554 route : 'sql-runner' ,
555+ scope : [ 'sql-runner' ] ,
554556 method : 'post' ,
555557 successBody : {
556558 query : {
@@ -592,7 +594,7 @@ describe('API Gateway', () => {
592594 }
593595 } ]
594596 } ,
595- { route : 'data-sources' , successResult : { dataSources : [ { dataSource : 'default' , dbType : 'postgres' } ] } } ,
597+ { route : 'data-sources' , scope : [ 'sql-runner' ] , successResult : { dataSources : [ { dataSource : 'default' , dbType : 'postgres' } ] } } ,
596598 ] ;
597599
598600 testConfigs . forEach ( ( config ) => {
0 commit comments