public void TestIisExpressInvalidSection()
{
var directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Environment.SetEnvironmentVariable("JEXUS_TEST_HOME", directoryName);
if (directoryName == null)
{
return;
}
string Current = Path.Combine(directoryName, @"applicationHost.config");
string Original = Path.Combine(directoryName, @"original2.config");
TestHelper.CopySiteConfig(directoryName, "original_invalid_section.config");
File.Copy(Original, Current, true);
TestHelper.FixPhysicalPathMono(Current);
#if IIS
var server = new ServerManager(Current);
#else
var server = new IisExpressServerManager(Current);
#endif
var config = server.Sites[0].Applications[0].GetWebConfiguration();
var exception = Assert.Throws<FileLoadException>(
() =>
{
// enable Windows authentication
var windowsSection =
config.GetSection("system.webServer/security/authentication/windowsAuthentication");
});
var siteConfig = Path.Combine(directoryName, "WebSite1", "web.config");
Assert.Equal(
string.Format(
"Filename: \\\\?\\{0}\r\nLine number: 11\r\nError: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=\"Deny\"), or set explicitly by a location tag with overrideMode=\"Deny\" or the legacy allowOverride=\"false\".\r\n\r\n",
siteConfig),
exception.Message);
}