From 72830ea943a79c30190f1ed6dc5619ef54ef6a02 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 20 Dec 2018 10:19:55 -0800 Subject: [PATCH] Set current directory by default (#4798) --- .../InProcessRequestHandler/InProcessOptions.cpp | 2 +- .../Common.FunctionalTests/Inprocess/ErrorPagesTests.cs | 2 +- .../Inprocess/HostingEnvironmentTests.cs | 2 +- .../test/Common.FunctionalTests/Inprocess/StartupTests.cs | 5 ++--- .../Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs | 8 ++++++-- .../IIS/test/Common.FunctionalTests/RequiresNewHandler.cs | 2 +- .../IIS/test/Common.FunctionalTests/RequiresNewShim.cs | 2 +- .../DeployerSelector.cs | 3 ++- .../DeployerSelector.cs | 3 ++- .../IIS/test/IIS.FunctionalTests/DeployerSelector.cs | 3 ++- .../test/IISExpress.FunctionalTests/DeployerSelector.cs | 3 ++- 11 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Servers/IIS/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessOptions.cpp b/src/Servers/IIS/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessOptions.cpp index 346df2c107..a179884242 100644 --- a/src/Servers/IIS/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessOptions.cpp +++ b/src/Servers/IIS/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessOptions.cpp @@ -55,7 +55,7 @@ InProcessOptions::InProcessOptions(const ConfigurationSource &configurationSourc m_environmentVariables = aspNetCoreSection->GetKeyValuePairs(CS_ASPNETCORE_ENVIRONMENT_VARIABLES); const auto handlerSettings = aspNetCoreSection->GetKeyValuePairs(CS_ASPNETCORE_HANDLER_SETTINGS); - m_fSetCurrentDirectory = equals_ignore_case(find_element(handlerSettings, CS_ASPNETCORE_HANDLER_SET_CURRENT_DIRECTORY).value_or(L"false"), L"true"); + m_fSetCurrentDirectory = equals_ignore_case(find_element(handlerSettings, CS_ASPNETCORE_HANDLER_SET_CURRENT_DIRECTORY).value_or(L"true"), L"true"); m_dwStartupTimeLimitInMS = aspNetCoreSection->GetRequiredLong(CS_ASPNETCORE_PROCESS_STARTUP_TIME_LIMIT) * 1000; m_dwShutdownTimeLimitInMS = aspNetCoreSection->GetRequiredLong(CS_ASPNETCORE_PROCESS_SHUTDOWN_TIME_LIMIT) * 1000; diff --git a/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/ErrorPagesTests.cs b/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/ErrorPagesTests.cs index bf45949491..f53571001e 100644 --- a/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/ErrorPagesTests.cs +++ b/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/ErrorPagesTests.cs @@ -105,7 +105,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests private static void VerifyNoExtraTrailingBytes(string responseString) { - if (!DeployerSelector.IsBackwardsCompatiblityTest) + if (DeployerSelector.HasNewShim) { Assert.EndsWith("\r\n", responseString); } diff --git a/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/HostingEnvironmentTests.cs b/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/HostingEnvironmentTests.cs index 3f9c61e5e4..3c2df6cb84 100644 --- a/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/HostingEnvironmentTests.cs +++ b/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/HostingEnvironmentTests.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { Assert.Equal(_fixture.DeploymentResult.ContentRoot, await _fixture.Client.GetStringAsync("/ContentRootPath")); Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\wwwroot", await _fixture.Client.GetStringAsync("/WebRootPath")); - Assert.Equal(Path.GetDirectoryName(_fixture.DeploymentResult.HostProcess.MainModule.FileName), await _fixture.Client.GetStringAsync("/CurrentDirectory")); + Assert.Equal(_fixture.DeploymentResult.ContentRoot, await _fixture.DeploymentResult.HttpClient.GetStringAsync("/CurrentDirectory")); Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\", await _fixture.Client.GetStringAsync("/BaseDirectory")); Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\", await _fixture.Client.GetStringAsync("/ASPNETCORE_IIS_PHYSICAL_PATH")); } diff --git a/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs b/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs index 0a1539ff42..db1570b960 100644 --- a/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs +++ b/src/Servers/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs @@ -454,16 +454,15 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public async Task SetCurrentDirectoryHandlerSettingWorks() { var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); - deploymentParameters.HandlerSettings["SetCurrentDirectory"] = "true"; + deploymentParameters.HandlerSettings["SetCurrentDirectory"] = "false"; var deploymentResult = await DeployAsync(deploymentParameters); Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/ContentRootPath")); Assert.Equal(deploymentResult.ContentRoot + "\\wwwroot", await deploymentResult.HttpClient.GetStringAsync("/WebRootPath")); - Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory")); + Assert.Equal(Path.GetDirectoryName(deploymentResult.HostProcess.MainModule.FileName), await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory")); Assert.Equal(deploymentResult.ContentRoot + "\\", await deploymentResult.HttpClient.GetStringAsync("/BaseDirectory")); Assert.Equal(deploymentResult.ContentRoot + "\\", await deploymentResult.HttpClient.GetStringAsync("/ASPNETCORE_IIS_PHYSICAL_PATH")); - Assert.Equal(Path.GetDirectoryName(deploymentResult.HostProcess.MainModule.FileName), await deploymentResult.HttpClient.GetStringAsync("/DllDirectory")); } private static void MoveApplication( diff --git a/src/Servers/IIS/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs b/src/Servers/IIS/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs index 68cfdbb0d8..a76f8c2095 100644 --- a/src/Servers/IIS/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs +++ b/src/Servers/IIS/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs @@ -71,10 +71,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/ContentRootPath")); Assert.Equal(deploymentResult.ContentRoot + "\\wwwroot", await deploymentResult.HttpClient.GetStringAsync("/WebRootPath")); - Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory")); - var expectedDll = variant.AncmVersion == AncmVersion.AspNetCoreModule ? "aspnetcore.dll" : "aspnetcorev2.dll"; Assert.Contains(deploymentResult.HostProcess.Modules.OfType(), m=> m.FileName.Contains(expectedDll)); + + if (DeployerSelector.HasNewHandler && variant.HostingModel == HostingModel.InProcess) + { + Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory")); + Assert.Equal(Path.GetDirectoryName(deploymentResult.HostProcess.MainModule.FileName), await deploymentResult.HttpClient.GetStringAsync("/DllDirectory")); + } } } } diff --git a/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewHandler.cs b/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewHandler.cs index cbe43ec0c7..e768df3bb6 100644 --- a/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewHandler.cs +++ b/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewHandler.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)] public sealed class RequiresNewHandlerAttribute : Attribute, ITestCondition { - public bool IsMet => !DeployerSelector.IsForwardsCompatibilityTest; + public bool IsMet => DeployerSelector.HasNewHandler; public string SkipReason => "Test verifies new behavior in the aspnetcorev2_inprocess.dll that isn't supported in earlier versions."; } diff --git a/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewShim.cs b/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewShim.cs index b0bc50a83b..3f9b5cae8b 100644 --- a/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewShim.cs +++ b/src/Servers/IIS/test/Common.FunctionalTests/RequiresNewShim.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)] public sealed class RequiresNewShimAttribute : Attribute, ITestCondition { - public bool IsMet => !DeployerSelector.IsBackwardsCompatiblityTest; + public bool IsMet => DeployerSelector.HasNewShim; public string SkipReason => "Test verifies new behavior in the aspnetcorev2.dll that isn't supported in earlier versions."; } diff --git a/src/Servers/IIS/test/IIS.BackwardsCompatibility.FunctionalTests/DeployerSelector.cs b/src/Servers/IIS/test/IIS.BackwardsCompatibility.FunctionalTests/DeployerSelector.cs index 5c6f3739a4..18ee47d427 100644 --- a/src/Servers/IIS/test/IIS.BackwardsCompatibility.FunctionalTests/DeployerSelector.cs +++ b/src/Servers/IIS/test/IIS.BackwardsCompatibility.FunctionalTests/DeployerSelector.cs @@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public static class DeployerSelector { public static ServerType ServerType => ServerType.IIS; - public static bool IsBackwardsCompatiblityTest => true; public static bool IsForwardsCompatibilityTest => false; + public static bool HasNewShim => false; + public static bool HasNewHandler => true; } } diff --git a/src/Servers/IIS/test/IIS.ForwardsCompatibility.FunctionalTests/DeployerSelector.cs b/src/Servers/IIS/test/IIS.ForwardsCompatibility.FunctionalTests/DeployerSelector.cs index bd7aabbe0f..2addfc912c 100644 --- a/src/Servers/IIS/test/IIS.ForwardsCompatibility.FunctionalTests/DeployerSelector.cs +++ b/src/Servers/IIS/test/IIS.ForwardsCompatibility.FunctionalTests/DeployerSelector.cs @@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public static class DeployerSelector { public static ServerType ServerType => ServerType.IIS; - public static bool IsBackwardsCompatiblityTest => false; public static bool IsForwardsCompatibilityTest => true; + public static bool HasNewShim => true; + public static bool HasNewHandler => false; } } diff --git a/src/Servers/IIS/test/IIS.FunctionalTests/DeployerSelector.cs b/src/Servers/IIS/test/IIS.FunctionalTests/DeployerSelector.cs index f2e1be321e..1451a0c34c 100644 --- a/src/Servers/IIS/test/IIS.FunctionalTests/DeployerSelector.cs +++ b/src/Servers/IIS/test/IIS.FunctionalTests/DeployerSelector.cs @@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public static class DeployerSelector { public static ServerType ServerType => ServerType.IIS; - public static bool IsBackwardsCompatiblityTest => false; public static bool IsForwardsCompatibilityTest => false; + public static bool HasNewShim => true; + public static bool HasNewHandler => true; } } diff --git a/src/Servers/IIS/test/IISExpress.FunctionalTests/DeployerSelector.cs b/src/Servers/IIS/test/IISExpress.FunctionalTests/DeployerSelector.cs index ba6a1ec6e2..f91b27009f 100644 --- a/src/Servers/IIS/test/IISExpress.FunctionalTests/DeployerSelector.cs +++ b/src/Servers/IIS/test/IISExpress.FunctionalTests/DeployerSelector.cs @@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public static class DeployerSelector { public static ServerType ServerType => ServerType.IISExpress; - public static bool IsBackwardsCompatiblityTest => false; public static bool IsForwardsCompatibilityTest => false; + public static bool HasNewShim => true; + public static bool HasNewHandler => true; } }