Skip to content

Commit a51b040

Browse files
committed
fixing tests for cb6 and 7
1 parent 41ecb57 commit a51b040

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
3+
* www.ortussolutions.com
4+
* ---
5+
* The default ColdBox WireBox Injector configuration object that is used when the
6+
* WireBox injector is created
7+
**/
8+
component extends="coldbox.system.ioc.config.Binder" {
9+
10+
/**
11+
* Configure WireBox, that's it!
12+
*/
13+
function configure(){
14+
// The WireBox configuration structure DSL
15+
wireBox = {
16+
// Default LogBox Configuration file
17+
logBoxConfig : "coldbox.system.ioc.config.LogBox",
18+
// CacheBox Integration OFF by default
19+
cacheBox : {
20+
enabled : false
21+
// configFile = "coldbox.system.ioc.config.CacheBox", An optional configuration file to use for loading CacheBox
22+
// cacheFactory = "" A reference to an already instantiated CacheBox CacheFactory
23+
// classNamespace = "" A class path namespace to use to create CacheBox: Default=coldbox.system.cache or wirebox.system.cache
24+
},
25+
// Name of a CacheBox cache to store metadata in to speed up start time.
26+
// Since metadata is already stored in memory, this is only useful for a disk, etc cache that persists across restarts.
27+
metadataCache : "",
28+
// Scope registration, automatically register a wirebox injector instance on any CF scope
29+
// By default it registers itself on application scope
30+
scopeRegistration : {
31+
enabled : false
32+
},
33+
// DSL Namespace registrations
34+
customDSL : {
35+
// namespace = "mapping name"
36+
},
37+
// Custom Storage Scopes
38+
customScopes : {
39+
// annotationName = "mapping name"
40+
},
41+
// Package scan locations
42+
scanLocations : [],
43+
// Stop Recursions
44+
stopRecursions : [],
45+
// Parent Injector to assign to the configured injector, this must be an object reference
46+
parentInjector : "",
47+
// Register all event listeners here, they are created in the specified order
48+
listeners : [
49+
// { class="", name="", properties={} }
50+
]
51+
};
52+
}
53+
54+
}

test-harness/tests/specs/unit/SecurityTest.cfc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
1212
beforeEach( function( currentSpec ){
1313
// setup properties
1414
setup();
15+
16+
mockWireBox = new coldbox.system.ioc.Injector( "tests.resources.Binder" );
17+
1518
mockController
1619
.$( "getAppHash", hash( "appHash" ) )
1720
.$( "getAppRootPath", expandPath( "/root" ) )
@@ -26,7 +29,7 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
2629
.$args( "modules" )
2730
.$results( [] );
2831

29-
mockSecurityService = getMockBox().prepareMock( new cbsecurity.models.CBSecurity() );
32+
mockSecurityService = prepareMock( new cbsecurity.models.CBSecurity() );
3033

3134
security = interceptor;
3235
settings = {
@@ -101,12 +104,13 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
101104
"/tests/resources/security.json.cfm"
102105
);
103106
settings.firewall.validator = "tests.resources.security";
107+
mockValidator = mockWireBox.getInstance( settings.firewall.validator );
104108
security.getRulesLoader().$( "loadRules", [] );
105109

106110
security
107111
.$( "getInstance" )
108112
.$args( settings.firewall.validator )
109-
.$results( mockWireBox.getInstance( settings.firewall.validator ) );
113+
.$results( mockValidator );
110114

111115
security.afterAspectsLoad();
112116

@@ -137,10 +141,11 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
137141

138142
it( "does not enable invalid event handler processing on Coldbox versions 6+", function(){
139143
security.setProperties( settings );
144+
mockValidator = mockWireBox.getInstance( settings.firewall.validator );
140145
security
141146
.$( "getInstance" )
142147
.$args( settings.firewall.validator )
143-
.$results( mockWireBox.getInstance( settings.firewall.validator ) );
148+
.$results( mockValidator );
144149
security.configure();
145150
expect( security.$getProperty( "enableInvalidHandlerCheck" ) ).toBeFalse();
146151
} );
@@ -151,21 +156,23 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
151156
{ "version" : "5.0.0" },
152157
false
153158
);
159+
mockValidator = mockWireBox.getInstance( settings.firewall.validator );
154160
security
155161
.$( "getInstance" )
156162
.$args( settings.firewall.validator )
157-
.$results( mockWireBox.getInstance( settings.firewall.validator ) );
163+
.$results( mockValidator );
158164
security.configure();
159165
expect( security.$getProperty( "enableInvalidHandlerCheck" ) ).toBeTrue();
160166
} );
161167

162168
describe( "It can load many types of rules", function(){
163169
beforeEach( function( currentSpec ){
164170
settings.firewall.validator = "tests.resources.security";
171+
mockValidator = mockWireBox.getInstance( settings.firewall.validator );
165172
security
166173
.$( "getInstance" )
167174
.$args( settings.firewall.validator )
168-
.$results( mockWireBox.getInstance( settings.firewall.validator ) );
175+
.$results( mockValidator );
169176
} );
170177

171178
it( "can load JSON Rules", function(){
@@ -205,6 +212,7 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
205212
describe( "module settings rule loading", function(){
206213
beforeEach( function( currentSpec ){
207214
settings.firewall.rules.inline = [];
215+
mockValidator = mockWireBox.getInstance( settings.firewall.validator );
208216
security
209217
.$property( propertyName = "securityModules", mock = {} )
210218
.$property(
@@ -216,7 +224,7 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
216224
)
217225
.$( "getInstance" )
218226
.$args( settings.firewall.validator )
219-
.$results( mockWireBox.getInstance( settings.firewall.validator ) );
227+
.$results( mockValidator );
220228
} );
221229

222230
it( "can load JSON Rules based on module settings", function(){

0 commit comments

Comments
 (0)