@@ -124,14 +124,23 @@ describe('acl', () => {
124124 expect ( acl . can ( { role : 'admin' , resource : 'comments' , action : 'create' } ) ) . toBeNull ( ) ;
125125 } ) ;
126126
127- it ( 'should allow explicit unbound strategy actions outside configured strategy resources' , ( ) => {
128- acl . setAvailableAction ( 'create' , {
129- type : 'new-data' ,
127+ it ( 'should require explicit resource binding outside configured strategy resources' , ( ) => {
128+ acl . setAvailableAction ( 'view' , {
129+ aliases : [ 'get' , 'list' ] ,
130+ type : 'old-data' ,
131+ } ) ;
132+ acl . setAvailableAction ( 'viewSystemSettings' , {
133+ resource : 'systemSettings' ,
134+ type : 'old-data' ,
135+ } ) ;
136+ acl . setAvailableAction ( 'viewAnySystemResource' , {
137+ resource : '*' ,
138+ type : 'old-data' ,
130139 } ) ;
131140
132141 acl . setAvailableStrategy ( 's1' , {
133142 displayName : 's1' ,
134- actions : [ 'create ' ] ,
143+ actions : [ 'view' , 'viewSystemSettings' , 'viewAnySystemResource '] ,
135144 } ) ;
136145
137146 acl . setStrategyResources ( [ 'posts' ] ) ;
@@ -141,10 +150,21 @@ describe('acl', () => {
141150 strategy : 's1' ,
142151 } ) ;
143152
144- expect ( acl . can ( { role : 'admin' , resource : 'customPosts ' , action : 'create ' } ) ) . toMatchObject ( {
153+ expect ( acl . can ( { role : 'admin' , resource : 'posts ' , action : 'get ' } ) ) . toMatchObject ( {
145154 role : 'admin' ,
146- resource : 'customPosts' ,
147- action : 'create' ,
155+ resource : 'posts' ,
156+ action : 'get' ,
157+ } ) ;
158+ expect ( acl . can ( { role : 'admin' , resource : 'aichat' , action : 'get' } ) ) . toBeNull ( ) ;
159+ expect ( acl . can ( { role : 'admin' , resource : 'systemSettings' , action : 'viewSystemSettings' } ) ) . toMatchObject ( {
160+ role : 'admin' ,
161+ resource : 'systemSettings' ,
162+ action : 'viewSystemSettings' ,
163+ } ) ;
164+ expect ( acl . can ( { role : 'admin' , resource : 'storages' , action : 'viewAnySystemResource' } ) ) . toMatchObject ( {
165+ role : 'admin' ,
166+ resource : 'storages' ,
167+ action : 'viewAnySystemResource' ,
148168 } ) ;
149169 } ) ;
150170
0 commit comments