Unit Testing NegotiateSecurityFilter or WindowsIdentity

Dec 23, 2011 at 1:56 AM

I have a working solution with a custom NegotiateSecurityFilter that correctly connects to my corporate Windows NTLM environment. This is good, except I can't really mock this behavior for dev/qa environments, where we don't have the ActiveDirectory present. Is there an existing Mocking Solution for NegotiateSecurityFilter or WindowsIdentity already that I can use? 

Worst case, I have a few ideas on providing flags to the custom NegotiateSecurityFilter to mock WindowsIdentity based on the environment but that seems far stretched.

Appreciate your suggestions.

Dec 23, 2011 at 9:02 PM

Take a look at the waffle source code under JNAWindowsAuthProvider/src-test/mock. MockWindowsAuthProvider is what you want, there're tests such as in http://waffle.codeplex.com/SourceControl/changeset/view/69234#1106346 that do this kind of stuff.

SimpleFilterConfig filterConfig = new SimpleFilterConfig();
filterConfig.setParameter("authProvider", MockWindowsAuthProvider.class.getName());

Yes, this is built by professionals :)