React to hosting
This commit is contained in:
parent
e8d3fbf7bc
commit
e7b0a76db9
|
|
@ -18,8 +18,6 @@ namespace StaticFilesSample
|
|||
// Displays all log levels
|
||||
factory.AddConsole(LogLevel.Verbose);
|
||||
|
||||
app.UseRequestServices();
|
||||
|
||||
app.UseFileServer(new FileServerOptions()
|
||||
{
|
||||
EnableDirectoryBrowsing = true,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.RequestContainer": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
|
|
|
|||
|
|
@ -19,28 +19,19 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[Fact]
|
||||
public async Task NullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions() { Formatter = null });
|
||||
}));
|
||||
Assert.Throws<ArgumentException>(() => TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions() { Formatter = null }),
|
||||
services => services.AddDirectoryBrowser()));
|
||||
|
||||
// No exception, default provided
|
||||
TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileProvider = null });
|
||||
});
|
||||
TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileProvider = null }),
|
||||
services => services.AddDirectoryBrowser());
|
||||
|
||||
// PathString(null) is OK.
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser((string)null);
|
||||
});
|
||||
TestServer server = TestServer.Create(
|
||||
app => app.UseDirectoryBrowser((string)null),
|
||||
services => services.AddDirectoryBrowser());
|
||||
|
||||
var response = await server.CreateClient().GetAsync("/");
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
|
|
@ -54,16 +45,13 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("", @".\", "/missing.dir")]
|
||||
public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
TestServer server = TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
{
|
||||
RequestPath = new PathString(baseUrl),
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(Environment.CurrentDirectory, baseDir))
|
||||
});
|
||||
});
|
||||
}),
|
||||
services => services.AddDirectoryBrowser());
|
||||
HttpResponseMessage response = await server.CreateRequest(requestUrl).GetAsync();
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
|
|
@ -76,16 +64,13 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("/somedir", @".", "/somedir/subfolder/")]
|
||||
public async Task FoundDirectory_Served(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
TestServer server = TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
{
|
||||
RequestPath = new PathString(baseUrl),
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(Environment.CurrentDirectory, baseDir))
|
||||
});
|
||||
});
|
||||
}),
|
||||
services => services.AddDirectoryBrowser());
|
||||
HttpResponseMessage response = await server.CreateRequest(requestUrl).GetAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
|
|
@ -103,16 +88,13 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("/somedir", @".", "/somedir/subfolder", "?a=b")]
|
||||
public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
TestServer server = TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
{
|
||||
RequestPath = new PathString(baseUrl),
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(Environment.CurrentDirectory, baseDir))
|
||||
});
|
||||
});
|
||||
}),
|
||||
services => services.AddDirectoryBrowser());
|
||||
|
||||
HttpResponseMessage response = await server.CreateRequest(requestUrl + queryString).GetAsync();
|
||||
|
||||
|
|
@ -128,16 +110,13 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("/somedir", @".", "/somedir/subfolder/")]
|
||||
public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
TestServer server = TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
{
|
||||
RequestPath = new PathString(baseUrl),
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(Environment.CurrentDirectory, baseDir))
|
||||
});
|
||||
});
|
||||
}),
|
||||
services => services.AddDirectoryBrowser());
|
||||
|
||||
HttpResponseMessage response = await server.CreateRequest(requestUrl).PostAsync();
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
|
|
@ -150,16 +129,13 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("/somedir", @".", "/somedir/subfolder/")]
|
||||
public async Task HeadDirectory_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseServices(services => services.AddDirectoryBrowser());
|
||||
|
||||
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
TestServer server = TestServer.Create(
|
||||
app => app.UseDirectoryBrowser(new DirectoryBrowserOptions()
|
||||
{
|
||||
RequestPath = new PathString(baseUrl),
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(Environment.CurrentDirectory, baseDir))
|
||||
});
|
||||
});
|
||||
}),
|
||||
services => services.AddDirectoryBrowser());
|
||||
|
||||
HttpResponseMessage response = await server.CreateRequest(requestUrl).SendAsync("HEAD");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Http.Core": "1.0.0-*",
|
||||
"Microsoft.AspNet.RequestContainer": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
"Microsoft.AspNet.TestHost": "1.0.0-*",
|
||||
"Microsoft.Framework.Logging.Testing": "1.0.0-*",
|
||||
|
|
|
|||
Loading…
Reference in New Issue