From df6471f4625f978ef6405da716cdce822f0d5587 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 29 Mar 2018 16:23:17 -0700 Subject: [PATCH] Add startup filter to detect overriden server (#740) --- IISIntegration.sln | 104 +++++++----- build/dependencies.props | 48 +++--- .../Properties => build}/launchSettings.json | 1 + build/testsite.props | 57 ++++--- .../NativeMethods.cs | 2 +- .../Server/IISServerSetupFilter.cs | 8 + .../WebHostBuilderIISExtensions.cs | 55 +++---- .../Properties/launchSettings.json | 27 ---- .../IISIntegration.FunctionalTests.csproj | 4 +- .../Inprocess/StartupTests.cs | 149 +++++++++--------- .../Utilities/Helpers.cs | 28 ++-- test/TestTasks/InjectRequestHandler.cs | 34 ++-- test/TestTasks/TestTasks.csproj | 5 +- .../InProcessWebSite/InProcessWebSite.csproj} | 5 +- .../InProcessWebSite}/Program.cs | 2 +- .../Properties/launchSettings.json | 1 + .../InProcessWebSite}/Startup.cs | 0 .../InProcessWebSite}/web.config | 0 .../OutOfProcessWebSite.csproj} | 4 +- .../OutOfProcessWebSite}/Program.cs | 2 +- .../Properties/launchSettings.json | 37 +++++ .../OutOfProcessWebSite}/StartupHelloWorld.cs | 0 .../StartupHttpsHelloWorld.cs | 0 .../StartupNtlmAuthentication.cs | 0 .../StartupUpgradeFeatureDetection.cs | 0 .../OutOfProcessWebSite}/web.config | 0 .../OverriddenServerWebSite.csproj | 17 ++ .../OverriddenServerWebSite/Program.cs | 48 ++++++ .../Properties/launchSettings.json | 37 +++++ .../OverriddenServerWebSite/web.config | 9 ++ .../StressTestWebSite}/Program.cs | 9 -- .../Properties/launchSettings.json | 37 +++++ .../StressTestWebSite}/Startup.cs | 0 .../StressTestWebSite.csproj} | 7 +- .../WebSockets/Constants.cs | 0 .../WebSockets/HandshakeHelpers.cs | 0 36 files changed, 456 insertions(+), 281 deletions(-) rename {test/TestSites/Properties => build}/launchSettings.json (97%) delete mode 100644 test/ANCMStressTestApp/Properties/launchSettings.json rename test/{IISTestSite/IISTestSite.csproj => WebSites/InProcessWebSite/InProcessWebSite.csproj} (83%) rename test/{IISTestSite => WebSites/InProcessWebSite}/Program.cs (92%) rename test/{IISTestSite => WebSites/InProcessWebSite}/Properties/launchSettings.json (97%) rename test/{IISTestSite => WebSites/InProcessWebSite}/Startup.cs (100%) rename test/{IISTestSite => WebSites/InProcessWebSite}/web.config (100%) rename test/{TestSites/TestSites.csproj => WebSites/OutOfProcessWebSite/OutOfProcessWebSite.csproj} (83%) rename test/{TestSites => WebSites/OutOfProcessWebSite}/Program.cs (92%) create mode 100644 test/WebSites/OutOfProcessWebSite/Properties/launchSettings.json rename test/{TestSites => WebSites/OutOfProcessWebSite}/StartupHelloWorld.cs (100%) rename test/{TestSites => WebSites/OutOfProcessWebSite}/StartupHttpsHelloWorld.cs (100%) rename test/{TestSites => WebSites/OutOfProcessWebSite}/StartupNtlmAuthentication.cs (100%) rename test/{TestSites => WebSites/OutOfProcessWebSite}/StartupUpgradeFeatureDetection.cs (100%) rename test/{TestSites => WebSites/OutOfProcessWebSite}/web.config (100%) create mode 100644 test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj create mode 100644 test/WebSites/OverriddenServerWebSite/Program.cs create mode 100644 test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json create mode 100644 test/WebSites/OverriddenServerWebSite/web.config rename test/{ANCMStressTestApp => WebSites/StressTestWebSite}/Program.cs (69%) create mode 100644 test/WebSites/StressTestWebSite/Properties/launchSettings.json rename test/{ANCMStressTestApp => WebSites/StressTestWebSite}/Startup.cs (100%) rename test/{ANCMStressTestApp/ANCMStressTestApp.csproj => WebSites/StressTestWebSite/StressTestWebSite.csproj} (68%) rename test/{ANCMStressTestApp => WebSites/StressTestWebSite}/WebSockets/Constants.cs (100%) rename test/{ANCMStressTestApp => WebSites/StressTestWebSite}/WebSockets/HandshakeHelpers.cs (100%) diff --git a/IISIntegration.sln b/IISIntegration.sln index 3508392e9d..e14a378b23 100644 --- a/IISIntegration.sln +++ b/IISIntegration.sln @@ -29,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration.Tests", "test\Microsoft.AspNetCore.Server.IISIntegration.Tests\Microsoft.AspNetCore.Server.IISIntegration.Tests.csproj", "{4106DB10-E09F-480E-9CE6-B39235512EE6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestSites", "test\TestSites\TestSites.csproj", "{F54715C3-88D8-49E3-A291-C13570FE81FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OutOfProcessWebSite", "test\WebSites\OutOfProcessWebSite\OutOfProcessWebSite.csproj", "{F54715C3-88D8-49E3-A291-C13570FE81FC}" ProjectSection(ProjectDependencies) = postProject {D57EA297-6DC2-4BC0-8C91-334863327863} = {D57EA297-6DC2-4BC0-8C91-334863327863} {439824F9-1455-4CC4-BD79-B44FA0A16552} = {439824F9-1455-4CC4-BD79-B44FA0A16552} @@ -54,7 +54,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeIISSample", "samples\ {439824F9-1455-4CC4-BD79-B44FA0A16552} = {439824F9-1455-4CC4-BD79-B44FA0A16552} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IISTestSite", "test\IISTestSite\IISTestSite.csproj", "{679FA2A2-898B-4320-884E-C2D294A97CE1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InProcessWebSite", "test\WebSites\InProcessWebSite\InProcessWebSite.csproj", "{679FA2A2-898B-4320-884E-C2D294A97CE1}" ProjectSection(ProjectDependencies) = postProject {D57EA297-6DC2-4BC0-8C91-334863327863} = {D57EA297-6DC2-4BC0-8C91-334863327863} {439824F9-1455-4CC4-BD79-B44FA0A16552} = {439824F9-1455-4CC4-BD79-B44FA0A16552} @@ -72,10 +72,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AspNetCoreModuleTests", "test\AspNetCoreModuleTests\AspNetCoreModuleTests.vcxproj", "{0692D963-DB10-4387-B3EA-460FBB9BD9A3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ANCMStressTestApp", "test\ANCMStressTestApp\ANCMStressTestApp.csproj", "{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StressTestWebSite", "test\WebSites\StressTestWebSite\StressTestWebSite.csproj", "{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestTasks", "test\TestTasks\TestTasks.csproj", "{064D860B-4D7C-4B1D-918F-E020F1B99E2A}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{744ACDC6-F6A0-4FF9-9421-F25C5F2DC520}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OverriddenServerWebSite", "test\WebSites\OverriddenServerWebSite\OverriddenServerWebSite.csproj", "{FC2A97F8-A749-4C04-97D1-97500066A820}" + ProjectSection(ProjectDependencies) = postProject + {D57EA297-6DC2-4BC0-8C91-334863327863} = {D57EA297-6DC2-4BC0-8C91-334863327863} + {439824F9-1455-4CC4-BD79-B44FA0A16552} = {439824F9-1455-4CC4-BD79-B44FA0A16552} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -122,18 +130,18 @@ Global {4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x64.Build.0 = Release|Any CPU {4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x86.ActiveCfg = Release|Any CPU {4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x86.Build.0 = Release|Any CPU - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.ActiveCfg = Debug|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.Build.0 = Debug|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x64.ActiveCfg = Debug|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x64.Build.0 = Debug|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x86.ActiveCfg = Debug|x86 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x86.Build.0 = Debug|x86 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.ActiveCfg = Release|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.Build.0 = Release|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x64.ActiveCfg = Release|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x64.Build.0 = Release|x64 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x86.ActiveCfg = Release|x86 - {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x86.Build.0 = Release|x86 + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x64.ActiveCfg = Debug|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x64.Build.0 = Debug|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x86.ActiveCfg = Debug|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x86.Build.0 = Debug|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.Build.0 = Release|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x64.ActiveCfg = Release|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x64.Build.0 = Release|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x86.ActiveCfg = Release|Any CPU + {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x86.Build.0 = Release|Any CPU {4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -158,18 +166,18 @@ Global {9BC4AFCB-325D-4C81-8228-8CF301CE2F97}.Release|x64.Build.0 = Release|x64 {9BC4AFCB-325D-4C81-8228-8CF301CE2F97}.Release|x86.ActiveCfg = Release|x86 {9BC4AFCB-325D-4C81-8228-8CF301CE2F97}.Release|x86.Build.0 = Release|x86 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|Any CPU.ActiveCfg = Debug|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|Any CPU.Build.0 = Debug|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x64.ActiveCfg = Debug|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x64.Build.0 = Debug|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x86.ActiveCfg = Debug|x86 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x86.Build.0 = Debug|x86 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|Any CPU.ActiveCfg = Release|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|Any CPU.Build.0 = Release|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x64.ActiveCfg = Release|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x64.Build.0 = Release|x64 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x86.ActiveCfg = Release|x86 - {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x86.Build.0 = Release|x86 + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x64.ActiveCfg = Debug|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x64.Build.0 = Debug|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x86.ActiveCfg = Debug|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Debug|x86.Build.0 = Debug|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|Any CPU.Build.0 = Release|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x64.ActiveCfg = Release|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x64.Build.0 = Release|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x86.ActiveCfg = Release|Any CPU + {679FA2A2-898B-4320-884E-C2D294A97CE1}.Release|x86.Build.0 = Release|Any CPU {439824F9-1455-4CC4-BD79-B44FA0A16552}.Debug|Any CPU.ActiveCfg = Debug|x64 {439824F9-1455-4CC4-BD79-B44FA0A16552}.Debug|x64.ActiveCfg = Debug|x64 {439824F9-1455-4CC4-BD79-B44FA0A16552}.Debug|x64.Build.0 = Debug|x64 @@ -232,18 +240,16 @@ Global {0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x64.Build.0 = Release|x64 {0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.ActiveCfg = Release|Win32 {0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.Build.0 = Release|Win32 - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x64.ActiveCfg = Debug|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x64.Build.0 = Debug|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x86.ActiveCfg = Debug|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x86.Build.0 = Debug|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|Any CPU.Build.0 = Release|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.ActiveCfg = Release|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.Build.0 = Release|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.ActiveCfg = Release|Any CPU - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.Build.0 = Release|Any CPU + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|Any CPU.ActiveCfg = Debug|x86 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x64.ActiveCfg = Debug|x64 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x64.Build.0 = Debug|x64 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x86.ActiveCfg = Debug|x86 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Debug|x86.Build.0 = Debug|x86 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|Any CPU.ActiveCfg = Release|x86 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.ActiveCfg = Release|x64 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.Build.0 = Release|x64 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.ActiveCfg = Release|x86 + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.Build.0 = Release|x86 {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -256,6 +262,18 @@ Global {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.Build.0 = Release|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.ActiveCfg = Release|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.Build.0 = Release|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x64.ActiveCfg = Debug|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x64.Build.0 = Debug|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x86.ActiveCfg = Debug|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x86.Build.0 = Debug|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|Any CPU.Build.0 = Release|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x64.ActiveCfg = Release|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x64.Build.0 = Release|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x86.ActiveCfg = Release|Any CPU + {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -264,18 +282,20 @@ Global {E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64} = {C74B8F36-FD2F-45C9-9B8A-00E7CF0126A9} {8B3446E8-E6A8-4591-AA63-A95837C6E97C} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {4106DB10-E09F-480E-9CE6-B39235512EE6} = {EF30B533-D715-421A-92B7-92FEF460AC9C} - {F54715C3-88D8-49E3-A291-C13570FE81FC} = {EF30B533-D715-421A-92B7-92FEF460AC9C} + {F54715C3-88D8-49E3-A291-C13570FE81FC} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {9BC4AFCB-325D-4C81-8228-8CF301CE2F97} = {C74B8F36-FD2F-45C9-9B8A-00E7CF0126A9} - {679FA2A2-898B-4320-884E-C2D294A97CE1} = {EF30B533-D715-421A-92B7-92FEF460AC9C} + {679FA2A2-898B-4320-884E-C2D294A97CE1} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {439824F9-1455-4CC4-BD79-B44FA0A16552} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {4787A64F-9A3E-4867-A55A-70CB4B2B2FFE} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {55494E58-E061-4C4C-A0A8-837008E72F85} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {D57EA297-6DC2-4BC0-8C91-334863327863} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {46A8612B-418B-4D70-B3A7-A21DD0627473} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {0692D963-DB10-4387-B3EA-460FBB9BD9A3} = {EF30B533-D715-421A-92B7-92FEF460AC9C} - {13FD8F12-FFBE-4D01-B4AC-444F2994B04F} = {EF30B533-D715-421A-92B7-92FEF460AC9C} + {13FD8F12-FFBE-4D01-B4AC-444F2994B04F} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {064D860B-4D7C-4B1D-918F-E020F1B99E2A} = {EF30B533-D715-421A-92B7-92FEF460AC9C} + {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} = {EF30B533-D715-421A-92B7-92FEF460AC9C} + {FC2A97F8-A749-4C04-97D1-97500066A820} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DB4F868D-E1AE-4FD7-9333-69FA15B268C5} diff --git a/build/dependencies.props b/build/dependencies.props index e74ce58ccd..0620d71cd5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,35 +4,35 @@ 2.1.0-preview2-15749 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 0.5.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 0.5.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 15.6.82 15.6.82 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 - 2.1.0-preview2-30478 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 + 2.1.0-preview2-30500 1.1.0 - 2.1.0-preview2-30478 + 2.1.0-preview2-30500 2.0.0 2.1.0-preview2-26326-03 - 2.1.0-preview2-30478 + 2.1.0-preview2-30500 15.6.1 7.0.0 4.5.0-preview2-26326-04 diff --git a/test/TestSites/Properties/launchSettings.json b/build/launchSettings.json similarity index 97% rename from test/TestSites/Properties/launchSettings.json rename to build/launchSettings.json index 7d09a120ab..6d5ce43f73 100644 --- a/test/TestSites/Properties/launchSettings.json +++ b/build/launchSettings.json @@ -12,6 +12,7 @@ "commandName": "Executable", "executablePath": "$(IISExpressPath)", "commandLineArgs": "$(IISExpressArguments)", + "nativeDebugging": true, "environmentVariables": { "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "ANCM_PATH": "$(TargetDir)$(AncmPath)", diff --git a/build/testsite.props b/build/testsite.props index f706a70a44..0a3f00ac79 100644 --- a/build/testsite.props +++ b/build/testsite.props @@ -8,15 +8,7 @@ x64 $(Platform) - - - - - - - - - + $(MSBuildProgramFiles32)\IIS Express\iisexpress.exe $(SystemRoot)\SysWOW64\inetsrv\w3wp.exe @@ -29,6 +21,13 @@ x64 + + + + + + + /config:"$(IISExpressAppHostConfig)" -h "$(IISAppHostConfig)" @@ -38,25 +37,45 @@ $(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe - - $(MSBuildThisFileDirectory)..\test\TestTasks\bin\$(Configuration)\netstandard2.0\TestTasks.dll - + + + + + - false - False + False - + + + + $(MSBuildThisFileDirectory)..\test\TestTasks\bin\$(Configuration)\$(TargetFramework)\TestTasks - - + $(InjectDepsAssembly) + "win7-$(NativePlatform)" "$(AncmRHPath)" + + + + $(InjectDepsAssembly).exe + $(InjectDepsAssembly) + + + + $(InjectDepsAssembly).dll + dotnet + $(InjectDepsAssembly) $(InjectDepsArguments) + - - + + + + + + diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs index 00c9d5beb1..a43938b61c 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration [DllImport("kernel32.dll")] public static extern IntPtr GetModuleHandle(string lpModuleName); - public static bool is_ancm_loaded() + public static bool IsAspNetCoreModuleLoaded() { return GetModuleHandle(AspNetCoreModuleDll) != IntPtr.Zero; } diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs index 94fa2ac136..787c979c96 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs @@ -4,6 +4,8 @@ using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Server.IISIntegration { @@ -20,6 +22,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration { return app => { + var server = app.ApplicationServices.GetService(); + if (server?.GetType() != typeof(IISHttpServer)) + { + throw new InvalidOperationException("Application is running inside IIS process but is not configured to use IIS server."); + } + app.UsePathBase(_virtualPath); next(app); }; diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs index a96305d4d8..fbf081f725 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs @@ -41,34 +41,9 @@ namespace Microsoft.AspNetCore.Hosting } // Check if in process - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && NativeMethods.is_ancm_loaded()) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && NativeMethods.IsAspNetCoreModuleLoaded()) { - hostBuilder.UseSetting(nameof(UseIISIntegration), "true"); - hostBuilder.CaptureStartupErrors(true); - - // TODO consider adding a configuration load where all variables needed are loaded from ANCM in one call. - var iisConfigData = new IISConfigurationData(); - var hResult = NativeMethods.http_get_application_properties(ref iisConfigData); - - var exception = Marshal.GetExceptionForHR(hResult); - if (exception != null) - { - throw exception; - } - - hostBuilder.UseContentRoot(iisConfigData.pwzFullApplicationPath); - return hostBuilder.ConfigureServices(services => - { - services.AddSingleton(); - services.AddSingleton(new IISServerSetupFilter(iisConfigData.pwzVirtualApplicationPath)); - services.AddAuthenticationCore(); - services.Configure( - options => - { - options.ForwardWindowsAuthentication = iisConfigData.fWindowsAuthEnabled || iisConfigData.fBasicAuthEnabled; - } - ); - }); + return SetupInProcessServer(hostBuilder); } var port = hostBuilder.GetSetting(ServerPort) ?? Environment.GetEnvironmentVariable($"ASPNETCORE_{ServerPort}"); @@ -131,5 +106,31 @@ namespace Microsoft.AspNetCore.Hosting return hostBuilder; } + + private static IWebHostBuilder SetupInProcessServer(IWebHostBuilder hostBuilder) + { + hostBuilder.UseSetting(nameof(UseIISIntegration), "true"); + hostBuilder.CaptureStartupErrors(true); + + var iisConfigData = new IISConfigurationData(); + var hResult = NativeMethods.http_get_application_properties(ref iisConfigData); + + var exception = Marshal.GetExceptionForHR(hResult); + if (exception != null) + { + throw exception; + } + + hostBuilder.UseContentRoot(iisConfigData.pwzFullApplicationPath); + return hostBuilder.ConfigureServices( + services => { + services.AddSingleton(); + services.AddSingleton(new IISServerSetupFilter(iisConfigData.pwzVirtualApplicationPath)); + services.AddAuthenticationCore(); + services.Configure( + options => { options.ForwardWindowsAuthentication = iisConfigData.fWindowsAuthEnabled || iisConfigData.fBasicAuthEnabled; } + ); + }); + } } } diff --git a/test/ANCMStressTestApp/Properties/launchSettings.json b/test/ANCMStressTestApp/Properties/launchSettings.json deleted file mode 100644 index 8e9b6cfcf7..0000000000 --- a/test/ANCMStressTestApp/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:16606/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "ANCMStressTestSample": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:16607/" - } - } -} \ No newline at end of file diff --git a/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj b/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj index c09eeee095..d79a5ec5d9 100644 --- a/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj +++ b/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj @@ -10,7 +10,9 @@ - + + False + diff --git a/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs b/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs index ac58c894e5..e351649d86 100644 --- a/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs +++ b/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs @@ -26,28 +26,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [Fact] public async Task ExpandEnvironmentVariableInWebConfig() { - var runtimeFlavor = RuntimeFlavor.CoreClr; - var serverType = ServerType.IISExpress; - var testName = $"HelloWorld_{runtimeFlavor}"; var architecture = RuntimeArchitecture.x64; var dotnetLocation = $"%USERPROFILE%\\.dotnet\\{architecture.ToString()}\\dotnet.exe"; - using (StartLog(out var loggerFactory, testName)) + using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger("HelloWorldTest"); - var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(), serverType, runtimeFlavor, architecture) - { - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("AppHostConfig/Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = "netcoreapp2.1", - ApplicationType = ApplicationType.Portable, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; + var deploymentParameters = GetBaseDeploymentParameters(); // Point to dotnet installed in user profile. deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet. @@ -82,29 +67,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [Fact] public async Task InvalidProcessPath_ExpectServerError() { - var architecture = RuntimeArchitecture.x64; - var runtimeFlavor = RuntimeFlavor.CoreClr; - var serverType = ServerType.IISExpress; - var testName = $"HelloWorld_{runtimeFlavor}"; var dotnetLocation = "bogus"; - using (StartLog(out var loggerFactory, testName)) + using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger("HelloWorldTest"); - - var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(), serverType, runtimeFlavor, architecture) - { - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("AppHostConfig/Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = "netcoreapp2.1", - ApplicationType = ApplicationType.Portable, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; - + var deploymentParameters = GetBaseDeploymentParameters(); + // Point to dotnet installed in user profile. deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet. @@ -128,30 +96,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests #if NETCOREAPP2_0 || NETCOREAPP2_1 [Fact] // Consistently fails on CI for net461 - public async Task StandaloneApplication_ExpectCorrectPublish() + public async Task StandaloneApplication_ExpectCorrectPublish() { - var architecture = RuntimeArchitecture.x64; - var runtimeFlavor = RuntimeFlavor.CoreClr; - var serverType = ServerType.IISExpress; - var testName = $"HelloWorld_{runtimeFlavor}"; - - using (StartLog(out var loggerFactory, testName)) + using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger("HelloWorldTest"); - - var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(), serverType, runtimeFlavor, architecture) - { - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("AppHostConfig/Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = "netcoreapp2.1", - ApplicationType = ApplicationType.Standalone, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; + + var deploymentParameters = GetBaseDeploymentParameters(); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { @@ -181,34 +132,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [Fact] // Consistently fails on CI for net461 public async Task StandaloneApplication_AbsolutePathToExe_ExpectCorrectPublish() { - var architecture = RuntimeArchitecture.x64; - var runtimeFlavor = RuntimeFlavor.CoreClr; - var serverType = ServerType.IISExpress; - var testName = $"HelloWorld_{runtimeFlavor}"; - - using (StartLog(out var loggerFactory, testName)) + using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger("HelloWorldTest"); - var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(), serverType, runtimeFlavor, architecture) - { - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("AppHostConfig/Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = "netcoreapp2.1", - ApplicationType = ApplicationType.Standalone, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; + var deploymentParameters = GetBaseDeploymentParameters(); + deploymentParameters.ApplicationType = ApplicationType.Standalone; using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { var deploymentResult = await deployer.DeployAsync(); - Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", $"{deploymentResult.ContentRoot}\\IISTestSite.exe"); + Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", $"{deploymentResult.ContentRoot}\\InProcessWebSite.exe"); // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(() => @@ -235,6 +170,64 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests #else #error Target frameworks need to be updated #endif + + [Fact] + public async Task DetectsOveriddenServer() + { + var testSink = new TestSink(); + using (StartLog(out var loggerFactory)) + { + var testLoggerFactory = new TestLoggerFactory(testSink, true); + loggerFactory.AddProvider(new TestLoggerProvider(testLoggerFactory)); + using (var deployer = ApplicationDeployerFactory.Create(GetBaseDeploymentParameters("OverriddenServerWebSite"), loggerFactory)) + { + var deploymentResult = await deployer.DeployAsync(); + var response = await deploymentResult.HttpClient.GetAsync("/"); + Assert.False(response.IsSuccessStatusCode); + } + } + Assert.Contains(testSink.Writes, context => context.State.ToString().Contains("Application is running inside IIS process but is not configured to use IIS server")); + } + + private DeploymentParameters GetBaseDeploymentParameters(string site = null) + { + return new DeploymentParameters(Helpers.GetTestWebSitePath(site ?? "InProcessWebSite"), ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) + { + ServerConfigTemplateContent = File.ReadAllText("AppHostConfig/Http.config"), + SiteName = "HttpTestSite", // This is configured in the Http.config + TargetFramework = "netcoreapp2.1", + ApplicationType = ApplicationType.Portable, + Configuration = GetCurrentConfiguration() + }; + } + + private static string GetCurrentConfiguration() + { +#if DEBUG + return "Debug"; +#else + return "Release"; +#endif + } + + private class TestLoggerProvider : ILoggerProvider + { + private readonly TestLoggerFactory _loggerFactory; + + public TestLoggerProvider(TestLoggerFactory loggerFactory) + { + _loggerFactory = loggerFactory; + } + + public void Dispose() + { + } + + public ILogger CreateLogger(string categoryName) + { + return _loggerFactory.CreateLogger(categoryName); + } + } } } diff --git a/test/IISIntegration.FunctionalTests/Utilities/Helpers.cs b/test/IISIntegration.FunctionalTests/Utilities/Helpers.cs index def988473f..5cda360005 100644 --- a/test/IISIntegration.FunctionalTests/Utilities/Helpers.cs +++ b/test/IISIntegration.FunctionalTests/Utilities/Helpers.cs @@ -11,27 +11,21 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { public class Helpers { - public static string GetInProcessTestSitesPath() - { + public static string GetTestWebSitePath(string name) + { return Path.GetFullPath( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, - "..", // tfm - "..", // debug - "..", // obj - "..", // projectfolder - "IISTestSite")); + "..", // tfm + "..", // debug + "..", // obj + "..", // projectfolder + "WebSites", + name)); } - public static string GetOutOfProcessTestSitesPath() - { - return Path.GetFullPath( - Path.Combine(AppDomain.CurrentDomain.BaseDirectory, - "..", // tfm - "..", // debug - "..", // obj - "..", // projectfolder - "TestSites")); - } + public static string GetInProcessTestSitesPath() => GetTestWebSitePath("InProcessWebSite"); + + public static string GetOutOfProcessTestSitesPath() => GetTestWebSitePath("OutOfProcessWebSite"); public static void ModifyAspNetCoreSectionInWebConfig(DeploymentResult deploymentResult, string key, string value) { diff --git a/test/TestTasks/InjectRequestHandler.cs b/test/TestTasks/InjectRequestHandler.cs index a97d5718a4..639428ebd1 100644 --- a/test/TestTasks/InjectRequestHandler.cs +++ b/test/TestTasks/InjectRequestHandler.cs @@ -1,36 +1,23 @@ // 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.Diagnostics; using System.IO; using System.Linq; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace TestTasks { - public class InjectRequestHandler : Task + public class InjectRequestHandler { - [Required] - public string DepsFile { get; set; } - - [Required] - public string Rid { get; set; } - - [Required] - public string LibraryLocation { get; set; } - - public override bool Execute() + private static void Main(string[] args) { - InjectNativeLibrary(DepsFile); + var depsFile = args[2]; + var rid = args[0]; + var libraryLocation = args[1]; - // Parse input - return true; - } - - private void InjectNativeLibrary(string depsFile) - { JToken deps; using (var file = File.OpenText(depsFile)) using (JsonTextReader reader = new JsonTextReader(file)) @@ -40,15 +27,16 @@ namespace TestTasks var libraryName = "ANCMRH/1.0"; var libraries = (JObject)deps["libraries"]; + var targetName = (JValue)deps["runtimeTarget"]["name"]; - var target = (JObject)((JObject)deps["targets"]).Properties().First().Value; + var target = (JObject)deps["targets"][targetName.Value]; var targetLibrary = target.Properties().FirstOrDefault(p => p.Name == libraryName); targetLibrary?.Remove(); targetLibrary = new JProperty(libraryName, new JObject( new JProperty("runtimeTargets", new JObject( - new JProperty(LibraryLocation.Replace('\\', '/'), new JObject( - new JProperty("rid", Rid), + new JProperty(libraryLocation.Replace('\\', '/'), new JObject( + new JProperty("rid", rid), new JProperty("assetType", "native") )))))); target.AddFirst(targetLibrary); diff --git a/test/TestTasks/TestTasks.csproj b/test/TestTasks/TestTasks.csproj index 24a26e6253..aa4c144936 100644 --- a/test/TestTasks/TestTasks.csproj +++ b/test/TestTasks/TestTasks.csproj @@ -1,13 +1,12 @@ - netstandard2.0 + Exe + $(StandardTestTfms) - - diff --git a/test/IISTestSite/IISTestSite.csproj b/test/WebSites/InProcessWebSite/InProcessWebSite.csproj similarity index 83% rename from test/IISTestSite/IISTestSite.csproj rename to test/WebSites/InProcessWebSite/InProcessWebSite.csproj index f628ba9cf9..c615d460ee 100644 --- a/test/IISTestSite/IISTestSite.csproj +++ b/test/WebSites/InProcessWebSite/InProcessWebSite.csproj @@ -1,13 +1,12 @@  - - + $(StandardTestTfms) - + diff --git a/test/IISTestSite/Program.cs b/test/WebSites/InProcessWebSite/Program.cs similarity index 92% rename from test/IISTestSite/Program.cs rename to test/WebSites/InProcessWebSite/Program.cs index 5e22d2f2c6..0550f0f1fd 100644 --- a/test/IISTestSite/Program.cs +++ b/test/WebSites/InProcessWebSite/Program.cs @@ -17,7 +17,7 @@ namespace IISTestSite factory.AddFilter("Console", level => level >= LogLevel.Information); }) .UseIISIntegration() - .UseStartup("IISTestSite") + .UseStartup(typeof(Program).Assembly.FullName) .Build(); host.Run(); diff --git a/test/IISTestSite/Properties/launchSettings.json b/test/WebSites/InProcessWebSite/Properties/launchSettings.json similarity index 97% rename from test/IISTestSite/Properties/launchSettings.json rename to test/WebSites/InProcessWebSite/Properties/launchSettings.json index 7d09a120ab..6d5ce43f73 100644 --- a/test/IISTestSite/Properties/launchSettings.json +++ b/test/WebSites/InProcessWebSite/Properties/launchSettings.json @@ -12,6 +12,7 @@ "commandName": "Executable", "executablePath": "$(IISExpressPath)", "commandLineArgs": "$(IISExpressArguments)", + "nativeDebugging": true, "environmentVariables": { "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "ANCM_PATH": "$(TargetDir)$(AncmPath)", diff --git a/test/IISTestSite/Startup.cs b/test/WebSites/InProcessWebSite/Startup.cs similarity index 100% rename from test/IISTestSite/Startup.cs rename to test/WebSites/InProcessWebSite/Startup.cs diff --git a/test/IISTestSite/web.config b/test/WebSites/InProcessWebSite/web.config similarity index 100% rename from test/IISTestSite/web.config rename to test/WebSites/InProcessWebSite/web.config diff --git a/test/TestSites/TestSites.csproj b/test/WebSites/OutOfProcessWebSite/OutOfProcessWebSite.csproj similarity index 83% rename from test/TestSites/TestSites.csproj rename to test/WebSites/OutOfProcessWebSite/OutOfProcessWebSite.csproj index 19ed3dc502..0b96c98c36 100644 --- a/test/TestSites/TestSites.csproj +++ b/test/WebSites/OutOfProcessWebSite/OutOfProcessWebSite.csproj @@ -1,13 +1,13 @@  - + $(StandardTestTfms) - + diff --git a/test/TestSites/Program.cs b/test/WebSites/OutOfProcessWebSite/Program.cs similarity index 92% rename from test/TestSites/Program.cs rename to test/WebSites/OutOfProcessWebSite/Program.cs index af6e90bd15..18104fa30a 100644 --- a/test/TestSites/Program.cs +++ b/test/WebSites/OutOfProcessWebSite/Program.cs @@ -17,7 +17,7 @@ namespace TestSites factory.AddFilter("Console", level => level >= LogLevel.Information); }) .UseIISIntegration() - .UseStartup("TestSites") + .UseStartup(typeof(Program).Assembly.FullName) .UseKestrel() .Build(); diff --git a/test/WebSites/OutOfProcessWebSite/Properties/launchSettings.json b/test/WebSites/OutOfProcessWebSite/Properties/launchSettings.json new file mode 100644 index 0000000000..6d5ce43f73 --- /dev/null +++ b/test/WebSites/OutOfProcessWebSite/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": true, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5762/", + "sslPort": 0 + } + }, + "profiles": { + "ANCM IIS Express": { + "commandName": "Executable", + "executablePath": "$(IISExpressPath)", + "commandLineArgs": "$(IISExpressArguments)", + "nativeDebugging": true, + "environmentVariables": { + "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", + "ANCM_PATH": "$(TargetDir)$(AncmPath)", + "LAUNCHER_ARGS": "$(TargetPath)", + "ASPNETCORE_ENVIRONMENT": "Development", + "LAUNCHER_PATH": "$(DotNetPath)" + } + }, + "ANCM IIS": { + "commandName": "Executable", + "executablePath": "$(IISPath)", + "commandLineArgs": "$(IISArguments)", + "environmentVariables": { + "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", + "ANCM_PATH": "$(TargetDir)$(AncmPath)", + "LAUNCHER_ARGS": "$(TargetPath)", + "ASPNETCORE_ENVIRONMENT": "Development", + "LAUNCHER_PATH": "$(DotNetPath)" + } + } + } +} diff --git a/test/TestSites/StartupHelloWorld.cs b/test/WebSites/OutOfProcessWebSite/StartupHelloWorld.cs similarity index 100% rename from test/TestSites/StartupHelloWorld.cs rename to test/WebSites/OutOfProcessWebSite/StartupHelloWorld.cs diff --git a/test/TestSites/StartupHttpsHelloWorld.cs b/test/WebSites/OutOfProcessWebSite/StartupHttpsHelloWorld.cs similarity index 100% rename from test/TestSites/StartupHttpsHelloWorld.cs rename to test/WebSites/OutOfProcessWebSite/StartupHttpsHelloWorld.cs diff --git a/test/TestSites/StartupNtlmAuthentication.cs b/test/WebSites/OutOfProcessWebSite/StartupNtlmAuthentication.cs similarity index 100% rename from test/TestSites/StartupNtlmAuthentication.cs rename to test/WebSites/OutOfProcessWebSite/StartupNtlmAuthentication.cs diff --git a/test/TestSites/StartupUpgradeFeatureDetection.cs b/test/WebSites/OutOfProcessWebSite/StartupUpgradeFeatureDetection.cs similarity index 100% rename from test/TestSites/StartupUpgradeFeatureDetection.cs rename to test/WebSites/OutOfProcessWebSite/StartupUpgradeFeatureDetection.cs diff --git a/test/TestSites/web.config b/test/WebSites/OutOfProcessWebSite/web.config similarity index 100% rename from test/TestSites/web.config rename to test/WebSites/OutOfProcessWebSite/web.config diff --git a/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj b/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj new file mode 100644 index 0000000000..4332ea3fd1 --- /dev/null +++ b/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj @@ -0,0 +1,17 @@ + + + + + + $(StandardTestTfms) + + + + + + + + + + + diff --git a/test/WebSites/OverriddenServerWebSite/Program.cs b/test/WebSites/OverriddenServerWebSite/Program.cs new file mode 100644 index 0000000000..bb65e03004 --- /dev/null +++ b/test/WebSites/OverriddenServerWebSite/Program.cs @@ -0,0 +1,48 @@ +// 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.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; + +namespace IISTestSite +{ + public static class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseIISIntegration() + .ConfigureServices(services => services.AddSingleton()) + .Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); })) + .Build(); + + host.Run(); + } + } + + public class DummyServer: IServer + { + public void Dispose() + { + } + + public Task StartAsync(IHttpApplication application, CancellationToken cancellationToken) + { + return Task.Delay(TimeSpan.MaxValue); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.Delay(TimeSpan.MaxValue); + } + + public IFeatureCollection Features { get; } + } +} diff --git a/test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json b/test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json new file mode 100644 index 0000000000..6d5ce43f73 --- /dev/null +++ b/test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": true, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5762/", + "sslPort": 0 + } + }, + "profiles": { + "ANCM IIS Express": { + "commandName": "Executable", + "executablePath": "$(IISExpressPath)", + "commandLineArgs": "$(IISExpressArguments)", + "nativeDebugging": true, + "environmentVariables": { + "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", + "ANCM_PATH": "$(TargetDir)$(AncmPath)", + "LAUNCHER_ARGS": "$(TargetPath)", + "ASPNETCORE_ENVIRONMENT": "Development", + "LAUNCHER_PATH": "$(DotNetPath)" + } + }, + "ANCM IIS": { + "commandName": "Executable", + "executablePath": "$(IISPath)", + "commandLineArgs": "$(IISArguments)", + "environmentVariables": { + "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", + "ANCM_PATH": "$(TargetDir)$(AncmPath)", + "LAUNCHER_ARGS": "$(TargetPath)", + "ASPNETCORE_ENVIRONMENT": "Development", + "LAUNCHER_PATH": "$(DotNetPath)" + } + } + } +} diff --git a/test/WebSites/OverriddenServerWebSite/web.config b/test/WebSites/OverriddenServerWebSite/web.config new file mode 100644 index 0000000000..f125d57107 --- /dev/null +++ b/test/WebSites/OverriddenServerWebSite/web.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/test/ANCMStressTestApp/Program.cs b/test/WebSites/StressTestWebSite/Program.cs similarity index 69% rename from test/ANCMStressTestApp/Program.cs rename to test/WebSites/StressTestWebSite/Program.cs index b0edb5b7f2..e8e5392c2c 100644 --- a/test/ANCMStressTestApp/Program.cs +++ b/test/WebSites/StressTestWebSite/Program.cs @@ -1,16 +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.Linq; -using System.Threading; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Server.IISIntegration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace ANCMStressTestApp diff --git a/test/WebSites/StressTestWebSite/Properties/launchSettings.json b/test/WebSites/StressTestWebSite/Properties/launchSettings.json new file mode 100644 index 0000000000..6d5ce43f73 --- /dev/null +++ b/test/WebSites/StressTestWebSite/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": true, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5762/", + "sslPort": 0 + } + }, + "profiles": { + "ANCM IIS Express": { + "commandName": "Executable", + "executablePath": "$(IISExpressPath)", + "commandLineArgs": "$(IISExpressArguments)", + "nativeDebugging": true, + "environmentVariables": { + "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", + "ANCM_PATH": "$(TargetDir)$(AncmPath)", + "LAUNCHER_ARGS": "$(TargetPath)", + "ASPNETCORE_ENVIRONMENT": "Development", + "LAUNCHER_PATH": "$(DotNetPath)" + } + }, + "ANCM IIS": { + "commandName": "Executable", + "executablePath": "$(IISPath)", + "commandLineArgs": "$(IISArguments)", + "environmentVariables": { + "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", + "ANCM_PATH": "$(TargetDir)$(AncmPath)", + "LAUNCHER_ARGS": "$(TargetPath)", + "ASPNETCORE_ENVIRONMENT": "Development", + "LAUNCHER_PATH": "$(DotNetPath)" + } + } + } +} diff --git a/test/ANCMStressTestApp/Startup.cs b/test/WebSites/StressTestWebSite/Startup.cs similarity index 100% rename from test/ANCMStressTestApp/Startup.cs rename to test/WebSites/StressTestWebSite/Startup.cs diff --git a/test/ANCMStressTestApp/ANCMStressTestApp.csproj b/test/WebSites/StressTestWebSite/StressTestWebSite.csproj similarity index 68% rename from test/ANCMStressTestApp/ANCMStressTestApp.csproj rename to test/WebSites/StressTestWebSite/StressTestWebSite.csproj index 54755b4824..3566143fcd 100644 --- a/test/ANCMStressTestApp/ANCMStressTestApp.csproj +++ b/test/WebSites/StressTestWebSite/StressTestWebSite.csproj @@ -1,12 +1,13 @@ + + - netcoreapp2.1 - win-x86;win-x64 + $(StandardTestTfms) - + diff --git a/test/ANCMStressTestApp/WebSockets/Constants.cs b/test/WebSites/StressTestWebSite/WebSockets/Constants.cs similarity index 100% rename from test/ANCMStressTestApp/WebSockets/Constants.cs rename to test/WebSites/StressTestWebSite/WebSockets/Constants.cs diff --git a/test/ANCMStressTestApp/WebSockets/HandshakeHelpers.cs b/test/WebSites/StressTestWebSite/WebSockets/HandshakeHelpers.cs similarity index 100% rename from test/ANCMStressTestApp/WebSockets/HandshakeHelpers.cs rename to test/WebSites/StressTestWebSite/WebSockets/HandshakeHelpers.cs