Best way for unit testing authorization issues

bri189a

Senior Contributor
Joined
Sep 11, 2003
Location
VA
I'm not sure the best way to do this. I need to write some unit tests that test that certain users have the ability to do certain things; the objects have role based permissions.

The problem is that in order to do this I have to impersonate one of 4 test users to get the permission set that is going to be tested. While impersonating myself is quite easy I can't find any .NET libraries that allow me to create a Windows identity/principal and make the unit test run in the context of that user.

Any ideas would be greatly appreciated. I'd prefer not to hit the Windows API's if possible; if that is the only solution, a pointer to someone who has already wrapped LogonUser or whatever it is (don't remember) would great.
 

bri189a

Senior Contributor
Joined
Sep 11, 2003
Location
VA
Thanks PD...the code project link was exactly what I needed. Good re-usable class that has comments and implements disposing...nice to see good contributions like that.
 
Top Bottom