@@ -204,7 +204,55 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
204
204
205
205
expect ( security .getProperty ( " rules" , [] ) ).toHaveLength ( 1 );
206
206
} );
207
- } );
207
+ } );
208
+
209
+ describe ( " module setting load" , function () {
210
+ beforeEach ( function (currentSpec ){
211
+ settings .rules = [];
212
+ settings .validator = " tests.resources.security" ;
213
+ security .$property ( propertyName = " securityModules" , mock = {} );
214
+ security .$property ( propertyName = " log" , mock = { info : function () {} });
215
+ security
216
+ .$( " getInstance" )
217
+ .$args ( settings .validator )
218
+ .$results ( wirebox .getInstance ( settings .validator ) );
219
+ security .setProperties ( settings );
220
+ } );
221
+
222
+ it ( " can load JSON Rules based on module settings" , function (){
223
+ expect ( security .getProperty ( " rules" , [] ) ).toHaveLength ( 0 );
224
+ var source = expandPath ( " /tests/resources/security.json.cfm" );
225
+ mockController .$( " locateFilePath" , source );
226
+
227
+ // initiate cbSecurity's module registration rule parsing
228
+ security .registerModule ( " myTestModule" , { rules : source } );
229
+
230
+ expect ( security .getProperty ( " rules" , [] ) ).toHaveLength ( 2 );
231
+ } );
232
+
233
+ it ( " can load XML Rules based on module settings" , function (){
234
+ var source = expandPath ( " /tests/resources/security.xml.cfm" );
235
+ mockController .$( " locateFilePath" , source );
236
+
237
+ // initiate cbSecurity's module registration rule parsing
238
+ security .registerModule ( " myTestModule" , { rules : source } );
239
+
240
+ expect ( security .getProperty ( " rules" , [] ) ).toHaveLength ( 3 );
241
+ } );
242
+
243
+ it ( " can load model Rules based on module settings" , function (){
244
+ var moduleSettings = {
245
+ rules : " model" ,
246
+ rulesModel : " tests.resources.security" ,
247
+ rulesModelMethod : " getSecurityRules"
248
+ };
249
+
250
+ // initiate cbSecurity's module registration rule parsing
251
+ security .registerModule ( " myTestModule" , moduleSettings );
252
+
253
+ expect ( security .getProperty ( " rules" , [] ) ).toHaveLength ( 1 );
254
+ } );
255
+ });
208
256
209
257
} );
210
258
}
0 commit comments