I have a suite of Selenium-driven functional tests for a web application I'm developing. I've recently integrated with Spring Security as a means of handling authentication. All of my functional tests now fail, naturally, given that every request is now taken to a login screen rather than the page that was originally requested.
There are many ways I can go about tackling this problem, of course, but none of them seem particularly appealing. Hard coding in dummy credentials into my testing code and then logging in as part of every test case seems ugly, fragile, and insecure. Adding in some kind of application level switch to disable authentication for test purposes likewise seems like a bad idea- any chance that security could be disabled in production is undesirable.
Surely I am not the first person to encounter this issue. What is the best means of handling authentication when writing functional tests for an application using Spring Security?


Reply With Quote
