@@ -392,12 +392,70 @@ describe('Schema Testing', () => {
392392 }
393393 } ) ;
394394
395- it ( 'valid schema with accessPolicy' , async ( ) => {
396- const { compiler } = prepareJsCompiler ( [
397- createCubeSchemaWithAccessPolicy ( 'ProtectedCube' ) ,
398- ] ) ;
399- await compiler . compile ( ) ;
400- compiler . throwIfAnyErrors ( ) ;
395+ describe ( 'Access Policies' , ( ) => {
396+ it ( 'valid schema with accessPolicy' , async ( ) => {
397+ const { compiler } = prepareJsCompiler ( [
398+ createCubeSchemaWithAccessPolicy ( 'ProtectedCube' ) ,
399+ ] ) ;
400+ await compiler . compile ( ) ;
401+ compiler . throwIfAnyErrors ( ) ;
402+ } ) ;
403+
404+ it ( 'throw errors for nonexistent policy members with paths' , async ( ) => {
405+ const orders = fs . readFileSync (
406+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders_nonexist_acl.yml' ) ,
407+ 'utf8'
408+ ) ;
409+ const orderUsers = fs . readFileSync (
410+ path . join ( process . cwd ( ) , '/test/unit/fixtures/order_users.yml' ) ,
411+ 'utf8'
412+ ) ;
413+ const { compiler } = prepareCompiler ( [
414+ {
415+ content : orders ,
416+ fileName : 'orders.yml' ,
417+ } ,
418+ {
419+ content : orderUsers ,
420+ fileName : 'order_users.yml' ,
421+ } ,
422+ ] ) ;
423+
424+ try {
425+ await compiler . compile ( ) ;
426+ throw new Error ( 'should throw earlier' ) ;
427+ } catch ( e : any ) {
428+ expect ( e . toString ( ) ) . toMatch ( / o r d e r s .o t h e r c a n n o t b e r e s o l v e d . T h e r e ' s n o s u c h m e m b e r o r c u b e / ) ;
429+ }
430+ } ) ;
431+
432+ it ( 'throw errors for incorrect policy members with paths' , async ( ) => {
433+ const orders = fs . readFileSync (
434+ path . join ( process . cwd ( ) , '/test/unit/fixtures/orders_incorrect_acl.yml' ) ,
435+ 'utf8'
436+ ) ;
437+ const orderUsers = fs . readFileSync (
438+ path . join ( process . cwd ( ) , '/test/unit/fixtures/order_users.yml' ) ,
439+ 'utf8'
440+ ) ;
441+ const { compiler } = prepareCompiler ( [
442+ {
443+ content : orders ,
444+ fileName : 'orders.yml' ,
445+ } ,
446+ {
447+ content : orderUsers ,
448+ fileName : 'order_users.yml' ,
449+ } ,
450+ ] ) ;
451+
452+ try {
453+ await compiler . compile ( ) ;
454+ throw new Error ( 'should throw earlier' ) ;
455+ } catch ( e : any ) {
456+ expect ( e . toString ( ) ) . toMatch ( / P a t h s a r e n ' t a l l o w e d i n t h e a c c e s s P o l i c y p o l i c y b u t ' o r d e r _ u s e r s .n a m e ' p r o v i d e d a s a f i l t e r m e m b e r r e f e r e n c e f o r o r d e r s / ) ;
457+ }
458+ } ) ;
401459 } ) ;
402460
403461 describe ( 'Views' , ( ) => {
@@ -431,14 +489,15 @@ describe('Schema Testing', () => {
431489
432490 try {
433491 await compiler . compile ( ) ;
492+ throw new Error ( 'should throw earlier' ) ;
434493 } catch ( e : any ) {
435494 expect ( e . toString ( ) ) . toMatch ( / P a t h s a r e n ' t a l l o w e d i n c u b e i n c l u d e s b u t ' n o n e x i s t e n t 2 \. v i a \. p a t h ' p r o v i d e d a s i n c l u d e m e m b e r / ) ;
436495 expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 1 ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
437496 expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 2 \. v i a \. p a t h ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
438497 }
439498 } ) ;
440499
441- it ( 'throws errors for incorrect referenced excludes members' , async ( ) => {
500+ it ( 'throws errors for incorrect referenced excludes members with paths ' , async ( ) => {
442501 const orders = fs . readFileSync (
443502 path . join ( process . cwd ( ) , '/test/unit/fixtures/orders.js' ) ,
444503 'utf8'
@@ -452,7 +511,7 @@ describe('Schema Testing', () => {
452511 excludes:
453512 - id
454513 - status
455- - nonexistent3
514+ - nonexistent3.ext
456515 - nonexistent4
457516 ` ;
458517
@@ -469,9 +528,9 @@ describe('Schema Testing', () => {
469528
470529 try {
471530 await compiler . compile ( ) ;
531+ throw new Error ( 'should throw earlier' ) ;
472532 } catch ( e : any ) {
473- expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 3 ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
474- expect ( e . toString ( ) ) . toMatch ( / M e m b e r ' n o n e x i s t e n t 4 ' i s i n c l u d e d i n ' o r d e r s _ v i e w ' b u t n o t d e f i n e d i n a n y c u b e / ) ;
533+ expect ( e . toString ( ) ) . toMatch ( / P a t h s a r e n ' t a l l o w e d i n c u b e e x c l u d e s b u t ' n o n e x i s t e n t 3 .e x t ' p r o v i d e d a s e x c l u d e m e m b e r / ) ;
475534 }
476535 } ) ;
477536
@@ -505,6 +564,7 @@ describe('Schema Testing', () => {
505564
506565 try {
507566 await compiler . compile ( ) ;
567+ throw new Error ( 'should throw earlier' ) ;
508568 } catch ( e : any ) {
509569 expect ( e . toString ( ) ) . toMatch ( / P a t h s a r e n ' t a l l o w e d i n c u b e e x c l u d e s b u t ' n o n e x i s t e n t 5 \. v i a \. p a t h ' p r o v i d e d a s e x c l u d e m e m b e r / ) ;
510570 }
@@ -546,6 +606,7 @@ describe('Schema Testing', () => {
546606
547607 try {
548608 await compiler . compile ( ) ;
609+ throw new Error ( 'should throw earlier' ) ;
549610 } catch ( e : any ) {
550611 expect ( e . toString ( ) ) . toMatch ( / I n c l u d e d m e m b e r ' c o u n t ' c o n f l i c t s w i t h e x i s t i n g m e m b e r o f ' o r d e r s _ v i e w ' \. P l e a s e c o n s i d e r e x c l u d i n g t h i s m e m b e r o r a s s i g n i n g i t a n a l i a s / ) ;
551612 expect ( e . toString ( ) ) . toMatch ( / I n c l u d e d m e m b e r ' i d ' c o n f l i c t s w i t h e x i s t i n g m e m b e r o f ' o r d e r s _ v i e w ' \. P l e a s e c o n s i d e r e x c l u d i n g t h i s m e m b e r o r a s s i g n i n g i t a n a l i a s / ) ;
0 commit comments