@@ -452,6 +452,46 @@ describe('DA auth', () => {
452452 groups : '2345B0EA551D747/4711' ,
453453 actions : 'write' ,
454454 } ,
455+ {
456+ path : 'CONFIG' ,
457+ groups : 'read-first@bloggs.org' ,
458+ actions : 'read' ,
459+ } ,
460+ {
461+ path : 'CONFIG' ,
462+ groups : 'read-first@bloggs.org' ,
463+ actions : 'write' ,
464+ } ,
465+ {
466+ path : '/test' ,
467+ groups : 'read-first@bloggs.org' ,
468+ actions : 'read' ,
469+ } ,
470+ {
471+ path : '/test' ,
472+ groups : 'read-first@bloggs.org' ,
473+ actions : 'write' ,
474+ } ,
475+ {
476+ path : 'CONFIG' ,
477+ groups : 'write-first@bloggs.org' ,
478+ actions : 'write' ,
479+ } ,
480+ {
481+ path : 'CONFIG' ,
482+ groups : 'write-first@bloggs.org' ,
483+ actions : 'read' ,
484+ } ,
485+ {
486+ path : '/test' ,
487+ groups : 'write-first@bloggs.org' ,
488+ actions : 'write' ,
489+ } ,
490+ {
491+ path : '/test' ,
492+ groups : 'write-first@bloggs.org' ,
493+ actions : 'read' ,
494+ } ,
455495 ] ,
456496 ':type' : 'sheet' ,
457497 ':sheetname' : 'permissions' ,
@@ -512,6 +552,44 @@ describe('DA auth', () => {
512552 users, org : 'test' , aclCtx, key,
513553 } , '/furb' , 'write' ) ) ;
514554 } ) ;
555+
556+ it ( 'test hasPermissions if read and write user' , async ( ) => {
557+ const key = '' ;
558+ const users = [ { email : 'read-first@bloggs.org' } ] ;
559+ const aclCtx = await getAclCtx ( env , 'test' , users , key ) ;
560+
561+ assert ( hasPermission ( {
562+ users, org : 'test' , aclCtx, key,
563+ } , 'CONFIG' , 'read' ) ) ;
564+ assert ( hasPermission ( {
565+ users, org : 'test' , aclCtx, key,
566+ } , 'CONFIG' , 'write' ) ) ;
567+ assert ( hasPermission ( {
568+ users, org : 'test' , aclCtx, key,
569+ } , '/test' , 'read' ) ) ;
570+ assert ( hasPermission ( {
571+ users, org : 'test' , aclCtx, key,
572+ } , '/test' , 'write' ) ) ;
573+ } ) ;
574+
575+ it ( 'test hasPermissions if write and read user' , async ( ) => {
576+ const key = '' ;
577+ const users = [ { email : 'write-first@bloggs.org' } ] ;
578+ const aclCtx = await getAclCtx ( env , 'test' , users , key ) ;
579+
580+ assert ( hasPermission ( {
581+ users, org : 'test' , aclCtx, key,
582+ } , 'CONFIG' , 'read' ) ) ;
583+ assert ( hasPermission ( {
584+ users, org : 'test' , aclCtx, key,
585+ } , 'CONFIG' , 'write' ) ) ;
586+ assert ( hasPermission ( {
587+ users, org : 'test' , aclCtx, key,
588+ } , '/test' , 'read' ) ) ;
589+ assert ( hasPermission ( {
590+ users, org : 'test' , aclCtx, key,
591+ } , '/test' , 'write' ) ) ;
592+ } ) ;
515593 } ) ;
516594
517595 it ( 'test getAclCtx missing props' , async ( ) => {
0 commit comments