diff --git a/test/IISIntegration.IISServerFunctionalTests/AuthenticationTests.cs b/test/IISIntegration.IISServerFunctionalTests/AuthenticationTests.cs index 7cf1e5b60d..5b23d2ec37 100644 --- a/test/IISIntegration.IISServerFunctionalTests/AuthenticationTests.cs +++ b/test/IISIntegration.IISServerFunctionalTests/AuthenticationTests.cs @@ -3,120 +3,62 @@ #if NET461 -using System; -using System.IO; using System.Net; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IIS.FunctionalTests; -using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; namespace IISIntegration.IISServerFunctionalTests { - public class AuthenticationTests : LoggedTest + [Collection(IISTestSiteCollection.Name)] + public class AuthenticationTests { - public AuthenticationTests(ITestOutputHelper output) : base(output) + private readonly IISTestSiteFixture _fixture; + public AuthenticationTests(IISTestSiteFixture fixture) { + _fixture = fixture; } [ConditionalFact] - public Task Authentication_InProcess_IISExpress() + public async Task Authentication_InProcess_IISExpressAsync() { - return Authentication(); - } + var response = await _fixture.Client.GetAsync("/AuthenticationAnonymous"); - private async Task Authentication() - { - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"Authentication_{RuntimeFlavor.CoreClr}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("AuthenticationTest"); + var responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("Anonymous?True", responseText); - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, RuntimeFlavor.CoreClr, architecture) - { - ApplicationBaseUriHint = $"http://localhost:5051", - EnvironmentName = "Authentication", // Will pick the Start class named 'StartupAuthentication', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = "netcoreapp2.0", - ApplicationType = ApplicationType.Portable, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; + response = await _fixture.Client.GetAsync("/AuthenticationRestricted"); + responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString()); + Assert.Contains("Negotiate", response.Headers.WwwAuthenticate.ToString()); - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - var httpClient = deploymentResult.HttpClient; - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); + response = await _fixture.Client.GetAsync("/AuthenticationRestrictedNTLM"); + responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString()); + // Note we can't restrict a challenge to a specific auth type, the native auth modules always add themselves. + Assert.Contains("Negotiate", response.Headers.WwwAuthenticate.ToString()); - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync(string.Empty); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); + response = await _fixture.Client.GetAsync("/AuthenticationForbidden"); + responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal("Hello World", responseText); + var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; + var httpClient = _fixture.DeploymentResult.CreateHttpClient(httpClientHandler); - response = await httpClient.GetAsync("/Anonymous"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal("Anonymous?True", responseText); + response = await httpClient.GetAsync("/AuthenticationAnonymous"); + responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("Anonymous?True", responseText); - response = await httpClient.GetAsync("/Restricted"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); - Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString()); - Assert.Contains("Negotiate", response.Headers.WwwAuthenticate.ToString()); - - response = await httpClient.GetAsync("/RestrictedNTLM"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); - Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString()); - // Note we can't restrict a challenge to a specific auth type, the native auth modules always add themselves. - Assert.Contains("Negotiate", response.Headers.WwwAuthenticate.ToString()); - - response = await httpClient.GetAsync("/Forbidden"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); - - var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; - httpClient = deploymentResult.CreateHttpClient(httpClientHandler); - - response = await httpClient.GetAsync("/Anonymous"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal("Anonymous?True", responseText); - - response = await httpClient.GetAsync("/Restricted"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.NotEmpty(responseText); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } + response = await httpClient.GetAsync("/AuthenticationRestricted"); + responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.NotEmpty(responseText); } } } diff --git a/test/IISIntegration.IISServerFunctionalTests/FeatureCollectionTests.cs b/test/IISIntegration.IISServerFunctionalTests/FeatureCollectionTests.cs index 7b9a3c3a71..fb085cd5f8 100644 --- a/test/IISIntegration.IISServerFunctionalTests/FeatureCollectionTests.cs +++ b/test/IISIntegration.IISServerFunctionalTests/FeatureCollectionTests.cs @@ -1,86 +1,30 @@ // 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.Collections.Generic; -using System.IO; -using System.Text; +using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Server.IIS.FunctionalTests; -using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests { - public class FeatureCollectionTest : LoggedTest + [Collection(IISTestSiteCollection.Name)] + public class FeatureCollectionTest { - public FeatureCollectionTest(ITestOutputHelper output) : base(output) + private readonly IISTestSiteFixture _fixture; + + public FeatureCollectionTest(IISTestSiteFixture fixture) { + _fixture = fixture; } [ConditionalTheory] - [InlineData("SetRequestFeatures")] - [InlineData("SetResponseFeatures")] - [InlineData("SetConnectionFeatures")] - public Task FeatureCollectionTest_SetHttpContextFeatures(string path) + [InlineData("FeatureCollectionSetRequestFeatures")] + [InlineData("FeatureCollectionSetResponseFeatures")] + [InlineData("FeatureCollectionSetConnectionFeatures")] + public async Task FeatureCollectionTest_SetHttpContextFeatures(string path) { - return SetFeatures(RuntimeFlavor.CoreClr, ApplicationType.Portable, path); + Assert.Equal("Success", await _fixture.Client.GetStringAsync(path + "/path" + "?query")); } - - private async Task SetFeatures(RuntimeFlavor runtimeFlavor, ApplicationType applicationType, string path) - { - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"SetFeatures_{runtimeFlavor}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("SetFeaturesTest"); - - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) - { - EnvironmentName = "FeatureCollection", // Will pick the Start class named 'StartupFeatureCollection', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", - ApplicationType = applicationType, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; - - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); - - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync(path + "?query"); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); - - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal("Success", responseText); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } - } - } } diff --git a/test/IISIntegration.IISServerFunctionalTests/HelloWorldTests.cs b/test/IISIntegration.IISServerFunctionalTests/HelloWorldTests.cs index 5682b5aaa9..5416aa0c4f 100644 --- a/test/IISIntegration.IISServerFunctionalTests/HelloWorldTests.cs +++ b/test/IISIntegration.IISServerFunctionalTests/HelloWorldTests.cs @@ -1,87 +1,31 @@ // 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; using System.Threading.Tasks; -using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests { - public class HelloWorldTests : LoggedTest + [Collection(IISTestSiteCollection.Name)] + public class HelloWorldTests { - public HelloWorldTests(ITestOutputHelper output) : base(output) + private readonly IISTestSiteFixture _fixture; + + public HelloWorldTests(IISTestSiteFixture fixture) { + _fixture = fixture; } [ConditionalFact] - public Task HelloWorld_InProcess_IISExpress_CoreClr_X64_Portable() + public async Task HelloWorld_InProcess_IISExpress_CoreClr_X64_Portable() { - return HelloWorld(RuntimeFlavor.CoreClr, ApplicationType.Portable); - } + Assert.Equal("Hello World", await _fixture.Client.GetStringAsync("/HelloWorld")); - private async Task HelloWorld(RuntimeFlavor runtimeFlavor, ApplicationType applicationType) - { - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"HelloWorld_{runtimeFlavor}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("HelloWorldTest"); + Assert.Equal("/Path??", await _fixture.Client.GetStringAsync("/HelloWorld/Path%3F%3F?query")); - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) - { - EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", - ApplicationType = applicationType, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; - - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); - - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync(string.Empty); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); - - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal("Hello World", responseText); - - response = await deploymentResult.HttpClient.GetAsync("/Path%3F%3F?query"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal("/Path??", responseText); - - response = await deploymentResult.HttpClient.GetAsync("/Query%3FPath?query?"); - responseText = await response.Content.ReadAsStringAsync(); - Assert.Equal("?query?", responseText); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } + Assert.Equal("?query", await _fixture.Client.GetStringAsync("/HelloWorld/Query%3F%3F?query")); } } } diff --git a/test/IISIntegration.IISServerFunctionalTests/LargeResponseBodyTests.cs b/test/IISIntegration.IISServerFunctionalTests/LargeResponseBodyTests.cs index 5dda2587b8..999cfd91e4 100644 --- a/test/IISIntegration.IISServerFunctionalTests/LargeResponseBodyTests.cs +++ b/test/IISIntegration.IISServerFunctionalTests/LargeResponseBodyTests.cs @@ -1,141 +1,28 @@ // 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; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests { - public class LargeResponseBodyTests : LoggedTest + [Collection(IISTestSiteCollection.Name)] + public class LargeResponseBodyTests { + private readonly IISTestSiteFixture _fixture; - public LargeResponseBodyTests(ITestOutputHelper output) : base(output) + public LargeResponseBodyTests(IISTestSiteFixture fixture) { + _fixture = fixture; } [ConditionalTheory] - [InlineData(10000)] - [InlineData(100000)] [InlineData(1000000)] [InlineData(10000000)] - public Task LargeResponseBodyTestCheckAllResponseBodyBytesWritten(int query) + public async Task LargeResponseBodyTestCheckAllResponseBodyBytesWritten(int query) { - return LargeResponseBody(RuntimeFlavor.CoreClr, ApplicationType.Portable, query); - } - - private async Task LargeResponseBody(RuntimeFlavor runtimeFlavor, ApplicationType applicationType, int query) - { - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"SetFeatures_{runtimeFlavor}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("SetFeaturesTest"); - - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) - { - EnvironmentName = "LargeResponseBody", // Will pick the Start class named 'StartupLargeResponseBody', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", - ApplicationType = applicationType, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; - - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); - - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync("LargeResponseBody?length=" + query); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); - - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal(new string('a', query), responseText); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } - } - - - [ConditionalFact] - public Task LargeFileResponseBodyInternalCheck() - { - return LargeResponseBodyFromFile(RuntimeFlavor.CoreClr, ApplicationType.Portable); - } - - private async Task LargeResponseBodyFromFile(RuntimeFlavor runtimeFlavor, ApplicationType applicationType) - { - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"SetFeatures_{runtimeFlavor}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("SetFeaturesTest"); - var expected = File.ReadAllText("Http.config"); - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) - { - EnvironmentName = "LargeResponseBody", // Will pick the Start class named 'StartupLargeResponseBody', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? expected : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", - ApplicationType = applicationType, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; - - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); - - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync("LargeResponseBodyFromFile"); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); - - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal(expected, responseText); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } + Assert.Equal(new string('a', query), await _fixture.Client.GetStringAsync($"/LargeResponseBody?length={query}")); } } } diff --git a/test/IISIntegration.IISServerFunctionalTests/ResponseHeaderTests.cs b/test/IISIntegration.IISServerFunctionalTests/ResponseHeaderTests.cs index 4dd70b8b35..6ec2682cd8 100644 --- a/test/IISIntegration.IISServerFunctionalTests/ResponseHeaderTests.cs +++ b/test/IISIntegration.IISServerFunctionalTests/ResponseHeaderTests.cs @@ -1,95 +1,44 @@ // 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.Linq; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Testing; using Microsoft.Net.Http.Headers; using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests { - public class ResponseHeaders : LoggedTest + [Collection(IISTestSiteCollection.Name)] + + public class ResponseHeaders { - public ResponseHeaders(ITestOutputHelper output) : base(output) + private readonly IISTestSiteFixture _fixture; + + public ResponseHeaders(IISTestSiteFixture fixture) { + _fixture = fixture; } [ConditionalFact] - public Task AddResponseHeaders_HeaderValuesAreSetCorrectly() + public async Task AddResponseHeaders_HeaderValuesAreSetCorrectly() { - return RunResponseHeaders(ApplicationType.Portable); - } + var response = await _fixture.Client.GetAsync("ResponseHeaders"); + var responseText = await response.Content.ReadAsStringAsync(); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("Request Complete", responseText); - private async Task RunResponseHeaders(ApplicationType applicationType) - { - var runtimeFlavor = RuntimeFlavor.CoreClr; - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"ResponseHeaders_{runtimeFlavor}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("HelloWorldTest"); + Assert.True(response.Headers.TryGetValues("UnknownHeader", out var headerValues)); + Assert.Equal("test123=foo", headerValues.First()); - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) - { - EnvironmentName = "ResponseHeaders", // Will pick the Start class named 'StartupHelloWorld', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = "netcoreapp2.0", - ApplicationType = applicationType, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; + Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentType, out headerValues)); + Assert.Equal("text/plain", headerValues.First()); - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); - - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync("/ResponseHeaders"); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); - - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal("Request Complete", responseText); - - Assert.True(response.Headers.TryGetValues("UnknownHeader", out var headerValues)); - Assert.Equal("test123=foo", headerValues.First()); - - Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentType, out headerValues)); - Assert.Equal("text/plain", headerValues.First()); - - Assert.True(response.Headers.TryGetValues("MultiHeader", out headerValues)); - Assert.Equal(2, headerValues.Count()); - Assert.Equal("1", headerValues.First()); - Assert.Equal("2", headerValues.Last()); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } + Assert.True(response.Headers.TryGetValues("MultiHeader", out headerValues)); + Assert.Equal(2, headerValues.Count()); + Assert.Equal("1", headerValues.First()); + Assert.Equal("2", headerValues.Last()); } } } diff --git a/test/IISIntegration.IISServerFunctionalTests/ResponseInvalidOrderingTests.cs b/test/IISIntegration.IISServerFunctionalTests/ResponseInvalidOrderingTests.cs index 87fcb51c6f..181220b4ea 100644 --- a/test/IISIntegration.IISServerFunctionalTests/ResponseInvalidOrderingTests.cs +++ b/test/IISIntegration.IISServerFunctionalTests/ResponseInvalidOrderingTests.cs @@ -1,81 +1,28 @@ // 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; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests { - public class ResponseInvalidOrderingTests : LoggedTest + [Collection(IISTestSiteCollection.Name)] + public class ResponseInvalidOrderingTest { - public ResponseInvalidOrderingTests(ITestOutputHelper output) : base(output) + private readonly IISTestSiteFixture _fixture; + + public ResponseInvalidOrderingTest(IISTestSiteFixture fixture) { + _fixture = fixture; } [ConditionalTheory] [InlineData("SetStatusCodeAfterWrite")] [InlineData("SetHeaderAfterWrite")] - public Task ResponseInvalidOrderingTests_ExpectFailure(string path) + public async Task ResponseInvalidOrderingTests_ExpectFailure(string path) { - return SetResponseInvalidOperations(RuntimeFlavor.CoreClr, ApplicationType.Portable, path); - } - - private async Task SetResponseInvalidOperations(RuntimeFlavor runtimeFlavor, ApplicationType applicationType, string path) - { - var serverType = ServerType.IISExpress; - var architecture = RuntimeArchitecture.x64; - var testName = $"SetResponseInvalidOperations_{runtimeFlavor}"; - using (StartLog(out var loggerFactory, testName)) - { - var logger = loggerFactory.CreateLogger("SetFeaturesTest"); - - var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) - { - EnvironmentName = "ResponseInvalidOrdering", // Will pick the Start class named 'StartupInvalidOrdering', - ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, - SiteName = "HttpTestSite", // This is configured in the Http.config - TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", - ApplicationType = applicationType, - Configuration = -#if DEBUG - "Debug" -#else - "Release" -#endif - }; - - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5); - - // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = await RetryHelper.RetryRequest(() => - { - return deploymentResult.HttpClient.GetAsync(path); - }, logger, deploymentResult.HostShutdownToken, retryCount: 30); - - var responseText = await response.Content.ReadAsStringAsync(); - try - { - Assert.Equal($"Started_{path}Threw_Finished", responseText); - } - catch (XunitException) - { - logger.LogWarning(response.ToString()); - logger.LogWarning(responseText); - throw; - } - } - } + Assert.Equal($"Started_{path}Threw_Finished", await _fixture.Client.GetStringAsync("/ResponseInvalidOrdering/" + path)); } } } diff --git a/test/IISIntegration.IISServerFunctionalTests/Utilities/IISTestSiteFixture.cs b/test/IISIntegration.IISServerFunctionalTests/Utilities/IISTestSiteFixture.cs index 498814e4bd..59727bb9fb 100644 --- a/test/IISIntegration.IISServerFunctionalTests/Utilities/IISTestSiteFixture.cs +++ b/test/IISIntegration.IISServerFunctionalTests/Utilities/IISTestSiteFixture.cs @@ -34,15 +34,16 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests }; _deployer = ApplicationDeployerFactory.Create(deploymentParameters, NullLoggerFactory.Instance); - var deploymentResult = _deployer.DeployAsync().Result; - Client = deploymentResult.HttpClient; - BaseUri = deploymentResult.ApplicationBaseUri; - ShutdownToken = deploymentResult.HostShutdownToken; + DeploymentResult = _deployer.DeployAsync().Result; + Client = DeploymentResult.HttpClient; + BaseUri = DeploymentResult.ApplicationBaseUri; + ShutdownToken = DeploymentResult.HostShutdownToken; } public string BaseUri { get; } public HttpClient Client { get; } public CancellationToken ShutdownToken { get; } + public DeploymentResult DeploymentResult { get; } public void Dispose() { diff --git a/test/IISTestSite/Startup.cs b/test/IISTestSite/Startup.cs index d26de2baa0..e1af0a9bf9 100644 --- a/test/IISTestSite/Startup.cs +++ b/test/IISTestSite/Startup.cs @@ -1,9 +1,17 @@ // 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.Net; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.IIS; +using Microsoft.AspNetCore.Server.IISIntegration; +using Microsoft.Extensions.Primitives; +using Xunit; namespace IISTestSite { @@ -12,6 +20,17 @@ namespace IISTestSite public void Configure(IApplicationBuilder app) { app.Map("/ServerVariable", ServerVariable); + app.Map("/AuthenticationAnonymous", AuthenticationAnonymous); + app.Map("/AuthenticationRestricted", AuthenticationRestricted); + app.Map("/AuthenticationForbidden", AuthenticationForbidden); + app.Map("/AuthenticationRestrictedNTLM", AuthenticationRestrictedNTLM); + app.Map("/FeatureCollectionSetRequestFeatures", FeatureCollectionSetRequestFeatures); + app.Map("/FeatureCollectionSetResponseFeatures", FeatureCollectionSetResponseFeatures); + app.Map("/FeatureCollectionSetConnectionFeatures", FeatureCollectionSetConnectionFeatures); + app.Map("/HelloWorld", HelloWorld); + app.Map("/LargeResponseBody", LargeResponseBody); + app.Map("/ResponseHeaders", ResponseHeaders); + app.Map("/ResponseInvalidOrdering", ResponseInvalidOrdering); } private void ServerVariable(IApplicationBuilder app) @@ -22,5 +41,249 @@ namespace IISTestSite await ctx.Response.WriteAsync($"{varName}: {ctx.GetIISServerVariable(varName) ?? "(null)"}"); }); } + + public void AuthenticationAnonymous(IApplicationBuilder app) + { + app.Run(async ctx => + { + await ctx.Response.WriteAsync("Anonymous?" + !ctx.User.Identity.IsAuthenticated); + }); + } + + private void AuthenticationRestricted(IApplicationBuilder app) + { + app.Run(async ctx => + { + if (ctx.User.Identity.IsAuthenticated) + { + await ctx.Response.WriteAsync(ctx.User.Identity.AuthenticationType); + } + else + { + await ctx.ChallengeAsync(IISDefaults.AuthenticationScheme); + } + }); + } + + public void AuthenticationForbidden(IApplicationBuilder app) + { + app.Run(async ctx => + { + await ctx.ForbidAsync(IISDefaults.AuthenticationScheme); + }); + } + + public void AuthenticationRestrictedNTLM(IApplicationBuilder app) + { + app.Run(async ctx => + { + if (string.Equals("NTLM", ctx.User.Identity.AuthenticationType, StringComparison.Ordinal)) + { + await ctx.Response.WriteAsync("NTLM"); + } + else + { + await ctx.ChallengeAsync(IISDefaults.AuthenticationScheme); + } + }); + } + + private void FeatureCollectionSetRequestFeatures(IApplicationBuilder app) + { + app.Run(async context => + { + try + { + Assert.Equal("GET", context.Request.Method); + context.Request.Method = "test"; + Assert.Equal("test", context.Request.Method); + + Assert.Equal("http", context.Request.Scheme); + context.Request.Scheme = "test"; + Assert.Equal("test", context.Request.Scheme); + + Assert.Equal("/FeatureCollectionSetRequestFeatures", context.Request.PathBase); + context.Request.PathBase = "/base"; + Assert.Equal("/base", context.Request.PathBase); + + Assert.Equal("/path", context.Request.Path); + context.Request.Path = "/path"; + Assert.Equal("/path", context.Request.Path); + + Assert.Equal("?query", context.Request.QueryString.Value); + context.Request.QueryString = QueryString.Empty; + Assert.Equal("", context.Request.QueryString.Value); + + Assert.Equal("HTTP/1.1", context.Request.Protocol); + context.Request.Protocol = "HTTP/1.0"; + Assert.Equal("HTTP/1.0", context.Request.Protocol); + + Assert.NotNull(context.Request.Headers); + var headers = new HeaderDictionary(); + context.Features.Get().Headers = headers; + Assert.Same(headers, context.Features.Get().Headers); + + Assert.NotNull(context.Request.Body); + var body = new MemoryStream(); + context.Request.Body = body; + Assert.Same(body, context.Request.Body); + + //Assert.NotNull(context.Features.Get().TraceIdentifier); + //Assert.NotEqual(CancellationToken.None, context.RequestAborted); + //var token = new CancellationTokenSource().Token; + //context.RequestAborted = token; + //Assert.Equal(token, context.RequestAborted); + + await context.Response.WriteAsync("Success"); + return; + } + catch (Exception exception) + { + context.Response.StatusCode = 500; + await context.Response.WriteAsync(exception.ToString()); + } + await context.Response.WriteAsync("_Failure"); + }); + } + + private void FeatureCollectionSetResponseFeatures(IApplicationBuilder app) + { + app.Run(async context => + { + try + { + Assert.Equal(200, context.Response.StatusCode); + context.Response.StatusCode = 404; + Assert.Equal(404, context.Response.StatusCode); + context.Response.StatusCode = 200; + + Assert.Null(context.Features.Get().ReasonPhrase); + context.Features.Get().ReasonPhrase = "Set Response"; + Assert.Equal("Set Response", context.Features.Get().ReasonPhrase); + + Assert.NotNull(context.Response.Headers); + var headers = new HeaderDictionary(); + context.Features.Get().Headers = headers; + Assert.Same(headers, context.Features.Get().Headers); + + var originalBody = context.Response.Body; + Assert.NotNull(originalBody); + var body = new MemoryStream(); + context.Response.Body = body; + Assert.Same(body, context.Response.Body); + context.Response.Body = originalBody; + + await context.Response.WriteAsync("Success"); + return; + } + catch (Exception exception) + { + context.Response.StatusCode = 500; + await context.Response.WriteAsync(exception.ToString()); + } + await context.Response.WriteAsync("_Failure"); + }); + } + + private void FeatureCollectionSetConnectionFeatures(IApplicationBuilder app) + { + app.Run(async context => + { + try + { + Assert.True(IPAddress.IsLoopback(context.Connection.LocalIpAddress)); + context.Connection.LocalIpAddress = IPAddress.IPv6Any; + Assert.Equal(IPAddress.IPv6Any, context.Connection.LocalIpAddress); + + Assert.True(IPAddress.IsLoopback(context.Connection.RemoteIpAddress)); + context.Connection.RemoteIpAddress = IPAddress.IPv6Any; + Assert.Equal(IPAddress.IPv6Any, context.Connection.RemoteIpAddress); + await context.Response.WriteAsync("Success"); + return; + } + catch (Exception exception) + { + context.Response.StatusCode = 500; + await context.Response.WriteAsync(exception.ToString()); + } + await context.Response.WriteAsync("_Failure"); + }); + } + + private void HelloWorld(IApplicationBuilder app) + { + app.Run(async ctx => + { + if (ctx.Request.Path.Value.StartsWith("/Path")) + { + await ctx.Response.WriteAsync(ctx.Request.Path.Value); + return; + } + if (ctx.Request.Path.Value.StartsWith("/Query")) + { + await ctx.Response.WriteAsync(ctx.Request.QueryString.Value); + return; + } + + await ctx.Response.WriteAsync("Hello World"); + }); + } + + private void LargeResponseBody(IApplicationBuilder app) + { + app.Run(async context => + { + if (int.TryParse(context.Request.Query["length"], out var length)) + { + await context.Response.WriteAsync(new string('a', length)); + } + }); + } + + private void ResponseHeaders(IApplicationBuilder app) + { + app.Run(async context => + { + context.Response.Headers["UnknownHeader"] = "test123=foo"; + context.Response.ContentType = "text/plain"; + context.Response.Headers["MultiHeader"] = new StringValues(new string[] { "1", "2" }); + await context.Response.WriteAsync("Request Complete"); + }); + } + + private void ResponseInvalidOrdering(IApplicationBuilder app) + { + app.Run(async context => + { + if (context.Request.Path.Equals("/SetStatusCodeAfterWrite")) + { + await context.Response.WriteAsync("Started_"); + try + { + context.Response.StatusCode = 200; + } + catch (InvalidOperationException) + { + await context.Response.WriteAsync("SetStatusCodeAfterWriteThrew_"); + } + await context.Response.WriteAsync("Finished"); + return; + } + else if (context.Request.Path.Equals("/SetHeaderAfterWrite")) + { + await context.Response.WriteAsync("Started_"); + try + { + context.Response.Headers["This will fail"] = "some value"; + } + catch (InvalidOperationException) + { + await context.Response.WriteAsync("SetHeaderAfterWriteThrew_"); + } + await context.Response.WriteAsync("Finished"); + return; + } + }); + } } } diff --git a/test/IISTestSite/StartupAuthentication.cs b/test/IISTestSite/StartupAuthentication.cs deleted file mode 100644 index 1306332d1f..0000000000 --- a/test/IISTestSite/StartupAuthentication.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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.Security.Principal; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Server.IISIntegration; -using Microsoft.Extensions.Logging; -using Xunit; - -namespace IISTestSite -{ - public class StartupAuthentication - { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - // Simple error page without depending on Diagnostics. - app.Use(async (context, next) => - { - try - { - await next(); - } - catch (Exception ex) - { - if (context.Response.HasStarted) - { - throw; - } - - context.Response.Clear(); - context.Response.StatusCode = 500; - await context.Response.WriteAsync(ex.ToString()); - } - }); - - app.Use((context, next) => - { - if (context.Request.Path.Equals("/Anonymous")) - { - return context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated); - } - - if (context.Request.Path.Equals("/Restricted")) - { - if (context.User.Identity.IsAuthenticated) - { - Assert.IsType(context.User); - return context.Response.WriteAsync(context.User.Identity.AuthenticationType); - } - else - { - return context.ChallengeAsync(IISDefaults.AuthenticationScheme); - } - } - - if (context.Request.Path.Equals("/Forbidden")) - { - return context.ForbidAsync(IISDefaults.AuthenticationScheme); - } - - if (context.Request.Path.Equals("/RestrictedNTLM")) - { - if (string.Equals("NTLM", context.User.Identity.AuthenticationType, StringComparison.Ordinal)) - { - return context.Response.WriteAsync("NTLM"); - } - else - { - return context.ChallengeAsync(IISDefaults.AuthenticationScheme); - } - } - - return context.Response.WriteAsync("Hello World"); - }); - } - } -} diff --git a/test/IISTestSite/StartupFeatureCollection.cs b/test/IISTestSite/StartupFeatureCollection.cs deleted file mode 100644 index b8424a2839..0000000000 --- a/test/IISTestSite/StartupFeatureCollection.cs +++ /dev/null @@ -1,119 +0,0 @@ -// 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.Net; -using System.Threading; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.Extensions.Logging; -using Xunit; - -namespace IISTestSite -{ - public class StartupFeatureCollection - { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.Run(async context => - { - try - { - // Verify setting and getting each feature/ portion of the httpcontext works - if (context.Request.Path.Equals("/SetRequestFeatures")) - { - - Assert.Equal("GET", context.Request.Method); - context.Request.Method = "test"; - Assert.Equal("test", context.Request.Method); - - Assert.Equal("http", context.Request.Scheme); - context.Request.Scheme = "test"; - Assert.Equal("test", context.Request.Scheme); - - Assert.Equal("", context.Request.PathBase); - context.Request.PathBase = "/base"; - Assert.Equal("/base", context.Request.PathBase); - - Assert.Equal("/SetRequestFeatures", context.Request.Path); - context.Request.Path = "/path"; - Assert.Equal("/path", context.Request.Path); - - Assert.Equal("?query", context.Request.QueryString.Value); - context.Request.QueryString = QueryString.Empty; - Assert.Equal("", context.Request.QueryString.Value); - - Assert.Equal("HTTP/1.1", context.Request.Protocol); - context.Request.Protocol = "HTTP/1.0"; - Assert.Equal("HTTP/1.0", context.Request.Protocol); - - Assert.NotNull(context.Request.Headers); - var headers = new HeaderDictionary(); - context.Features.Get().Headers = headers; - Assert.Same(headers, context.Features.Get().Headers); - - Assert.NotNull(context.Request.Body); - var body = new MemoryStream(); - context.Request.Body = body; - Assert.Same(body, context.Request.Body); - - //Assert.NotNull(context.Features.Get().TraceIdentifier); - //Assert.NotEqual(CancellationToken.None, context.RequestAborted); - //var token = new CancellationTokenSource().Token; - //context.RequestAborted = token; - //Assert.Equal(token, context.RequestAborted); - - await context.Response.WriteAsync("Success"); - return; - } - else if (context.Request.Path.Equals("/SetResponseFeatures")) - { - Assert.Equal(200, context.Response.StatusCode); - context.Response.StatusCode = 404; - Assert.Equal(404, context.Response.StatusCode); - - Assert.Null(context.Features.Get().ReasonPhrase); - context.Features.Get().ReasonPhrase = "Set Response"; - Assert.Equal("Set Response", context.Features.Get().ReasonPhrase); - - Assert.NotNull(context.Response.Headers); - var headers = new HeaderDictionary(); - context.Features.Get().Headers = headers; - Assert.Same(headers, context.Features.Get().Headers); - - var originalBody = context.Response.Body; - Assert.NotNull(originalBody); - var body = new MemoryStream(); - context.Response.Body = body; - Assert.Same(body, context.Response.Body); - context.Response.Body = originalBody; - - await context.Response.WriteAsync("Success"); - return; - } - else if (context.Request.Path.Equals("/SetConnectionFeatures")) - { - Assert.True(IPAddress.IsLoopback(context.Connection.LocalIpAddress)); - context.Connection.LocalIpAddress = IPAddress.IPv6Any; - Assert.Equal(IPAddress.IPv6Any, context.Connection.LocalIpAddress); - - Assert.True(IPAddress.IsLoopback(context.Connection.RemoteIpAddress)); - context.Connection.RemoteIpAddress = IPAddress.IPv6Any; - Assert.Equal(IPAddress.IPv6Any, context.Connection.RemoteIpAddress); - await context.Response.WriteAsync("Success"); - return; - } - } - catch (Exception exception) - { - context.Response.StatusCode = 500; - await context.Response.WriteAsync(exception.ToString()); - } - await context.Response.WriteAsync("_Failure"); - }); - } - } -} diff --git a/test/IISTestSite/StartupHelloWorld.cs b/test/IISTestSite/StartupHelloWorld.cs deleted file mode 100644 index 5878b11adf..0000000000 --- a/test/IISTestSite/StartupHelloWorld.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace IISTestSite -{ - public class StartupHelloWorld - { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.Run(async ctx => - { - if (ctx.Request.Path.Value.StartsWith("/Path")) - { - await ctx.Response.WriteAsync(ctx.Request.Path.Value); - return; - } - if (ctx.Request.Path.Value.StartsWith("/Query")) - { - await ctx.Response.WriteAsync(ctx.Request.QueryString.Value); - return; - } - - await ctx.Response.WriteAsync("Hello World"); - }); - } - } -} diff --git a/test/IISTestSite/StartupHttpsHelloWorld.cs b/test/IISTestSite/StartupHttpsHelloWorld.cs deleted file mode 100644 index 60a1c384df..0000000000 --- a/test/IISTestSite/StartupHttpsHelloWorld.cs +++ /dev/null @@ -1,31 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace IISTestSite -{ - public class StartupHttpsHelloWorld - { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.Run(async ctx => - { - if (ctx.Request.Path.Value.StartsWith("/ClientCertificate")) - { - await ctx.Response.WriteAsync($"{ ctx.Request.Scheme }Hello World, Cert: {ctx.Connection.ClientCertificate != null}"); - return; - } - await ctx.Response.WriteAsync(ctx.Request.Scheme + "Hello World"); - }); - } - } -} diff --git a/test/IISTestSite/StartupLargeResponseBody.cs b/test/IISTestSite/StartupLargeResponseBody.cs deleted file mode 100644 index 0d9fc3ac14..0000000000 --- a/test/IISTestSite/StartupLargeResponseBody.cs +++ /dev/null @@ -1,36 +0,0 @@ -// 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.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; - -namespace IISTestSite -{ - public class StartupLargeResponseBody - { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.Run(async context => - { - if (context.Request.Path.Equals("/LargeResponseBody")) - { - if (int.TryParse(context.Request.Query["length"], out var length)) - { - await context.Response.WriteAsync(new string('a', length)); - } - } - else if (context.Request.Path.Equals("/LargeResponseBodyFromFile")) - { - var fileString = File.ReadAllText("Http.config"); - await context.Response.WriteAsync(fileString); - } - }); - } - } -} diff --git a/test/IISTestSite/StartupResponseHeaders.cs b/test/IISTestSite/StartupResponseHeaders.cs deleted file mode 100644 index b6ed1bec4b..0000000000 --- a/test/IISTestSite/StartupResponseHeaders.cs +++ /dev/null @@ -1,33 +0,0 @@ -// 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.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Primitives; -using Microsoft.Net.Http.Headers; - -namespace IISTestSite -{ - public class StartupResponseHeaders - { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.Run(async context => - { - if (context.Request.Path.Equals("/ResponseHeaders")) - { - context.Response.Headers["UnknownHeader"] = "test123=foo"; - context.Response.ContentType = "text/plain"; - context.Response.Headers["MultiHeader"] = new StringValues(new string[] { "1", "2" }); - await context.Response.WriteAsync("Request Complete"); - } - }); - } - } -} diff --git a/test/IISTestSite/StartupResponseInvalidOrdering.cs b/test/IISTestSite/StartupResponseInvalidOrdering.cs deleted file mode 100644 index 0dd2c3ba23..0000000000 --- a/test/IISTestSite/StartupResponseInvalidOrdering.cs +++ /dev/null @@ -1,48 +0,0 @@ -// 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.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; - -namespace IISTestSite -{ - public class StartupResponseInvalidOrdering - { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.Run(async context => - { - if (context.Request.Path.Equals("/SetStatusCodeAfterWrite")) - { - await context.Response.WriteAsync("Started_"); - try - { - context.Response.StatusCode = 200; - } - catch (InvalidOperationException) - { - await context.Response.WriteAsync("SetStatusCodeAfterWriteThrew_"); - } - await context.Response.WriteAsync("Finished"); - return; - } - else if (context.Request.Path.Equals("/SetHeaderAfterWrite")) - { - await context.Response.WriteAsync("Started_"); - try - { - context.Response.Headers["This will fail"] = "some value"; - } - catch (InvalidOperationException) - { - await context.Response.WriteAsync("SetHeaderAfterWriteThrew_"); - } - await context.Response.WriteAsync("Finished"); - return; - } - }); - } - } -}