This commit is contained in:
Nate McMaster 2017-08-22 15:43:31 -07:00
Родитель dc8d1d0788
Коммит c36b18d80e
8 изменённых файлов: 27 добавлений и 31 удалений

Просмотреть файл

@ -6,7 +6,7 @@
<NETStandardImplicitPackageVersion>2.0.0-*</NETStandardImplicitPackageVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion>
<XunitVersion>2.3.0-beta2-*</XunitVersion>
<TestSdkVersion>15.3.0</TestSdkVersion>
<XunitVersion>2.3.0-beta4-build3742</XunitVersion>
</PropertyGroup>
</Project>

Просмотреть файл

@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{
var response = await SendRequestAsync(address);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(0, response.Headers.WwwAuthenticate.Count);
Assert.Empty(response.Headers.WwwAuthenticate);
}
}
@ -186,7 +186,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{
var response = await SendRequestAsync(address);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(0, response.Headers.WwwAuthenticate.Count);
Assert.Empty(response.Headers.WwwAuthenticate);
}
}
@ -306,12 +306,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys
}
}
[ConditionalTheory]
[InlineData(AuthenticationSchemes.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)]
[InlineData(AuthenticationSchemes.Basic)]
public async Task AuthTypes_Forbid_Forbidden(AuthenticationSchemes authType)
[ConditionalFact]
public async Task AuthTypes_Forbid_Forbidden()
{
var authTypes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic;
using (var server = Utilities.CreateDynamicHost(authTypes, AllowAnoymous, out var address, httpContext =>
@ -324,7 +320,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{
var response = await SendRequestAsync(address);
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
Assert.Equal(0, response.Headers.WwwAuthenticate.Count);
Assert.Empty(response.Headers.WwwAuthenticate);
}
}
@ -345,7 +341,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{
var response = await SendRequestAsync(address, useDefaultCredentials: true);
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
Assert.Equal(1, response.Headers.WwwAuthenticate.Count);
Assert.Single(response.Headers.WwwAuthenticate);
Assert.Equal(authType.ToString(), response.Headers.WwwAuthenticate.First().Scheme);
}
}

Просмотреть файл

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
var response = await responseTask;
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(0, response.Headers.WwwAuthenticate.Count);
Assert.Empty(response.Headers.WwwAuthenticate);
}
}

Просмотреть файл

@ -1083,7 +1083,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
response = await SendRequestAsync(address, "GET", "Range", "bytes=0-10,15-20");
Assert.Equal(206, (int)response.StatusCode);
Assert.Equal("1", response.Headers.GetValues("x-request-count").FirstOrDefault());
Assert.True(response.Content.Headers.GetValues("content-type").First().StartsWith("multipart/byteranges;"));
Assert.StartsWith("multipart/byteranges;", response.Content.Headers.GetValues("content-type").First());
}
}
@ -1145,7 +1145,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
response = await SendRequestAsync(address, "GET", "Range", "bytes=0-" + (rangeLength - 1) + "," + rangeLength + "-" + (rangeLength + rangeLength - 1), HttpCompletionOption.ResponseHeadersRead);
Assert.Equal(206, (int)response.StatusCode);
Assert.Equal("1", response.Headers.GetValues("x-request-count").FirstOrDefault());
Assert.True(response.Content.Headers.GetValues("content-type").First().StartsWith("multipart/byteranges;"));
Assert.StartsWith("multipart/byteranges;", response.Content.Headers.GetValues("content-type").First());
}
}

Просмотреть файл

@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.False(response.Headers.TransferEncodingChunked.HasValue);
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.Equal(1, response.Content.Headers.Count());
Assert.Single(response.Content.Headers);
Assert.Equal(0, response.Content.Headers.ContentLength);
}
}
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Headers.ConnectionClose.Value);
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.Equal(1, response.Content.Headers.Count());
Assert.Single(response.Content.Headers);
Assert.Equal(0, response.Content.Headers.ContentLength);
}
}
@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.False(response.Content.Headers.Contains("Content-Length"));
Assert.Equal(0, response.Content.Headers.Count());
Assert.Empty(response.Content.Headers);
// Send a second request to check that the connection wasn't corrupted.
responseTask = SendHeadRequestAsync(address);
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.False(response.Content.Headers.Contains("Content-Length"));
Assert.Equal(0, response.Content.Headers.Count());
Assert.Empty(response.Content.Headers);
// Send a second request to check that the connection wasn't corrupted.
responseTask = SendHeadRequestAsync(address);
@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.False(response.Headers.TransferEncodingChunked.HasValue);
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.Equal(1, response.Content.Headers.Count());
Assert.Single(response.Content.Headers);
Assert.Equal(20, response.Content.Headers.ContentLength);
// Send a second request to check that the connection wasn't corrupted.
@ -173,7 +173,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.False(response.Content.Headers.Contains("Content-Length"));
Assert.Equal(0, response.Content.Headers.Count());
Assert.Empty(response.Content.Headers);
}
}
@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.False(response.Content.Headers.Contains("Content-Length"));
Assert.Equal(0, response.Content.Headers.Count());
Assert.Empty(response.Content.Headers);
// Send a second request to check that the connection wasn't corrupted.
responseTask = SendHeadRequestAsync(address);
@ -414,7 +414,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.Equal(2, response.Headers.GetValues("Custom1").Count());
Assert.Equal("value1a", response.Headers.GetValues("Custom1").First());
Assert.Equal("value1b", response.Headers.GetValues("Custom1").Skip(1).First());
Assert.Equal(1, response.Headers.GetValues("Custom2").Count());
Assert.Single(response.Headers.GetValues("Custom2"));
Assert.Equal("value2a, value2b", response.Headers.GetValues("Custom2").First());
}
}
@ -450,7 +450,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.Equal(2, response.Headers.GetValues("Custom1").Count());
Assert.Equal("value1a", response.Headers.GetValues("Custom1").First());
Assert.Equal("value1b", response.Headers.GetValues("Custom1").Skip(1).First());
Assert.Equal(1, response.Headers.GetValues("Custom2").Count());
Assert.Single(response.Headers.GetValues("Custom2"));
Assert.Equal("value2a, value2b", response.Headers.GetValues("Custom2").First());
}
}

Просмотреть файл

@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
IEnumerable<string> contentLength;
Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
Assert.True(response.Headers.TransferEncodingChunked.Value);
Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length);
Assert.Empty((await response.Content.ReadAsByteArrayAsync()));
}
}
@ -299,7 +299,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
Assert.Equal("0", contentLength.First());
Assert.Null(response.Headers.TransferEncodingChunked);
Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length);
Assert.Empty((await response.Content.ReadAsByteArrayAsync()));
}
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.False(response.Headers.TransferEncodingChunked.HasValue);
Assert.True(response.Headers.Date.HasValue);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers.Server.ToString());
Assert.Equal(1, response.Content.Headers.Count());
Assert.Single(response.Content.Headers);
Assert.Equal(0, response.Content.Headers.ContentLength);
}
}
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.Equal(2, response.Headers.GetValues("Custom1").Count());
Assert.Equal("value1a", response.Headers.GetValues("Custom1").First());
Assert.Equal("value1b", response.Headers.GetValues("Custom1").Skip(1).First());
Assert.Equal(1, response.Headers.GetValues("Custom2").Count());
Assert.Single(response.Headers.GetValues("Custom2"));
Assert.Equal("value2a, value2b", response.Headers.GetValues("Custom2").First());
}
}
@ -254,7 +254,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.Equal(2, response.Headers.GetValues("Custom1").Count());
Assert.Equal("value1a", response.Headers.GetValues("Custom1").First());
Assert.Equal("value1b", response.Headers.GetValues("Custom1").Skip(1).First());
Assert.Equal(1, response.Headers.GetValues("Custom2").Count());
Assert.Single(response.Headers.GetValues("Custom2"));
Assert.Equal("value2a, value2b", response.Headers.GetValues("Custom2").First());
}
}

Просмотреть файл

@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
IEnumerable<string> contentLength;
Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
Assert.True(response.Headers.TransferEncodingChunked.Value);
Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length);
Assert.Empty((await response.Content.ReadAsByteArrayAsync()));
}
}
@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
Assert.Equal("0", contentLength.First());
Assert.Null(response.Headers.TransferEncodingChunked);
Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length);
Assert.Empty((await response.Content.ReadAsByteArrayAsync()));
}
}