Move server start failure test in MaxRequestLineSizeTests to KestrelServerTests.
This commit is contained in:
parent
b8f21bee03
commit
fa41588779
|
|
@ -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)
|
private IWebHost BuildWebHost(Action<KestrelServerOptions> options)
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,24 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
Assert.Equal("No recognized listening addresses were configured.", exception.Message);
|
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)
|
private static KestrelServer CreateServer(KestrelServerOptions options)
|
||||||
{
|
{
|
||||||
var lifetime = new LifetimeNotImplemented();
|
var lifetime = new LifetimeNotImplemented();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue