Skip to content

Commit 95e3d94

Browse files
committed
Add unit tests for invalid handler processing
1 parent 91999f2 commit 95e3d94

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
1313
// setup properties
1414
setup();
1515
variables.wirebox = new coldbox.system.ioc.Injector();
16-
mockController.$( "getAppHash", hash( "appHash" ) ).$( "getAppRootPath", expandPath( "/root" ) );
17-
security = interceptor;
16+
mockController
17+
.$( "getAppHash", hash( "appHash" ) )
18+
.$( "getAppRootPath", expandPath( "/root" ) )
19+
.$( "getColdboxSettings", {
20+
"version": "6.0.0"
21+
}, false );
22+
security = interceptor;
23+
security.setInvalidEventHandler( '' );
1824
settings = {
1925
// The global invalid authentication event or URI or URL to go if an invalid authentication occurs
2026
"invalidAuthenticationEvent" : "",
@@ -131,7 +137,32 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
131137
expect( function(){
132138
security.configure();
133139
} ).toThrow( "Security.ValidatorMethodException" );
134-
} );
140+
} );
141+
142+
it( "does not enable invalid event handler processing on Coldbox versions 6+", function() {
143+
security.setProperties( settings );
144+
security
145+
.$( "getInstance" )
146+
.$args( settings.validator )
147+
.$results( wirebox.getInstance( settings.validator ) );
148+
security.configure();
149+
expect( security.$getProperty( "enableInvalidHandlerCheck" ) ).toBeFalse();
150+
} );
151+
152+
it( "enables invalid event handler processing on Coldbox versions prior to 6", function() {
153+
154+
mockController.$( "getColdboxSettings", {
155+
"version": "5.0.0"
156+
}, false );
157+
158+
security.setProperties( settings );
159+
security
160+
.$( "getInstance" )
161+
.$args( settings.validator )
162+
.$results( wirebox.getInstance( settings.validator ) );
163+
security.configure();
164+
expect( security.$getProperty( "enableInvalidHandlerCheck" ) ).toBeTrue();
165+
} );
135166

136167
describe( "It can load many types of rules", function(){
137168
beforeEach( function(currentSpec){
@@ -173,7 +204,8 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
173204

174205
expect( security.getProperty( "rules", [] ) ).toHaveLength( 1 );
175206
} );
176-
} );
207+
} );
208+
177209
} );
178210
}
179211

0 commit comments

Comments
 (0)