Move server start failure test in MaxRequestLineSizeTests to KestrelServerTests.

This commit is contained in:
Cesar Blum Silveira 2016-08-04 14:07:21 -07:00
parent b8f21bee03
commit fa41588779
2 changed files with 18 additions and 15 deletions

View File

@ -67,21 +67,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
}
}
[Theory]
[InlineData(1, 2)]
[InlineData(int.MaxValue - 1, int.MaxValue)]
public void ServerFailsToStartWhenMaxRequestBufferSizeIsLessThanMaxRequestLineSize(long maxRequestBufferSize, int maxRequestLineSize)
{
using (var host = BuildWebHost(options =>
{
options.Limits.MaxRequestBufferSize = maxRequestBufferSize;
options.Limits.MaxRequestLineSize = maxRequestLineSize;
}))
{
Assert.Throws<InvalidOperationException>(() => host.Start());
}
}
private IWebHost BuildWebHost(Action<KestrelServerOptions> options)
{
var host = new WebHostBuilder()

View File

@ -49,6 +49,24 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
Assert.Equal("No recognized listening addresses were configured.", exception.Message);
}
[Theory]
[InlineData(1, 2)]
[InlineData(int.MaxValue - 1, int.MaxValue)]
public void StartWithMaxRequestBufferSizeLessThanMaxRequestLineSizeThrows(long maxRequestBufferSize, int maxRequestLineSize)
{
var options = new KestrelServerOptions();
options.Limits.MaxRequestBufferSize = maxRequestBufferSize;
options.Limits.MaxRequestLineSize = maxRequestLineSize;
var server = CreateServer(options);
var exception = Assert.Throws<InvalidOperationException>(() => StartDummyApplication(server));
Assert.Equal(
$"Maximum request buffer size ({maxRequestBufferSize}) must be greater than or equal to maximum request line size ({maxRequestLineSize}).",
exception.Message);
}
private static KestrelServer CreateServer(KestrelServerOptions options)
{
var lifetime = new LifetimeNotImplemented();