[coldbox-3.5.0-BE] Integration Testing with Solitary enabled

Hi All - I’m sure there is an simple answer to this.

I’m trying to run integration testing via mxunit but the solitary security module (obviously) jumps in and hijacks my executed event.

How do I get around this? is there a way I can disable it at runtime?

how do you guys run your integration tests with a security interceptor in place?

Cheers
Steve

well, that’s the good thing, that integration tests test everything. So either mock a login to bypass it or just don’t put it in your configuration file for testing.

I usually mock a login

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

OK. yes. you’re right, I should be testing the login.

thanks

So next question, how do you mock a handler function?

Solitary has the following function

Well, look at what the method is doing, if it places something in rc scope like the username. So in your setup do things like

rc.username = “luis”

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

OK well it looked like a stupid question and it sounded like a stupid question… .

the login function calls event.setView(…) which goes to the login form - do I just ignore that?
hmm I’m missing something

S

Sounds like you are blending integration tests with unit tests? For an integration test to test functionality hidden behind your membership wall you need to simulate a session so you appear to be an authenticated user. Your basically running the entire application from database to handler and asserting the handler got X back from your service/model and set Y into the PRC scope and finally set the view to Z.

Unit testing is much more targeted. You would mock everything the login handler needed to authenticate a user. Then, you would mock everything for a bad email address. Then you would mock everything for a bad password. Etc… In this case the only thing you would test is the handler. You would even mock the CFCs that handle the database stuff for you.

Hope this helps.

Aaron

Thanks aaron… not sure if it helps, I’ll let it try and sink in for a couple of hours

For those that search and find this issue. I’m not sure this is best practice but given that I couldn’t get it working any other way I unloaded the solitary module at runtime in the integration test by using:
getController().getModuleService().unload(“Solitary”);

which allows me to integration test the parent application without worrying about mocking/testing a third party module as well

Cheers

Great point

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

Hi Luis,

Could you post a short example of how to mock a login for an app that uses the “coldbox.system.interceptors.Security” interceptor? I would like to integration test a handler that is behind the security service and can’t quite connect the dots as to how to mock the login.

Thanks,
Micah