ExpectedException and AspNetHostingPermission attributes for testing Medium Trust ASP.Net environment
Ron Grabowski <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <[email protected]> |
I'm trying to emulate a ASP.Net Medium Trust environment to make sure SecurityExceptions are handled properly. The first test passes ok because it catches the SecurityException:
[Test]
[ExpectedException(typeof(SecurityException))]
[AspNetHostingPermission(SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.Medium)]
public void Can_only_access_certain_environment_variables_under_Medium_Trust()
{
Environment.GetEnvironmentVariable("USERNAME");
}
This test throws a SecurityException even though I'm running under Full Trust:
[Test]
[AspNetHostingPermission(SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.Unrestricted)]
public void All_environment_variables_are_accessible_under_Full_Trust()
{
Environment.GetEnvironmentVariable("USERNAME");
}
Any ideas why the second test is failing?
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone