From c6477ad031f285923ea838ba307594eb45d68dc8 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 29 Sep 2015 12:48:15 -0700 Subject: [PATCH] Fix unit tests on x-plat. --- .../CacheHeaderTests.cs | 46 +++++++-------- .../DefaultFilesMiddlewareTests.cs | 19 ++++--- .../DirectoryBrowserMiddlewareTests.cs | 17 +++--- .../RangeHeaderTests.cs | 56 +++++++++---------- .../StaticFileMiddlewareTests.cs | 25 ++++----- .../SubFolder/{Default.html => default.html} | 0 .../SubFolder/{Extra.xml => extra.xml} | 0 .../SubFolder/{Ranges.txt => ranges.txt} | 0 8 files changed, 81 insertions(+), 82 deletions(-) rename test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/{Default.html => default.html} (100%) rename test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/{Extra.xml => extra.xml} (100%) rename test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/{Ranges.txt => ranges.txt} (100%) diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/CacheHeaderTests.cs b/test/Microsoft.AspNet.StaticFiles.Tests/CacheHeaderTests.cs index 2443d04d5a..a70460d9f1 100644 --- a/test/Microsoft.AspNet.StaticFiles.Tests/CacheHeaderTests.cs +++ b/test/Microsoft.AspNet.StaticFiles.Tests/CacheHeaderTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.StaticFiles { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); + HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); Assert.NotNull(response.Headers.ETag); Assert.NotNull(response.Headers.ETag.Tag); } @@ -28,8 +28,8 @@ namespace Microsoft.AspNet.StaticFiles { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage response1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); - HttpResponseMessage response2 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); + HttpResponseMessage response1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); + HttpResponseMessage response2 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); Assert.Equal(response2.Headers.ETag, response1.Headers.ETag); } @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfMatchShouldReturn412WhenNotListed() { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml"); req.Headers.Add("If-Match", "\"fake\""); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.PreconditionFailed, resp.StatusCode); @@ -55,9 +55,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfMatchShouldBeServedWhenListed() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml"); req.Headers.Add("If-Match", original.Headers.ETag.ToString()); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -67,7 +67,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfMatchShouldBeServedForAstrisk() { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml"); req.Headers.Add("If-Match", "*"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -91,14 +91,14 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfNoneMatchShouldReturn304ForMatchingOnGetAndHeadMethod() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); + HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); - var req2 = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml"); + var req2 = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml"); req2.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString()); HttpResponseMessage resp2 = await server.CreateClient().SendAsync(req2); Assert.Equal(HttpStatusCode.NotModified, resp2.StatusCode); - var req3 = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Extra.xml"); + var req3 = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/extra.xml"); req3.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString()); HttpResponseMessage resp3 = await server.CreateClient().SendAsync(req3); Assert.Equal(HttpStatusCode.NotModified, resp3.StatusCode); @@ -108,14 +108,14 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfNoneMatchShouldBeIgnoredForNonTwoHundredAnd304Responses() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); + HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); - var req2 = new HttpRequestMessage(HttpMethod.Post, "http://localhost/SubFolder/Extra.xml"); + var req2 = new HttpRequestMessage(HttpMethod.Post, "http://localhost/SubFolder/extra.xml"); req2.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString()); HttpResponseMessage resp2 = await server.CreateClient().SendAsync(req2); Assert.Equal(HttpStatusCode.NotFound, resp2.StatusCode); - var req3 = new HttpRequestMessage(HttpMethod.Put, "http://localhost/SubFolder/Extra.xml"); + var req3 = new HttpRequestMessage(HttpMethod.Put, "http://localhost/SubFolder/extra.xml"); req3.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString()); HttpResponseMessage resp3 = await server.CreateClient().SendAsync(req3); Assert.Equal(HttpStatusCode.NotFound, resp3.StatusCode); @@ -136,7 +136,7 @@ namespace Microsoft.AspNet.StaticFiles { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml"); + HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml"); Assert.NotNull(response.Content.Headers.LastModified); } @@ -154,11 +154,11 @@ namespace Microsoft.AspNet.StaticFiles { TestServer server = TestServer.Create(app => app.UseFileServer()); HttpResponseMessage resp1 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .GetAsync(); HttpResponseMessage resp2 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .AddHeader("If-None-Match", resp1.Headers.ETag.ToString()) .And(req => req.Headers.IfModifiedSince = resp1.Content.Headers.LastModified) .GetAsync(); @@ -171,7 +171,7 @@ namespace Microsoft.AspNet.StaticFiles { TestServer server = TestServer.Create(app => app.UseFileServer()); HttpResponseMessage resp1 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .GetAsync(); DateTimeOffset lastModified = resp1.Content.Headers.LastModified.Value; @@ -179,19 +179,19 @@ namespace Microsoft.AspNet.StaticFiles DateTimeOffset furtureDate = lastModified.AddHours(1); HttpResponseMessage resp2 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .AddHeader("If-None-Match", "\"fake\"") .And(req => req.Headers.IfModifiedSince = lastModified) .GetAsync(); HttpResponseMessage resp3 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .AddHeader("If-None-Match", resp1.Headers.ETag.ToString()) .And(req => req.Headers.IfModifiedSince = pastDate) .GetAsync(); HttpResponseMessage resp4 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .AddHeader("If-None-Match", "\"fake\"") .And(req => req.Headers.IfModifiedSince = furtureDate) .GetAsync(); @@ -219,7 +219,7 @@ namespace Microsoft.AspNet.StaticFiles TestServer server = TestServer.Create(app => app.UseFileServer()); HttpResponseMessage res = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .AddHeader("If-Modified-Since", "bad-date") .GetAsync(); @@ -239,11 +239,11 @@ namespace Microsoft.AspNet.StaticFiles TestServer server = TestServer.Create(app => app.UseFileServer()); HttpResponseMessage res1 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .GetAsync(); HttpResponseMessage res2 = await server - .CreateRequest("/SubFolder/Extra.xml") + .CreateRequest("/SubFolder/extra.xml") .And(req => req.Headers.IfModifiedSince = res1.Content.Headers.LastModified) .GetAsync(); diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs b/test/Microsoft.AspNet.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs index d39492a98c..4a0ea4eb8c 100644 --- a/test/Microsoft.AspNet.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs +++ b/test/Microsoft.AspNet.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; +using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -32,7 +33,7 @@ namespace Microsoft.AspNet.StaticFiles [InlineData("", @".", "/missing.dir/")] [InlineData("/subdir", @".", "/subdir/missing.dir")] [InlineData("/subdir", @".", "/subdir/missing.dir/")] - [InlineData("", @".\", "/missing.dir")] + [InlineData("", @"./", "/missing.dir")] public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => @@ -52,8 +53,8 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/SubFolder/")] - [InlineData("", @".\", "/SubFolder/")] - [InlineData("", @".\SubFolder", "/")] + [InlineData("", @"./", "/SubFolder/")] + [InlineData("", @"./SubFolder", "/")] public async Task FoundDirectoryWithDefaultFile_PathModified(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => @@ -73,8 +74,8 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/SubFolder", "")] - [InlineData("", @".\", "/SubFolder", "")] - [InlineData("", @".\", "/SubFolder", "?a=b")] + [InlineData("", @"./", "/SubFolder", "")] + [InlineData("", @"./", "/SubFolder", "?a=b")] public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString) { TestServer server = TestServer.Create(app => app.UseDefaultFiles(new DefaultFilesOptions() @@ -85,15 +86,15 @@ namespace Microsoft.AspNet.StaticFiles HttpResponseMessage response = await server.CreateRequest(requestUrl + queryString).GetAsync(); Assert.Equal(HttpStatusCode.Moved, response.StatusCode); - Assert.Equal(requestUrl + "/" + queryString, response.Headers.Location.ToString()); + Assert.Equal(requestUrl + "/" + queryString, response.Headers.GetValues("Location").FirstOrDefault()); Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length); } [Theory] - [InlineData("/SubFolder", @".\", "/SubFolder/")] + [InlineData("/SubFolder", @"./", "/SubFolder/")] [InlineData("/SubFolder", @".", "/somedir/")] - [InlineData("", @".\SubFolder", "/")] - [InlineData("", @".\SubFolder\", "/")] + [InlineData("", @"./SubFolder", "/")] + [InlineData("", @"./SubFolder/", "/")] public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => app.UseDefaultFiles(new DefaultFilesOptions() diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs b/test/Microsoft.AspNet.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs index 89cf846ca7..a217a841c1 100644 --- a/test/Microsoft.AspNet.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs +++ b/test/Microsoft.AspNet.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -43,7 +44,7 @@ namespace Microsoft.AspNet.StaticFiles [InlineData("", @".", "/missing.dir/")] [InlineData("/subdir", @".", "/subdir/missing.dir")] [InlineData("/subdir", @".", "/subdir/missing.dir/")] - [InlineData("", @".\", "/missing.dir")] + [InlineData("", @"./", "/missing.dir")] public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create( @@ -61,8 +62,8 @@ namespace Microsoft.AspNet.StaticFiles [InlineData("", @".", "/")] [InlineData("", @".", "/SubFolder/")] [InlineData("/somedir", @".", "/somedir/")] - [InlineData("/somedir", @".\", "/somedir/")] - [InlineData("/somedir", @".", "/somedir/subfolder/")] + [InlineData("/somedir", @"./", "/somedir/")] + [InlineData("/somedir", @".", "/somedir/SubFolder/")] public async Task FoundDirectory_Served(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create( @@ -83,10 +84,10 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/SubFolder", "")] [InlineData("/somedir", @".", "/somedir", "")] - [InlineData("/somedir", @".", "/somedir/subfolder", "")] + [InlineData("/somedir", @".", "/somedir/SubFolder", "")] [InlineData("", @".", "/SubFolder", "?a=b")] [InlineData("/somedir", @".", "/somedir", "?a=b")] - [InlineData("/somedir", @".", "/somedir/subfolder", "?a=b")] + [InlineData("/somedir", @".", "/somedir/SubFolder", "?a=b")] public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString) { TestServer server = TestServer.Create( @@ -100,7 +101,7 @@ namespace Microsoft.AspNet.StaticFiles HttpResponseMessage response = await server.CreateRequest(requestUrl + queryString).GetAsync(); Assert.Equal(HttpStatusCode.Moved, response.StatusCode); - Assert.Equal(requestUrl + "/" + queryString, response.Headers.Location.ToString()); + Assert.Equal(requestUrl + "/" + queryString, response.Headers.GetValues("Location").FirstOrDefault()); Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length); } @@ -108,7 +109,7 @@ namespace Microsoft.AspNet.StaticFiles [InlineData("", @".", "/")] [InlineData("", @".", "/SubFolder/")] [InlineData("/somedir", @".", "/somedir/")] - [InlineData("/somedir", @".", "/somedir/subfolder/")] + [InlineData("/somedir", @".", "/somedir/SubFolder/")] public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create( @@ -127,7 +128,7 @@ namespace Microsoft.AspNet.StaticFiles [InlineData("", @".", "/")] [InlineData("", @".", "/SubFolder/")] [InlineData("/somedir", @".", "/somedir/")] - [InlineData("/somedir", @".", "/somedir/subfolder/")] + [InlineData("/somedir", @".", "/somedir/SubFolder/")] public async Task HeadDirectory_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create( diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/RangeHeaderTests.cs b/test/Microsoft.AspNet.StaticFiles.Tests/RangeHeaderTests.cs index 26db991d67..5fc1b6de4e 100644 --- a/test/Microsoft.AspNet.StaticFiles.Tests/RangeHeaderTests.cs +++ b/test/Microsoft.AspNet.StaticFiles.Tests/RangeHeaderTests.cs @@ -20,9 +20,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfRangeWithCurrentEtagShouldServePartialContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Headers.ETag.ToString()); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -40,9 +40,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADIfRangeWithCurrentEtagShouldReturn200Ok() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Headers.ETag.ToString()); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -60,9 +60,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfRangeWithCurrentDateShouldServePartialContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -79,9 +79,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADIfRangeWithCurrentDateShouldReturn200Ok() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -99,7 +99,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfRangeWithOldEtagShouldServeFullContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", "\"OldEtag\""); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -115,7 +115,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADIfRangeWithOldEtagShouldServeFullContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", "\"OldEtag\""); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -131,9 +131,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfRangeWithOldDateShouldServeFullContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.Subtract(TimeSpan.FromDays(1)).ToString("r")); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -149,9 +149,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADIfRangeWithOldDateShouldServeFullContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.Subtract(TimeSpan.FromDays(1)).ToString("r")); req.Headers.Add("Range", "bytes=0-10"); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); @@ -168,9 +168,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task IfRangeWithoutRangeShouldServeFullContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Headers.ETag.ToString()); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -178,7 +178,7 @@ namespace Microsoft.AspNet.StaticFiles Assert.Equal(62, resp.Content.Headers.ContentLength); Assert.Equal("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", await resp.Content.ReadAsStringAsync()); - req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -194,9 +194,9 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADIfRangeWithoutRangeShouldServeFullContent() { TestServer server = TestServer.Create(app => app.UseFileServer()); - HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt"); + HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt"); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Headers.ETag.ToString()); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -204,7 +204,7 @@ namespace Microsoft.AspNet.StaticFiles Assert.Equal(62, resp.Content.Headers.ContentLength); Assert.Equal(string.Empty, await resp.Content.ReadAsStringAsync()); - req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -226,7 +226,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task SingleValidRangeShouldServePartialContent(string range, string expectedRange, int length, string expectedData) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.PartialContent, resp.StatusCode); @@ -243,7 +243,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADSingleValidRangeShouldReturnOk(string range) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -260,7 +260,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task SingleNotSatisfiableRange(string range) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.TryAddWithoutValidation("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, resp.StatusCode); @@ -274,7 +274,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADSingleNotSatisfiableRangeReturnsOk(string range) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.TryAddWithoutValidation("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -290,7 +290,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task SingleInvalidRangeIgnored(string range) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.TryAddWithoutValidation("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -308,7 +308,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADSingleInvalidRangeIgnored(string range) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.TryAddWithoutValidation("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -328,7 +328,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task MultipleValidRangesShouldServeFullContent(string ranges) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("Range", "bytes=" + ranges); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); @@ -347,7 +347,7 @@ namespace Microsoft.AspNet.StaticFiles public async Task HEADMultipleValidRangesShouldServeFullContent(string range) { TestServer server = TestServer.Create(app => app.UseFileServer()); - var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt"); + var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt"); req.Headers.Add("Range", "bytes=" + range); HttpResponseMessage resp = await server.CreateClient().SendAsync(req); Assert.Equal(HttpStatusCode.OK, resp.StatusCode); diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/StaticFileMiddlewareTests.cs b/test/Microsoft.AspNet.StaticFiles.Tests/StaticFileMiddlewareTests.cs index affcee553a..4d6595e630 100644 --- a/test/Microsoft.AspNet.StaticFiles.Tests/StaticFileMiddlewareTests.cs +++ b/test/Microsoft.AspNet.StaticFiles.Tests/StaticFileMiddlewareTests.cs @@ -33,8 +33,8 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/missing.file")] [InlineData("/subdir", @".", "/subdir/missing.file")] - [InlineData("/missing.file", @".\", "/missing.file")] - [InlineData("", @".\", "/xunit.xml")] + [InlineData("/missing.file", @"./", "/missing.file")] + [InlineData("", @"./", "/xunit.xml")] public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions() @@ -48,11 +48,10 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/TestDocument.txt")] - [InlineData("", @".", "/testDocument.Txt")] - [InlineData("/somedir", @".", "/somedir/Testdocument.TXT")] - [InlineData("/SomeDir", @".", "/soMediR/testdocument.txT")] + [InlineData("/somedir", @".", "/somedir/TestDocument.txt")] + [InlineData("/SomeDir", @".", "/soMediR/TestDocument.txt")] [InlineData("", @"SubFolder", "/ranges.txt")] - [InlineData("/somedir", @"SubFolder", "/somedir/Ranges.tXt")] + [InlineData("/somedir", @"SubFolder", "/somedir/ranges.txt")] public async Task FoundFile_Served(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions() @@ -70,11 +69,10 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/TestDocument.txt")] - [InlineData("", @".", "/testDocument.Txt")] - [InlineData("/somedir", @".", "/somedir/Testdocument.TXT")] - [InlineData("/SomeDir", @".", "/soMediR/testdocument.txT")] + [InlineData("/somedir", @".", "/somedir/TestDocument.txt")] + [InlineData("/SomeDir", @".", "/soMediR/TestDocument.txt")] [InlineData("", @"SubFolder", "/ranges.txt")] - [InlineData("/somedir", @"SubFolder", "/somedir/Ranges.tXt")] + [InlineData("/somedir", @"SubFolder", "/somedir/ranges.txt")] public async Task PostFile_PassesThrough(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions() @@ -88,11 +86,10 @@ namespace Microsoft.AspNet.StaticFiles [Theory] [InlineData("", @".", "/TestDocument.txt")] - [InlineData("", @".", "/testDocument.Txt")] - [InlineData("/somedir", @".", "/somedir/Testdocument.TXT")] - [InlineData("/SomeDir", @".", "/soMediR/testdocument.txT")] + [InlineData("/somedir", @".", "/somedir/TestDocument.txt")] + [InlineData("/SomeDir", @".", "/soMediR/TestDocument.txt")] [InlineData("", @"SubFolder", "/ranges.txt")] - [InlineData("/somedir", @"SubFolder", "/somedir/Ranges.tXt")] + [InlineData("/somedir", @"SubFolder", "/somedir/ranges.txt")] public async Task HeadFile_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl) { TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions() diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/Default.html b/test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/default.html similarity index 100% rename from test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/Default.html rename to test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/default.html diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/Extra.xml b/test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/extra.xml similarity index 100% rename from test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/Extra.xml rename to test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/extra.xml diff --git a/test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/Ranges.txt b/test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/ranges.txt similarity index 100% rename from test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/Ranges.txt rename to test/Microsoft.AspNet.StaticFiles.Tests/SubFolder/ranges.txt