Use TestApplication (#1118)

This commit is contained in:
Pavel Krymets 2018-07-31 19:32:48 -07:00 committed by GitHub
parent ff0a5bbbdf
commit 4b5a32d3b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 236 additions and 152 deletions

View File

@ -4,38 +4,38 @@
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17102</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAllPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreAllPackageVersion>
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
<MicrosoftAspNetCoreHttpOverridesPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreHttpOverridesPackageVersion>
<MicrosoftAspNetCoreHttpPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreHttpPackageVersion>
<MicrosoftAspNetCoreHttpSysSourcesPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreHttpSysSourcesPackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.6.0-preview1-34823</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.2.0-preview1-34823</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17099</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAllPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreAllPackageVersion>
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
<MicrosoftAspNetCoreHttpOverridesPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreHttpOverridesPackageVersion>
<MicrosoftAspNetCoreHttpPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreHttpPackageVersion>
<MicrosoftAspNetCoreHttpSysSourcesPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreHttpSysSourcesPackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.6.0-a-preview1-test-application-17108</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.2.0-preview1-34825</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
<MicrosoftBuildFrameworkPackageVersion>15.6.82</MicrosoftBuildFrameworkPackageVersion>
<MicrosoftBuildUtilitiesCorePackageVersion>15.6.82</MicrosoftBuildUtilitiesCorePackageVersion>
<MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsConfigurationJsonPackageVersion>
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingDebugPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsLoggingDebugPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsOptionsPackageVersion>2.2.0-preview1-34823</MicrosoftExtensionsOptionsPackageVersion>
<MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsConfigurationJsonPackageVersion>
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingDebugPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsLoggingDebugPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsOptionsPackageVersion>2.2.0-preview1-34825</MicrosoftExtensionsOptionsPackageVersion>
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.2</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview1-26618-02</MicrosoftNETCoreApp22PackageVersion>
<MicrosoftNETCoreWindowsApiSetsPackageVersion>1.0.1</MicrosoftNETCoreWindowsApiSetsPackageVersion>
<MicrosoftNetHttpHeadersPackageVersion>2.2.0-preview1-34823</MicrosoftNetHttpHeadersPackageVersion>
<MicrosoftNetHttpHeadersPackageVersion>2.2.0-preview1-34825</MicrosoftNetHttpHeadersPackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
<MicrosoftWebAdministrationPackageVersion>11.1.0</MicrosoftWebAdministrationPackageVersion>
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>

View File

@ -7,6 +7,7 @@
<IISAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.iis.config</IISAppHostConfig>
<NativePlatform Condition="'$(Platform)' == 'AnyCPU'">x64</NativePlatform>
<NativePlatform Condition="'$(NativePlatform)' == ''">$(Platform)</NativePlatform>
<PreserveCompilationContext>false</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup Condition="'$(NativePlatform)' == 'x86'">
@ -51,7 +52,7 @@
<Target Name="CopyLaunchSettings" AfterTargets="CoreBuild">
<!-- This would always override launch settings files in test projects by the default one -->
<Copy SourceFiles="$(MSBuildThisFileDirectory)launchSettings.json" DestinationFolder="$(MSBuildProjectDirectory)\Properties" />
<Copy SourceFiles="$(MSBuildThisFileDirectory)launchSettings.json" DestinationFolder="$(MSBuildProjectDirectory)\Properties" SkipUnchangedFiles="true" />
</Target>
<!-- Deps file injection-->

View File

@ -14,10 +14,18 @@ using Microsoft.Extensions.Logging;
using Xunit;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.Inprocess
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class AppOfflineTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public AppOfflineTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalTheory]
[InlineData(HostingModel.InProcess)]
[InlineData(HostingModel.OutOfProcess)]
@ -36,8 +44,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.Inprocess
[InlineData(HostingModel.OutOfProcess, 502, "502.5")]
public async Task AppOfflineDroppedWhileSiteFailedToStartInShim_AppOfflineServed(HostingModel hostingModel, int statusCode, string content)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(hostingModel: hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: hostingModel, publish: true);
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", "nonexistent"));
var deploymentResult = await DeployAsync(deploymentParameters);
@ -193,10 +200,9 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.Inprocess
}
}
private async Task<IISDeploymentResult> DeployApp(HostingModel hostingModel = HostingModel.InProcess)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(hostingModel: hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: hostingModel, publish: true);
return await DeployAsync(deploymentParameters);
}

View File

@ -9,12 +9,20 @@ using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class EventLogTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public EventLogTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalFact]
public async Task CheckStartupEventLogMessage()
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentResult = await DeployAsync(deploymentParameters);
await Helpers.AssertStarts(deploymentResult);
@ -26,7 +34,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task CheckShutdownEventLogMessage()
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.GracefulShutdown = true;
var deploymentResult = await DeployAsync(deploymentParameters);
await Helpers.AssertStarts(deploymentResult);

View File

@ -14,14 +14,22 @@ using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class LoggingTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public LoggingTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalTheory]
[InlineData("CheckErrLogFile")]
[InlineData("CheckLogFile")]
public async Task CheckStdoutLoggingToFile(string path)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.WebConfigActionList.Add(
WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true"));
@ -63,7 +71,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task InvalidFilePathForLogs_ServerStillRuns()
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.WebConfigActionList.Add(
WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true"));
@ -82,7 +90,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var tempFile = Path.GetTempFileName();
try
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"] = tempFile;
deploymentParameters.AddDebugLogToWebConfig(tempFile);
@ -107,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("CheckLogFile")]
public async Task CheckStdoutLoggingToPipe_DoesNotCrashProcess(string path)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.GracefulShutdown = true;
var deploymentResult = await DeployAsync(deploymentParameters);
@ -126,7 +134,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("CheckLogFile")]
public async Task CheckStdoutLoggingToPipeWithFirstWrite(string path)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.GracefulShutdown = true;
var firstWriteString = path + path;
@ -156,7 +164,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
try
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"] = firstTempFile;
deploymentParameters.AddDebugLogToWebConfig(secondTempFile);

View File

@ -10,8 +10,16 @@ using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class StartupExceptionTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public StartupExceptionTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalTheory]
[InlineData("CheckLogFile")]
[InlineData("CheckErrLogFile")]
@ -21,7 +29,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
// Reason is because by default for IISExpress, we expect there to not be a web.config file.
// However, for IIS, we need a web.config file because the default on generated on publish
// doesn't include V2. We can remove the publish flag once IIS supports non-publish running
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite", publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true);
var randomNumberString = new Random(Guid.NewGuid().GetHashCode()).Next(10000000).ToString();
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
@ -45,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("CheckOversizedStdOutWrites")]
public async Task CheckStdoutWithLargeWrites(string path)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite", publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true);
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
var deploymentResult = await DeployAsync(deploymentParameters);
@ -62,7 +70,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task Gets500_30_ErrorPage()
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite", publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true);
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -2,21 +2,22 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class HelloWorldTests : IISFunctionalTestBase
{
public HelloWorldTests(ITestOutputHelper output = null) : base(output)
private readonly PublishedSitesFixture _fixture;
public HelloWorldTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
public static TestMatrix TestVariants
@ -31,10 +32,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
// The default in hosting sets windows auth to true.
// Set it to the IISExpress.config file
var deploymentParameters = new IISDeploymentParameters(variant)
{
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath()
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -0,0 +1,70 @@
// 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.Server.IntegrationTesting.IIS;
using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
/// <summary>
/// This type just maps collection names to available fixtures
/// </summary>
[CollectionDefinition(Name)]
public class PublishedSitesCollection : ICollectionFixture<PublishedSitesFixture>
{
public const string Name = nameof(PublishedSitesCollection);
}
public class PublishedSitesFixture : IDisposable
{
public CachingApplicationPublisher InProcessTestSite { get; } = new CachingApplicationPublisher(Helpers.GetInProcessTestSitesPath());
public CachingApplicationPublisher OutOfProcessTestSite { get; } = new CachingApplicationPublisher(Helpers.GetOutOfProcessTestSitesPath());
public CachingApplicationPublisher StartupExceptionWebsite { get; } = new CachingApplicationPublisher(Helpers.GetTestWebSitePath("StartupExceptionWebsite"));
public CachingApplicationPublisher OverriddenServerWebSite { get; } = new CachingApplicationPublisher(Helpers.GetTestWebSitePath("OverriddenServerWebSite"));
public void Dispose()
{
InProcessTestSite.Dispose();
OutOfProcessTestSite.Dispose();
StartupExceptionWebsite.Dispose();
OverriddenServerWebSite.Dispose();
}
public IISDeploymentParameters GetBaseDeploymentParameters(HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
{
var publisher = hostingModel == HostingModel.InProcess ? InProcessTestSite : OutOfProcessTestSite;
return GetBaseDeploymentParameters(publisher, hostingModel, publish);
}
public IISDeploymentParameters GetBaseDeploymentParameters(TestVariant variant, bool publish = false)
{
var publisher = variant.HostingModel == HostingModel.InProcess ? InProcessTestSite : OutOfProcessTestSite;
return GetBaseDeploymentParameters(publisher, new DeploymentParameters(variant), publish);
}
public IISDeploymentParameters GetBaseDeploymentParameters(ApplicationPublisher publisher, HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
{
return GetBaseDeploymentParameters(
publisher,
new DeploymentParameters(publisher.ApplicationPath, DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
{
HostingModel = hostingModel
},
publish);
}
public IISDeploymentParameters GetBaseDeploymentParameters(ApplicationPublisher publisher, DeploymentParameters baseParameters, bool publish = false)
{
return new IISDeploymentParameters(baseParameters)
{
ApplicationPublisher = publisher,
ApplicationPath = publisher.ApplicationPath,
TargetFramework = Tfm.NetCoreApp22,
ApplicationType = ApplicationType.Portable,
AncmVersion = AncmVersion.AspNetCoreModuleV2,
PublishApplicationBeforeDeployment = publish,
};
}
}
}

View File

@ -1,6 +1,7 @@
// 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 System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
@ -31,6 +32,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
parameters.ServerConfigTemplateContent = parameters.ServerConfigTemplateContent ?? File.ReadAllText("IISExpress.config");
}
if (parameters.ApplicationPublisher == null)
{
throw new InvalidOperationException("All tests should use ApplicationPublisher");
}
_deployer = IISApplicationDeployerFactory.Create(parameters, LoggerFactory);

View File

@ -25,24 +25,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public static string GetInProcessTestSitesPath() => GetTestWebSitePath("InProcessWebSite");
public static string GetOutOfProcessTestSitesPath() => GetTestWebSitePath("OutOfProcessWebSite");
// Defaults to inprocess specific deployment parameters
public static IISDeploymentParameters GetBaseDeploymentParameters(string site = null, HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
{
if (site == null)
{
site = hostingModel == HostingModel.InProcess ? "InProcessWebSite" : "OutOfProcessWebSite";
}
return new IISDeploymentParameters(GetTestWebSitePath(site), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
{
TargetFramework = Tfm.NetCoreApp22,
ApplicationType = ApplicationType.Portable,
AncmVersion = AncmVersion.AspNetCoreModuleV2,
HostingModel = hostingModel,
PublishApplicationBeforeDeployment = publish,
};
}
public static async Task AssertStarts(IISDeploymentResult deploymentResult, string path = "/HelloWorld")
{

View File

@ -11,13 +11,20 @@ using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class AuthenticationTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public AuthenticationTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalFact]
public async Task Authentication_InProcess()
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.AddWindowsAuthToServerConfig();
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -9,21 +9,23 @@ using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class ShutdownTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public ShutdownTests(ITestOutputHelper output) : base(output)
public ShutdownTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalFact]
public async Task ServerShutsDownWhenMainExits()
{
var parameters = Helpers.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var result = await DeployAsync(parameters);
try
{
@ -39,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task GracefulShutdown_DoesNotCrashProcess()
{
var parameters = Helpers.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
parameters.GracefulShutdown = true;
var result = await DeployAsync(parameters);
@ -51,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ForcefulShutdown_DoesrashProcess()
{
var parameters = Helpers.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var result = await DeployAsync(parameters);
var response = await result.RetryingHttpClient.GetAsync("/HelloWorld");

View File

@ -11,18 +11,21 @@ using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class StartupTests : IISFunctionalTestBase
{
private readonly string _dotnetLocation = DotNetCommands.GetDotNetExecutable(RuntimeArchitecture.x64);
private readonly PublishedSitesFixture _fixture;
public StartupTests(ITestOutputHelper output) : base(output)
public StartupTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
private readonly string _dotnetLocation = DotNetCommands.GetDotNetExecutable(RuntimeArchitecture.x64);
[ConditionalFact]
public async Task ExpandEnvironmentVariableInWebConfig()
{
@ -42,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData(".\\dotnet.exe")]
public async Task InvalidProcessPath_ExpectServerError(string path)
{
var deploymentParameters = GetBaseDeploymentParameters();
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", path));
@ -99,7 +102,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task AssertStarts(Action<IISDeploymentParameters> preDeploy = null)
{
var deploymentParameters = GetBaseDeploymentParameters();
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
preDeploy?.Invoke(deploymentParameters);
@ -121,11 +124,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task HelloWorld(TestVariant variant)
{
var deploymentParameters = new IISDeploymentParameters(variant)
{
ApplicationPath = Helpers.GetInProcessTestSitesPath(),
PublishApplicationBeforeDeployment = true
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentResult = await DeployAsync(deploymentParameters);
@ -138,7 +137,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task DetectsOveriddenServer()
{
var deploymentResult = await DeployAsync(GetBaseDeploymentParameters("OverriddenServerWebSite"));
var deploymentResult = await DeployAsync(_fixture.GetBaseDeploymentParameters(_fixture.OverriddenServerWebSite, publish: true));
var response = await deploymentResult.HttpClient.GetAsync("/");
Assert.False(response.IsSuccessStatusCode);
@ -150,7 +149,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task CheckInvalidHostingModelParameter()
{
var deploymentParameters = GetBaseDeploymentParameters();
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("hostingModel", "bogus"));
var deploymentResult = await DeployAsync(deploymentParameters);
@ -161,18 +160,5 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
EventLogHelpers.VerifyEventLogEvent(TestSink, "Unknown hosting model 'bogus'. Please specify either hostingModel=\"inprocess\" or hostingModel=\"outofprocess\" in the web.config file.");
}
// Defaults to inprocess specific deployment parameters
public static IISDeploymentParameters GetBaseDeploymentParameters(string site = "InProcessWebSite")
{
return new IISDeploymentParameters(Helpers.GetTestWebSitePath(site), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
{
TargetFramework = Tfm.NetCoreApp22,
ApplicationType = ApplicationType.Portable,
AncmVersion = AncmVersion.AspNetCoreModuleV2,
HostingModel = HostingModel.InProcess,
PublishApplicationBeforeDeployment = site == "InProcessWebSite",
};
}
}
}

View File

@ -13,13 +13,20 @@ using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class GlobalVersionTests : IISFunctionalTestBase
{
private readonly PublishedSitesFixture _fixture;
public GlobalVersionTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
private const string _aspNetCoreDll = "aspnetcorev2_outofprocess.dll";
private const string _handlerVersion20 = "2.0.0";
private const string _helloWorldRequest = "HelloWorld";
private const string _helloWorldResponse = "Hello World";
private const string _outOfProcessVersionVariable = "/p:AspNetCoreModuleOutOfProcessVersion=";
[ConditionalFact]
public async Task GlobalVersion_DefaultWorks()
@ -65,11 +72,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task GlobalVersion_NewVersionNumber(string version)
{
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
deploymentParameters.AdditionalPublishParameters = $"{_outOfProcessVersionVariable}{version}";
deploymentParameters.HandlerSettings["handlerVersion"] = version;
var deploymentResult = await DeployAsync(deploymentParameters);
var originalANCMPath = GetANCMRequestHandlerPath(deploymentResult, _handlerVersion20);
var newANCMPath = GetANCMRequestHandlerPath(deploymentResult, version);
Directory.Move(originalANCMPath, newANCMPath);
var response = await deploymentResult.RetryingHttpClient.GetAsync(_helloWorldRequest);
var responseText = await response.Content.ReadAsStringAsync();
Assert.Equal(_helloWorldResponse, responseText);
@ -89,9 +99,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var newANCMPath = GetANCMRequestHandlerPath(deploymentResult, version);
var di = Directory.CreateDirectory(Path.GetDirectoryName(newANCMPath));
File.Copy(originalANCMPath, newANCMPath, true);
CopyDirectory(originalANCMPath, newANCMPath);
deploymentResult.RetryingHttpClient.DefaultRequestHeaders.Add("ANCMRHPath", newANCMPath);
var response = await deploymentResult.RetryingHttpClient.GetAsync("CheckRequestHandlerVersion");
@ -125,9 +133,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var newANCMPath = GetANCMRequestHandlerPath(deploymentResult, version);
var di = Directory.CreateDirectory(Path.GetDirectoryName(newANCMPath));
File.Copy(originalANCMPath, newANCMPath, true);
CopyDirectory(originalANCMPath, newANCMPath);
deploymentResult.RetryingHttpClient.DefaultRequestHeaders.Add("ANCMRHPath", newANCMPath);
response = await deploymentResult.RetryingHttpClient.GetAsync("CheckRequestHandlerVersion");
@ -139,23 +145,25 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private IISDeploymentParameters GetGlobalVersionBaseDeploymentParameters()
{
return new IISDeploymentParameters(Helpers.GetOutOfProcessTestSitesPath(), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
return _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
}
private void CopyDirectory(string from, string to)
{
var toInfo = new DirectoryInfo(to);
toInfo.Create();
foreach (var file in new DirectoryInfo(from).GetFiles())
{
TargetFramework = Tfm.NetCoreApp22,
ApplicationType = ApplicationType.Portable,
AncmVersion = AncmVersion.AspNetCoreModuleV2,
HostingModel = HostingModel.OutOfProcess,
PublishApplicationBeforeDeployment = true,
AdditionalPublishParameters = $"{_outOfProcessVersionVariable}{_handlerVersion20}"
};
file.CopyTo(Path.Combine(toInfo.FullName, file.Name));
}
}
private string GetANCMRequestHandlerPath(IISDeploymentResult deploymentResult, string version)
{
return Path.Combine(deploymentResult.ContentRoot,
deploymentResult.DeploymentParameters.RuntimeArchitecture.ToString(),
version,
_aspNetCoreDll);
version);
}
private void AssertLoadedVersion(string version)

View File

@ -18,10 +18,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
// So these tests always have to use ports in this range, and we can't rely on OS-allocated ports without a whole lot of ceremony around
// creating self-signed certificates and registering SSL bindings with HTTP.sys
// Test specific to IISExpress
[Collection(PublishedSitesCollection.Name)]
public class HttpsTest : IISFunctionalTestBase
{
public HttpsTest(ITestOutputHelper output) : base(output)
private readonly PublishedSitesFixture _fixture;
public HttpsTest(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
public static TestMatrix TestVariants
@ -34,12 +38,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task HttpsHelloWorld(TestVariant variant)
{
var port = TestPortHelper.GetNextSSLPort();
var deploymentParameters = new IISDeploymentParameters(variant)
{
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
ApplicationBaseUriHint = $"https://localhost:{port}/"
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/";
deploymentParameters.AddHttpsToServerConfig();
var deploymentResult = await DeployAsync(deploymentParameters);
@ -73,12 +73,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task HttpsHelloWorldCerts(TestVariant variant, bool sendClientCert)
{
var port = TestPortHelper.GetNextSSLPort();
var deploymentParameters = new IISDeploymentParameters(variant)
{
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
ApplicationBaseUriHint = $"https://localhost:{port}/",
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/";
deploymentParameters.AddHttpsToServerConfig();
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -13,14 +13,19 @@ using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class NtlmAuthenticationTests : IISFunctionalTestBase
{
// Test only runs on IISExpress today as our CI machines do not have
// Windows auth installed globally.
// TODO either enable windows auth on our CI or use containers to test this
// behavior
public NtlmAuthenticationTests(ITestOutputHelper output) : base(output)
private readonly PublishedSitesFixture _fixture;
public NtlmAuthenticationTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
public static TestMatrix TestVariants
@ -32,11 +37,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task NtlmAuthentication(TestVariant variant)
{
var deploymentParameters = new IISDeploymentParameters(variant)
{
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
ApplicationBaseUriHint = $"http://localhost:0/"
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:0/";
deploymentParameters.AddWindowsAuthToServerConfig();

View File

@ -12,10 +12,14 @@ using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class WindowsAuthTests : IISFunctionalTestBase
{
public WindowsAuthTests(ITestOutputHelper output = null) : base(output)
private readonly PublishedSitesFixture _fixture;
public WindowsAuthTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
public static TestMatrix TestVariants
@ -28,10 +32,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task WindowsAuthTest(TestVariant variant)
{
var deploymentParameters = new IISDeploymentParameters(variant)
{
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.AddWindowsAuthToServerConfig();
// The default in hosting sets windows auth to true.

View File

@ -9,16 +9,18 @@ using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(PublishedSitesCollection.Name)]
public class UpgradeFeatureDetectionTests : IISFunctionalTestBase
{
private readonly string _isWebsocketsSupported = Environment.OSVersion.Version >= new Version(6, 2) ? "Enabled" : "Disabled";
private readonly PublishedSitesFixture _fixture;
public UpgradeFeatureDetectionTests(ITestOutputHelper output) : base(output)
public UpgradeFeatureDetectionTests(PublishedSitesFixture fixture)
{
_fixture = fixture;
}
[ConditionalFact]
@ -60,14 +62,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task UpgradeFeatureDetectionDeployer(bool disableWebSocket, string sitePath, string expected, HostingModel hostingModel)
{
var deploymentParameters = new IISDeploymentParameters(sitePath, DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
{
TargetFramework = Tfm.NetCoreApp22,
ApplicationType = ApplicationType.Portable,
AncmVersion = AncmVersion.AspNetCoreModuleV2,
HostingModel = hostingModel,
PublishApplicationBeforeDeployment = hostingModel == HostingModel.InProcess
};
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
if (disableWebSocket)
{