parent
897386ab3f
commit
0b5973e501
|
|
@ -43,14 +43,22 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
|
|
||||||
public static void SetWindowsAuth(this IISDeploymentParameters parameters, bool enabled = true)
|
public static void SetWindowsAuth(this IISDeploymentParameters parameters, bool enabled = true)
|
||||||
{
|
{
|
||||||
|
parameters.EnsureSection("windowsAuthentication", "system.webServer", "security", "windowsAuthentication");
|
||||||
parameters.EnableModule("WindowsAuthenticationModule", "%IIS_BIN%\\authsspi.dll");
|
parameters.EnableModule("WindowsAuthenticationModule", "%IIS_BIN%\\authsspi.dll");
|
||||||
|
|
||||||
parameters.AddServerConfigAction(
|
parameters.AddServerConfigAction(
|
||||||
element =>
|
element =>
|
||||||
{
|
{
|
||||||
element.Descendants("windowsAuthentication")
|
var windowsAuthentication = element
|
||||||
.Single()
|
.RequiredElement("system.webServer")
|
||||||
.SetAttributeValue("enabled", enabled);
|
.RequiredElement("security")
|
||||||
|
.RequiredElement("authentication")
|
||||||
|
.GetOrAdd("windowsAuthentication");
|
||||||
|
|
||||||
|
windowsAuthentication.SetAttributeValue("enabled", enabled);
|
||||||
|
var providers = windowsAuthentication.GetOrAdd("providers");
|
||||||
|
providers.GetOrAdd("add", "value", "Negotiate");
|
||||||
|
providers.GetOrAdd("add", "value", "NTLM");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,8 +67,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
parameters.AddServerConfigAction(
|
parameters.AddServerConfigAction(
|
||||||
element =>
|
element =>
|
||||||
{
|
{
|
||||||
element.Descendants("anonymousAuthentication")
|
element
|
||||||
.Single()
|
.RequiredElement("system.webServer")
|
||||||
|
.RequiredElement("security")
|
||||||
|
.RequiredElement("authentication")
|
||||||
|
.GetOrAdd("anonymousAuthentication")
|
||||||
.SetAttributeValue("enabled", enabled);
|
.SetAttributeValue("enabled", enabled);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -72,12 +83,33 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
parameters.AddServerConfigAction(
|
parameters.AddServerConfigAction(
|
||||||
element =>
|
element =>
|
||||||
{
|
{
|
||||||
element.Descendants("basicAuthentication")
|
element
|
||||||
.Single()
|
.RequiredElement("system.webServer")
|
||||||
|
.RequiredElement("security")
|
||||||
|
.RequiredElement("authentication")
|
||||||
|
.GetOrAdd("basicAuthentication")
|
||||||
.SetAttributeValue("enabled", enabled);
|
.SetAttributeValue("enabled", enabled);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void EnsureSection(this IISDeploymentParameters parameters, string name, params string[] path)
|
||||||
|
{
|
||||||
|
parameters.ServerConfigActionList.Add(
|
||||||
|
(config, _) => {
|
||||||
|
|
||||||
|
var element = config
|
||||||
|
.RequiredElement("configSections");
|
||||||
|
|
||||||
|
foreach (var s in path)
|
||||||
|
{
|
||||||
|
element = element.GetOrAdd("sectionGroup", "name", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
element.GetOrAdd("section", "name", "applicationInitialization")
|
||||||
|
.SetAttributeValue("overrideModeDefault", "Allow");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void EnableLogging(this IISDeploymentParameters deploymentParameters, string path)
|
public static void EnableLogging(this IISDeploymentParameters deploymentParameters, string path)
|
||||||
{
|
{
|
||||||
deploymentParameters.WebConfigActionList.Add(
|
deploymentParameters.WebConfigActionList.Add(
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
.WithAllAncmVersions()
|
.WithAllAncmVersions()
|
||||||
.WithAllHostingModels();
|
.WithAllHostingModels();
|
||||||
|
|
||||||
[ConditionalTheory(Skip = "This test is manual. To run it set ASPNETCORE_MODULE_TEST_USER and ASPNETCORE_MODULE_TEST_PASSWORD environment variables to existing user")]
|
[ConditionalTheory]
|
||||||
|
[RequiresEnvironmentVariable("ASPNETCORE_MODULE_TEST_USER")]
|
||||||
[RequiresIIS(IISCapability.BasicAuthentication)]
|
[RequiresIIS(IISCapability.BasicAuthentication)]
|
||||||
[MemberData(nameof(TestVariants))]
|
[MemberData(nameof(TestVariants))]
|
||||||
public async Task BasicAuthTest(TestVariant variant)
|
public async Task BasicAuthTest(TestVariant variant)
|
||||||
|
|
@ -63,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We expect out-of-proc not allowing basic auth
|
// We expect out-of-proc not allowing basic auth
|
||||||
Assert.Equal("Windows:", responseText);
|
Assert.Equal("Windows", responseText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
|
||||||
|
public sealed class RequiresEnvironmentVariableAttribute : Attribute, ITestCondition
|
||||||
|
{
|
||||||
|
private readonly string _name;
|
||||||
|
|
||||||
|
public RequiresEnvironmentVariableAttribute(string name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsMet => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(_name));
|
||||||
|
|
||||||
|
public string SkipReason => $"Environment variable {_name} is required to run this test.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -78,13 +78,9 @@ namespace IIS.FunctionalTests
|
||||||
|
|
||||||
private static void EnablePreload(IISDeploymentParameters baseDeploymentParameters)
|
private static void EnablePreload(IISDeploymentParameters baseDeploymentParameters)
|
||||||
{
|
{
|
||||||
|
baseDeploymentParameters.EnsureSection("applicationInitialization", "system.webServer");
|
||||||
baseDeploymentParameters.ServerConfigActionList.Add(
|
baseDeploymentParameters.ServerConfigActionList.Add(
|
||||||
(config, _) => {
|
(config, _) => {
|
||||||
config
|
|
||||||
.RequiredElement("configSections")
|
|
||||||
.GetOrAdd("sectionGroup", "name", "system.webServer")
|
|
||||||
.GetOrAdd("section", "name", "applicationInitialization")
|
|
||||||
.SetAttributeValue("overrideModeDefault", "Allow");
|
|
||||||
|
|
||||||
config
|
config
|
||||||
.RequiredElement("system.applicationHost")
|
.RequiredElement("system.applicationHost")
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ function Setup-appverif($application)
|
||||||
|
|
||||||
function Shutdown-appverif($application)
|
function Shutdown-appverif($application)
|
||||||
{
|
{
|
||||||
setx APPVERIFIER_ENABLED_CODES "`"`"";
|
setx APPVERIFIER_ENABLED_CODES "NONE";
|
||||||
setx APPVERIFIER_LEVEL "`"`"";
|
setx APPVERIFIER_LEVEL "NONE";
|
||||||
|
|
||||||
appverif.exe -disable * -for $application
|
appverif.exe -disable * -for $application
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue