Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard1.3-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,189 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.ComponentModel;
using System.Net;
using System.Net.Http;
using System.Net.Security;
using System.Net.Test.Common;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace System.Net.Http.WinHttpHandlerFunctional.Tests
{
public class ServerCertificateTest
{
private readonly ITestOutputHelper _output;
private readonly ValidationCallbackHistory _validationCallbackHistory;
public ServerCertificateTest(ITestOutputHelper output)
{
_output = output;
_validationCallbackHistory = new ValidationCallbackHistory();
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public async Task NoCallback_ValidCertificate_CallbackNotCalled()
{
var handler = new WinHttpHandler();
using (var client = new HttpClient(handler))
using (HttpResponseMessage response = await client.GetAsync(System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer))
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.False(_validationCallbackHistory.WasCalled);
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public async Task UseCallback_NotSecureConnection_CallbackNotCalled()
{
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
using (var client = new HttpClient(handler))
using (HttpResponseMessage response = await client.GetAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer))
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.False(_validationCallbackHistory.WasCalled);
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public async Task UseCallback_ValidCertificate_ExpectedValuesDuringCallback()
{
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
using (var client = new HttpClient(handler))
using (HttpResponseMessage response = await client.GetAsync(System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer))
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.True(_validationCallbackHistory.WasCalled);
ConfirmValidCertificate(System.Net.Test.Common.Configuration.Http.Host);
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public async Task UseCallback_RedirectandValidCertificate_ExpectedValuesDuringCallback()
{
Uri uri = System.Net.Test.Common.Configuration.Http.RedirectUriForDestinationUri(true, 302, System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer, 1);
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
using (var client = new HttpClient(handler))
using (HttpResponseMessage response = await client.GetAsync(uri))
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.True(_validationCallbackHistory.WasCalled);
ConfirmValidCertificate(System.Net.Test.Common.Configuration.Http.Host);
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public async Task UseCallback_CallbackReturnsFailure_ThrowsInnerSecurityFailureException()
{
const int ERROR_WINHTTP_SECURE_FAILURE = 12175;
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
using (var client = new HttpClient(handler))
{
var request = new HttpRequestMessage(HttpMethod.Get, System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer);
_validationCallbackHistory.ReturnFailure = true;
HttpRequestException ex = await Assert.ThrowsAsync<HttpRequestException>(() =>
client.GetAsync(System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer));
var innerEx = (Win32Exception)ex.InnerException;
Assert.Equal(ERROR_WINHTTP_SECURE_FAILURE, innerEx.NativeErrorCode);
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public async Task UseCallback_CallbackThrowsSpecificException_ThrowsInnerSpecificException()
{
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
using (var client = new HttpClient(handler))
{
_validationCallbackHistory.ThrowException = true;
await Assert.ThrowsAsync<CustomException>(() => client.GetAsync(System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer));
}
}
private void ConfirmValidCertificate(string expectedHostName)
{
Assert.Equal(SslPolicyErrors.None, _validationCallbackHistory.SslPolicyErrors);
Assert.True(_validationCallbackHistory.CertificateChain.Count > 0);
_output.WriteLine("Certificate.Subject: {0}", _validationCallbackHistory.CertificateSubject);
_output.WriteLine("Expected HostName: {0}", expectedHostName);
}
private bool CustomServerCertificateValidationCallback(
HttpRequestMessage sender,
X509Certificate2 certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
_validationCallbackHistory.WasCalled = true;
_validationCallbackHistory.CertificateSubject = certificate.Subject;
foreach (var element in chain.ChainElements)
{
_validationCallbackHistory.CertificateChain.Add(element.Certificate);
}
_validationCallbackHistory.ChainStatus = chain.ChainStatus;
_validationCallbackHistory.SslPolicyErrors = sslPolicyErrors;
if (_validationCallbackHistory.ThrowException)
{
throw new CustomException();
}
if (_validationCallbackHistory.ReturnFailure)
{
return false;
}
return true;
}
public class CustomException : Exception
{
public CustomException()
{
}
}
public class ValidationCallbackHistory
{
public bool ThrowException;
public bool ReturnFailure;
public bool WasCalled;
public SslPolicyErrors SslPolicyErrors;
public string CertificateSubject;
public X509CertificateCollection CertificateChain;
public X509ChainStatus[] ChainStatus;
public ValidationCallbackHistory()
{
ThrowException = false;
ReturnFailure = false;
WasCalled = false;
SslPolicyErrors = SslPolicyErrors.None;
CertificateSubject = null;
CertificateChain = new X509CertificateCollection();
ChainStatus = null;
}
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Net.Http.WinHttpHandler.Functional.Tests.csproj">
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>netcoreapp;netcoreapp1.0;net46</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{17D5CC82-F72C-4DD2-B6DB-DE7FB2F19C34}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Release|AnyCPU'" />
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' ">
<Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
<Link>Common\System\Net\Configuration.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\Net\Configuration.Http.cs">
<Link>Common\System\Net\Configuration.Http.cs</Link>
</Compile>
<Compile Include="ServerCertificateTest.cs" />
<Compile Include="WinHttpHandlerTest.cs" />
<Compile Include="XunitTestAssemblyAtrributes.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,121 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Net;
using System.Net.Http;
using System.Net.Test.Common;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
// Can't use "WinHttpHandler.Functional.Tests" in namespace as it won't compile.
// WinHttpHandler is a class and not a namespace and can't be part of namespace paths.
namespace System.Net.Http.WinHttpHandlerFunctional.Tests
{
// Note: Disposing the HttpClient object automatically disposes the handler within. So, it is not necessary
// to separately Dispose (or have a 'using' statement) for the handler.
public class WinHttpHandlerTest
{
// TODO: This is a placeholder until GitHub Issue #2383 gets resolved.
private const string SlowServer = "http://httpbin.org/drip?numbytes=1&duration=1&delay=40&code=200";
private readonly ITestOutputHelper _output;
public WinHttpHandlerTest(ITestOutputHelper output)
{
_output = output;
}
[OuterLoop] // TODO: Issue #11345
[Fact]
public void SendAsync_SimpleGet_Success()
{
var handler = new WinHttpHandler();
using (var client = new HttpClient(handler))
{
// TODO: This is a placeholder until GitHub Issue #2383 gets resolved.
var response = client.GetAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer).Result;
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var responseContent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
_output.WriteLine(responseContent);
}
}
[OuterLoop] // TODO: Issue #11345
[Theory]
[InlineData(CookieUsePolicy.UseInternalCookieStoreOnly, "cookieName1", "cookieValue1")]
[InlineData(CookieUsePolicy.UseSpecifiedCookieContainer, "cookieName2", "cookieValue2")]
public async Task GetAsync_RedirectResponseHasCookie_CookieSentToFinalUri(
CookieUsePolicy cookieUsePolicy,
string cookieName,
string cookieValue)
{
Uri uri = System.Net.Test.Common.Configuration.Http.RedirectUriForDestinationUri(false, 302, System.Net.Test.Common.Configuration.Http.RemoteEchoServer, 1);
var handler = new WinHttpHandler();
handler.WindowsProxyUsePolicy = WindowsProxyUsePolicy.UseWinInetProxy;
handler.CookieUsePolicy = cookieUsePolicy;
if (cookieUsePolicy == CookieUsePolicy.UseSpecifiedCookieContainer)
{
handler.CookieContainer = new CookieContainer();
}
using (HttpClient client = new HttpClient(handler))
{
client.DefaultRequestHeaders.Add(
"X-SetCookie",
string.Format("{0}={1};Path=/", cookieName, cookieValue));
using (HttpResponseMessage httpResponse = await client.GetAsync(uri))
{
string responseText = await httpResponse.Content.ReadAsStringAsync();
_output.WriteLine(responseText);
Assert.True(JsonMessageContainsKeyValue(responseText, cookieName, cookieValue));
}
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
[OuterLoop]
public async Task SendAsync_SlowServerAndCancel_ThrowsTaskCanceledException()
{
var handler = new WinHttpHandler();
using (var client = new HttpClient(handler))
{
var cts = new CancellationTokenSource();
Task<HttpResponseMessage> t = client.GetAsync(SlowServer, cts.Token);
await Task.Delay(500);
cts.Cancel();
AggregateException ag = Assert.Throws<AggregateException>(() => t.Wait());
Assert.IsType<TaskCanceledException>(ag.InnerException);
}
}
[OuterLoop] // TODO: Issue #11345
[Fact]
[OuterLoop]
public void SendAsync_SlowServerRespondsAfterDefaultReceiveTimeout_ThrowsHttpRequestException()
{
var handler = new WinHttpHandler();
using (var client = new HttpClient(handler))
{
Task<HttpResponseMessage> t = client.GetAsync(SlowServer);
AggregateException ag = Assert.Throws<AggregateException>(() => t.Wait());
Assert.IsType<HttpRequestException>(ag.InnerException);
}
}
public static bool JsonMessageContainsKeyValue(string message, string key, string value)
{
// TODO: Merge with System.Net.Http TestHelper class as part of GitHub Issue #4989.
string pattern = string.Format(@"""{0}"": ""{1}""", key, value);
return message.Contains(pattern);
}
}
}

View File

@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Xunit;
// The WinHttpHandler unit tests need to have parallelism turned off between test classes since they rely on
// a mock network with simulated failures controlled by singleton static classes (TestControl, TestServer).
// This attribute will put all test classes into a single collection. Default Xunit behavior is to run tests
// within a single collection in series and not in parallel.
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]

View File

@@ -0,0 +1,107 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public static class APICallHistory
{
public const string StringNotSet = "NOT SET";
private static ProxyInfo sessionProxySettings;
private static ProxyInfo requestProxySettings;
private static List<IntPtr> winHttpOptionClientCertContextList = new List<IntPtr>();
public static ProxyInfo SessionProxySettings
{
get
{
return sessionProxySettings;
}
set
{
sessionProxySettings.AccessType = value.AccessType;
sessionProxySettings.Proxy = value.Proxy;
sessionProxySettings.ProxyBypass = value.ProxyBypass;
}
}
public static ProxyInfo RequestProxySettings
{
get
{
return requestProxySettings;
}
set
{
requestProxySettings.AccessType = value.AccessType;
requestProxySettings.Proxy = value.Proxy;
requestProxySettings.ProxyBypass = value.ProxyBypass;
}
}
public static string ProxyUsernameWithDomain { get; set; }
public static string ProxyPassword { get; set; }
public static string ServerUsernameWithDomain { get; set; }
public static string ServerPassword { get; set; }
public static bool? WinHttpOptionDisableCookies { get; set; }
public static bool? WinHttpOptionEnableSslRevocation { get; set; }
public static uint? WinHttpOptionSecureProtocols { get; set; }
public static uint? WinHttpOptionSecurityFlags { get; set; }
public static uint? WinHttpOptionMaxHttpAutomaticRedirects { get; set; }
public static uint? WinHttpOptionRedirectPolicy { get; set; }
public static int? WinHttpOptionSendTimeout { get; set; }
public static int? WinHttpOptionReceiveTimeout { get; set; }
public static List<IntPtr> WinHttpOptionClientCertContext { get { return winHttpOptionClientCertContextList; } }
public static void Reset()
{
sessionProxySettings.AccessType = null;
sessionProxySettings.Proxy = APICallHistory.StringNotSet;
sessionProxySettings.ProxyBypass = APICallHistory.StringNotSet;
requestProxySettings.AccessType = null;
requestProxySettings.Proxy = APICallHistory.StringNotSet;
requestProxySettings.ProxyBypass = APICallHistory.StringNotSet;
ProxyUsernameWithDomain = APICallHistory.StringNotSet;
ProxyPassword = APICallHistory.StringNotSet;
ServerUsernameWithDomain = APICallHistory.StringNotSet;
ServerPassword = APICallHistory.StringNotSet;
WinHttpOptionDisableCookies = null;
WinHttpOptionEnableSslRevocation = null;
WinHttpOptionSecureProtocols = null;
WinHttpOptionSecurityFlags = null;
WinHttpOptionMaxHttpAutomaticRedirects = null;
WinHttpOptionRedirectPolicy = null;
WinHttpOptionSendTimeout = null;
WinHttpOptionReceiveTimeout = null;
winHttpOptionClientCertContextList.Clear();
}
public struct ProxyInfo
{
public uint? AccessType;
public string Proxy;
public string ProxyBypass;
}
}
}

View File

@@ -0,0 +1,311 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography.X509Certificates;
using Xunit;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public class ClientCertificateHelper
{
private readonly X509Certificate2 _cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_PrivateKey =
new X509Certificate2(
Convert.FromBase64String(
@"MIIKTgIBAzCCCgoGCSqGSIb3DQEHAaCCCfsEggn3MIIJ8zCCBgwGCSqGSIb3DQEHAaCCBf0EggX5
MIIF9TCCBfEGCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAiHDatvDr8QBQIC
B9AEggTYv1r4ckwt7o6f6DCMHlb/zv4t7rPju+PP0PjoJ8kzPfj419aSeyPuE+65YH9WFDqafJed
uzBSDaTXIabKapWN5NLnNYsyjCM3xHuP2N6QVa9irHmXE0BsB+3pfJW/aqIeDpHok/qc6xKxQhx0
jvfSNGkm6dqGpLX67o5ADGRTInmQc8EuLk11I75gJhRgZfsuaHEOaIj8+xbBQprmkDTEtjO/COVu
+FSksIBbQzi8Uyf778zNkvOZNdyOvLBLC4rOnJH1taCTr/9Rd03cf5U2F03GMTppJeoexMQZn/Ue
9F8yeZR20RLXXrgq+jD7a4IIpHhVenuF1+GQjwST3UQiS2QJ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z4uVWPpaNzcwEBhS+g
ARlFuGtfZes2Gky/ZpfxCG8GCuCilqcyV8T1ak0L97Q8JMmYSNcr+DElQdkl9kVgMqiXuHvx1SAQ
7sKxk/eITj7cXon036m30jh7T7CyeIC7S8e++2GMzV4UFQU3OqCkJKOsnvY9Gn/8yrTHGz62oZtY
1DaDg3m47jD9McR1NMhWOSNVcVfZcCzpJ+8yFX58qg2/uiAx9oigEY4Lms5kYCp4AO2VXtrRrp2B
pu7IEDmlF8eqrCUK6t5FqUY50xwgMVqPdW/cbn8YEoBU2TeSjEGXAFapuYDmAgDGUQTseHFXsd+D
wnKlj1xHeDYqBWFKkKt7GDSgq1pPvQVDIDvJbQCeVmYWMzplqPd5NHUojEwwc4jaln0g1M3YRN+w
vEVCG8mH4YtYp4fXCpEsapIn7tfWHPRAYARCwEEMsOuTruE4yPyhLEntVMw7UZlFgt5OuKDmHB6Q
phyJUN/UCnC+hfdTtvfGBzceKB/CAVPPLYmTYIAGfeJiZ+ED43rq1Vru6bIE3H6Bugxen+ZMvBXA
8uCGAHlVTHkmfS3egT8KUIeFLGSj2NBlUuE+lTfSmJcYyE8ptknKpE0PFNoVhtM+7Rc6C+hObBt2
S3POmJhVbUFXX0MoXQU7CfLZgRDNtFuj67izmcnqdfHcLViRPxqYl5uk9KY8UBgo5Gg5qjdv8Csx
3lKowEBJ0mf5/SO8e0jrsngnnBMnzhbH63DpvbMkew9JzYniO/qqbTYTb5Se9xGNaZMeCq9s0Ktn
eGzaLVeL3KuDXTcykeSrMzA7MB8wBwYFKw4DAhoEFFyWxw+sBYjg+u+FZOpcB22jW37XBBTa1n71
1STYVQ5YhCJvstItqyExlAICB9A="),
"password");
private readonly X509Certificate2 _cert_KeyUsageMissingDigitalSignature_EKUIncludesClientAuth_PrivateKey =
new X509Certificate2(
Convert.FromBase64String(
@"MIIKTgIBAzCCCgoGCSqGSIb3DQEHAaCCCfsEggn3MIIJ8zCCBgwGCSqGSIb3DQEHAaCCBf0EggX5
MIIF9TC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ytSAD+0SS5zs4aBu3cXrXCH7ZN4X7Q
QZWC9/2TJnPvzTMtTKrgu9azNjEQw8T2d6uHtEV+qyKm6QR4fs2l25OqH167/StAlpTohOahwzO1
6ZzUabYI5B+4pji7A1fn+aQa8u0kX3qyYNCeEpFoX0FVI6G7VfeFus+91a/sVVa1EkGQrdFE/xBA
gOxmB9mCYydeLzMbYUa7KTA7MB8wBwYFKw4DAhoEFP7GyT09gJP2TcfZRvC4S5rTPsRjBBSWQf3f
BXH9IG0V641MICnWmHeUhQICB9A="),
"password");
private readonly X509Certificate2 _cert_KeyUsageIncludesDigitalSignature_EKUMissingClientAuth_PrivateKey =
new X509Certificate2(
Convert.FromBase64String(
@"MIIKRgIBAzCCCgIGCSqGSIb3DQEHAaCCCfMEggnvMIIJ6zCCBgQGCSqGSIb3DQEHAaCCBfUEggXx
MIIF7TCCBekGCyqGSIb3DQEMCgECoIIE9jCCBPIwHAYKKoZIhvcNAQwBAzAOBAhCUuNQ0RqfZQIC
B9AEggTQHCQRSiCiNI7egTvUaI1Z3tfeLwFWvG7B/za5v9fb97MExoyVQSDmUyUDTlVEcg3gVqJZ
MKGD6U1pmJsnTB+tH53Ho8L9GIrmZKq1L4Y9Wxu/VfIgub4I54UK8LZylpcIkb+OXBn46HnhDBu/
fknsBWLWUbtuOGp7PDHQLvoEu5rvmvTDWTWQr4S7S2cqrR0RIXThKObgKCjJ+/y9YCBZfX8jbZvq
r7vedpoFS0P0mDOk8aILefNADdoALfHzrrxYl0hp31sHrnDHJ0I/j6xFtsKBFmDigtPhHb9+c9PC
Bi/QJ5vmfECiHsw+dwBFH7m50ZbRFllDY6vIOjXRCeixMkq+18GZirX9l042RCijChCIbiaQI9O8
Eejnvkf41+KiVQAoaC42s1yQtmmDDIqJZD6N5X9wx7NgnfjxpuUvq91O/iBN0yzVzep5nQ4CDGmF
ljFc50beI5uOcSNOiO7Zn40h6MkPcecIMlI7sUFlo3IglzQGLvGL3OqsQ+dYqBGLD21x1ItmQOyH
z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AXKE/pUFaeJUpYXg26jhgonQa7ODi8L+cBu4tCjef7NQqe+4I5SOrCDlo04d3S
V38Crywjz7YyC1wSYmxCzMZSAXZZ0K6wWsDnUjpxcuKSjZ98B3SIyNWIitQvlrzv0eo29PYlp4Rz
WPLrPG5y09o8MCtonHfwoKjqjQ5k/4qorwxfHoLwNdQpEEyldaiA14VRcpQukdMr4Y6cDKPU92Tm
iENC3eecBBTPgzaftHPt4A5v8TUiH7NhK1TJTn6qjzLpSONUKe0SSs1me6qqvdOcen+koey7XMTi
+CwJ2pH7QFK3ImxJ4jcTrXIUb0nzRabeAy1fMQv4jBMMqEpBQLpy+NOosME7NhHn9ijM0i0TPImT
Iw3MD5cLB1f2jHlyrviC3gGtIjACb61WLp1g2nkOyXgoq61aBOYQCuE0Ej8tcqbBMwOSV5BdGuAX
4+4wKQm5gN/A61E53rXWbC94KYInPE+cOr520WYXa5A2EBLeD2zFJmPLKRWtcYQ68TpO5CXwv3Vf
PJSfxLpKGbEzJwTVym+e8/wV6rIMenN2wDc3lPUD0BYeQNSthGyb8Lxx7QGIh9n2tv69xCjGX0Q2
XsK7XDeFDEowOzAfMAcGBSsOAwIaBBSRhbklb9VyYh3HUjX0soZDQ4LQYQQUUNfB0Xe9MmRurnYX
KMyIoz+dMXUCAgfQ"),
"password");
private readonly X509Certificate2 _cert_KeyUsageIncludesDigitalSignature_NoEKU_PrivateKey =
new X509Certificate2(
Convert.FromBase64String(
@"MIIKPgIBAzCCCfoGCSqGSIb3DQEHAaCCCesEggnnMIIJ4zCCBgwGCSqGSIb3DQEHAaCCBf0EggX5
MIIF9TCCBfEGCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAijQh1kbOZOYQIC
B9AEggTY+wDp3V31Lh7f8YrsqEsyGZ+GlYvFhLWvDASjisYJi5NlQ0ONbf0KOXHVSvBj3tVyuHm4
5j6PlwF8nLiANmvnNyr+tmnLLx8Fa8XGmi4ggs3YGPJEw6u41qTnPGlT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5HLwrmwm/xDlNMw1KASQOL
AgIH0A=="),
"password");
private readonly X509Certificate2 _cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_NoPrivateKey =
new X509Certificate2(
Convert.FromBase64String(
@"MIIDFjCCAf6gAwIBAgIQTm8+EF94L4FJ0nBFl5LICzANBgkqhkiG9w0BAQsFADAb
MRkwFwYDVQQDDBB1c2VyQGV4YW1wbGUuY29tMCAXDTE1MTAwNTEwMDMwMFoYDzIx
MTUxMDA1MTAwMzAwWjAbMRkwFwYDVQQDDBB1c2VyQGV4YW1wbGUuY29tMIIBIjAN
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Cl/rbhWRnypVnNyS48iWanKR0em
y0t8aDLe6OF2PUabmDdP/Xu7rREM19mB9c2eYC3U21lbCdNlksZS8pWKizcXpCtY
KpcBuyudFcSGRDcPSMPaXouBpow9WzxiOQ30qY72pAj6HZZXn5W+t6oJnzFOzD8u
vcptvc6sAEMRrdq7NTfSuW5pfaZMfkXM5lbBDdgbZrBptaNErYoHl/hIKCGiHauE
pWpUP1tpyGPxt2r8xjht2BHV6gFK582Wn8IuIGXag/9oBvFEavjpqbbYOrC6qraa
vTGoaWgraQHyGvWKbROFCpX46Wxjn+PMFhtwsFF/F93iNrzs6A2B2WPz0QIDAQAB
o1QwUjAOBgNVHQ8BAf8EBAMCBLAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDAYDVR0T
AQH/BAIwADAdBgNVHQ4EFgQUMgZRdUW5s+sgh7EC2pHpvOGQzUgwDQYJKoZIhvcN
AQELBQADggEBAJDi3pmzVvjJdTQCwFJEZvem9y64jHN+9MxM2rpwem0ZdQj+Cqst
iTRJZ7zW4alBec76qA0/BXN7kI2zm5+AtoDxUIUi18jUK8Y6b3qq7lInykE2al9e
xSgnRhaEJUxN2V5kkmhbdXBip70jazQZZbxQgYAZXhsX2rC39spt5Jz6NG24q4Eg
egBBHhV8p9mvaYUXLJUnL98ZSz2Zplw8YSR3LxJsko6uKYnJl0WRnt+O3eNodj7Y
3TKeUdX+KE01n8/QjJCiDd6QyyqDxtIfCVdvrlMbBGGNBY4TZ39RIpGunbe/zuLC
5hx0nLLS6LB2x2UaYdSkKnIlM5BCDnCt/38="));
public ClientCertificateHelper()
{
}
public object[][] ValidClientCertificates
{
get
{
return new object[][]
{
new object[] { _cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_PrivateKey },
new object[] { _cert_KeyUsageIncludesDigitalSignature_NoEKU_PrivateKey }
};
}
}
public X509Certificate2Collection ValidClientCertificateCollection
{
get
{
X509Certificate2Collection certs = new X509Certificate2Collection();
certs.Add(_cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_PrivateKey);
certs.Add(_cert_KeyUsageIncludesDigitalSignature_NoEKU_PrivateKey);
return certs;
}
}
public object[][] InvalidClientCertificates
{
get
{
return new object[][]
{
new object[] { _cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_NoPrivateKey },
new object[] { _cert_KeyUsageMissingDigitalSignature_EKUIncludesClientAuth_PrivateKey },
new object[] { _cert_KeyUsageIncludesDigitalSignature_EKUMissingClientAuth_PrivateKey }
};
}
}
public X509Certificate2Collection InvalidClientCertificateCollection
{
get
{
X509Certificate2Collection certs = new X509Certificate2Collection();
certs.Add(_cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_NoPrivateKey);
certs.Add(_cert_KeyUsageMissingDigitalSignature_EKUIncludesClientAuth_PrivateKey);
certs.Add(_cert_KeyUsageIncludesDigitalSignature_EKUMissingClientAuth_PrivateKey);
return certs;
}
}
public X509Certificate2Collection ValidAndInvalidClientCertificateCollection
{
get
{
X509Certificate2Collection certs = new X509Certificate2Collection();
certs.Add(_cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_NoPrivateKey);
certs.Add(_cert_KeyUsageMissingDigitalSignature_EKUIncludesClientAuth_PrivateKey);
certs.Add(_cert_KeyUsageIncludesDigitalSignature_EKUIncludesClientAuth_PrivateKey);
certs.Add(_cert_KeyUsageIncludesDigitalSignature_EKUMissingClientAuth_PrivateKey);
return certs;
}
}
}
}

View File

@@ -0,0 +1,189 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography.X509Certificates;
using Xunit;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public class ClientCertificateScenarioTest
{
public static object[][] ValidClientCertificates
{
get
{
var helper = new ClientCertificateHelper();
return helper.ValidClientCertificates;
}
}
public static object[][] InvalidClientCertificates
{
get
{
var helper = new ClientCertificateHelper();
return helper.InvalidClientCertificates;
}
}
public ClientCertificateScenarioTest()
{
TestControl.ResetAll();
}
[Fact]
public void NonSecureRequest_AddNoCertificates_CertificateContextNotSet()
{
using (var handler = new WinHttpHandler())
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeServerEndpoint))
{
Assert.Equal(0, APICallHistory.WinHttpOptionClientCertContext.Count);
}
}
[Theory, MemberData(nameof(ValidClientCertificates))]
public void NonSecureRequest_AddValidCertificate_CertificateContextNotSet(X509Certificate2 certificate)
{
using (var handler = new WinHttpHandler())
{
handler.ClientCertificates.Add(certificate);
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeServerEndpoint))
{
Assert.Equal(0, APICallHistory.WinHttpOptionClientCertContext.Count);
}
}
}
[Fact]
public void SecureRequest_AddNoCertificates_NullCertificateContextSet()
{
using (var handler = new WinHttpHandler())
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.Equal(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
[Theory, MemberData(nameof(ValidClientCertificates))]
public void SecureRequest_AddValidCertificate_ValidCertificateContextSet(X509Certificate2 certificate)
{
using (var handler = new WinHttpHandler())
{
handler.ClientCertificates.Add(certificate);
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.NotEqual(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
}
[Theory, MemberData(nameof(InvalidClientCertificates))]
public void SecureRequest_AddInvalidCertificate_NullCertificateContextSet(X509Certificate2 certificate)
{
using (var handler = new WinHttpHandler())
{
handler.ClientCertificates.Add(certificate);
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.Equal(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
}
[Fact]
public void SecureRequest_ClientCertificateOptionAutomatic_CertStoreEmpty_NullCertificateContextSet()
{
using (var handler = new WinHttpHandler())
{
handler.ClientCertificateOption = ClientCertificateOption.Automatic;
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.Equal(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
}
[Fact]
public void SecureRequest_ClientCertificateOptionAutomatic_CertStoreHasInvalidCerts_NullCertificateContextSet()
{
using (var handler = new WinHttpHandler())
{
var helper = new ClientCertificateHelper();
TestControl.CurrentUserCertificateStore = helper.InvalidClientCertificateCollection;
handler.ClientCertificateOption = ClientCertificateOption.Automatic;
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.Equal(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
}
[Fact]
public void SecureRequest_ClientCertificateOptionAutomatic_CertStoreHasValidCerts_ValidCertificateContextSet()
{
using (var handler = new WinHttpHandler())
{
var helper = new ClientCertificateHelper();
TestControl.CurrentUserCertificateStore = helper.ValidClientCertificateCollection;
handler.ClientCertificateOption = ClientCertificateOption.Automatic;
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.NotEqual(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
}
[Fact]
public void SecureRequest_ClientCertificateOptionAutomatic_CertStoreHasValidAndInvalidCerts_ValidCertificateContextSet()
{
using (var handler = new WinHttpHandler())
{
var helper = new ClientCertificateHelper();
TestControl.CurrentUserCertificateStore = helper.ValidAndInvalidClientCertificateCollection;
handler.ClientCertificateOption = ClientCertificateOption.Automatic;
using (HttpResponseMessage response = SendRequestHelper.Send(
handler,
() => { },
TestServer.FakeSecureServerEndpoint))
{
Assert.Equal(1, APICallHistory.WinHttpOptionClientCertContext.Count);
Assert.NotEqual(IntPtr.Zero, APICallHistory.WinHttpOptionClientCertContext[0]);
}
}
}
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard1.3-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Net.Http.WinHttpHandlerUnitTests;
namespace System.Net.Http
{
public static class Marshal
{
public static int GetLastWin32Error()
{
if (TestControl.LastWin32Error != 0)
{
return TestControl.LastWin32Error;
}
return System.Runtime.InteropServices.Marshal.GetLastWin32Error();
}
public static IntPtr AllocHGlobal(int cb)
{
return System.Runtime.InteropServices.Marshal.AllocHGlobal(cb);
}
public static void FreeHGlobal(IntPtr hglobal)
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(hglobal);
}
public static string PtrToStringUni(IntPtr ptr)
{
return System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr);
}
public static IntPtr StringToHGlobalUni(string s)
{
return System.Runtime.InteropServices.Marshal.StringToHGlobalUni(s);
}
public static void Copy(IntPtr source, byte[] destination, int startIndex, int length)
{
System.Runtime.InteropServices.Marshal.Copy(source, destination, startIndex, length);
}
public static int SizeOf<T>()
{
return System.Runtime.InteropServices.Marshal.SizeOf<T>();
}
public static IntPtr UnsafeAddrOfPinnedArrayElement<T>(T[] arr, int index)
{
return System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement<T>(arr, index);
}
public static T PtrToStructure<T>(IntPtr ptr)
{
return System.Runtime.InteropServices.Marshal.PtrToStructure<T>(ptr);
}
public static void WriteByte(IntPtr ptr, int ofs, byte val)
{
System.Runtime.InteropServices.Marshal.WriteByte(ptr, ofs, val);
}
public static string PtrToStringAnsi(IntPtr ptr, int len)
{
return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr, len);
}
public static void StructureToPtr<T>(T structure, IntPtr ptr, bool fDeleteOld)
{
System.Runtime.InteropServices.Marshal.StructureToPtr<T>(structure, ptr, fDeleteOld);
}
public static int SizeOf<T>(T structure)
{
return System.Runtime.InteropServices.Marshal.SizeOf<T>(structure);
}
public static int ReadInt32(IntPtr ptr)
{
return System.Runtime.InteropServices.Marshal.ReadInt32(ptr);
}
}
}

View File

@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public static class FakeRegistry
{
public static void Reset()
{
WinInetProxySettings.RegistryKeyMissing = false;
WinInetProxySettings.AutoDetect = false;
WinInetProxySettings.AutoConfigUrl = null;
WinInetProxySettings.Proxy = null;
WinInetProxySettings.ProxyBypass = null;
}
public static class WinInetProxySettings
{
public static bool RegistryKeyMissing { get; set; }
public static bool AutoDetect { get; set; }
public static string AutoConfigUrl { get; set; }
public static string Proxy { get; set; }
public static string ProxyBypass { get; set; }
}
}
}

View File

@@ -0,0 +1,125 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
internal class FakeSafeWinHttpHandle : Interop.WinHttp.SafeWinHttpHandle
{
private static int s_HandlesOpen = 0;
private Interop.WinHttp.WINHTTP_STATUS_CALLBACK _callback = null;
private IntPtr _context = IntPtr.Zero;
public FakeSafeWinHttpHandle(bool markAsValid)
{
if (markAsValid)
{
SetHandle(Marshal.AllocHGlobal(1));
Interlocked.Increment(ref s_HandlesOpen);
Debug.WriteLine(
"FakeSafeWinHttpHandle.cctor, handle=#{0}, s_HandlesOpen={1}",
handle.GetHashCode(),
s_HandlesOpen);
}
else
{
SetHandleAsInvalid();
}
}
public static int HandlesOpen
{
get
{
return s_HandlesOpen;
}
}
public Interop.WinHttp.WINHTTP_STATUS_CALLBACK Callback
{
get
{
return _callback;
}
set
{
_callback = value;
}
}
public IntPtr Context
{
get
{
return _context;
}
set
{
_context = value;
}
}
public bool DelayOperation(int delay)
{
if (delay <= 0)
{
return true;
}
// Sleep for delay time specified. Abort if handle becomes closed.
var sw = new Stopwatch();
sw.Start();
while (sw.ElapsedMilliseconds <= delay)
{
if (IsClosed)
{
sw.Stop();
return false;
}
Thread.Sleep(1);
}
sw.Stop();
return true;
}
public void InvokeCallback(uint internetStatus, Interop.WinHttp.WINHTTP_ASYNC_RESULT asyncResult)
{
GCHandle pinnedAsyncResult = GCHandle.Alloc(asyncResult, GCHandleType.Pinned);
IntPtr statusInformation = pinnedAsyncResult.AddrOfPinnedObject();
uint statusInformationLength = (uint)Marshal.SizeOf<Interop.WinHttp.WINHTTP_ASYNC_RESULT>();
InvokeCallback(internetStatus, statusInformation, statusInformationLength);
pinnedAsyncResult.Free();
}
public void InvokeCallback(uint internetStatus, IntPtr statusInformation, uint statusInformationLength)
{
_callback(DangerousGetHandle(), _context, internetStatus, statusInformation, statusInformationLength);
}
protected override bool ReleaseHandle()
{
Interlocked.Decrement(ref s_HandlesOpen);
Debug.WriteLine(
"FakeSafeWinHttpHandle.ReleaseHandle, handle=#{0}, s_HandlesOpen={1}",
handle.GetHashCode(),
s_HandlesOpen);
return base.ReleaseHandle();
}
}
}

View File

@@ -0,0 +1,47 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
using System.Net.Http.WinHttpHandlerUnitTests;
using System.Security.Cryptography.X509Certificates;
namespace System.Net.Http
{
public class X509Store : IDisposable
{
private bool _disposed;
public X509Store(StoreName storeName, StoreLocation storeLocation)
{
Debug.Assert(storeName == StoreName.My);
Debug.Assert(storeLocation == StoreLocation.CurrentUser);
}
public X509Certificate2Collection Certificates
{
get
{
return TestControl.CurrentUserCertificateStore;
}
}
public void Open(OpenFlags flags)
{
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
_disposed = true;
}
}
}
}

View File

@@ -0,0 +1,179 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using Xunit;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public class SafeWinHttpHandleTest
{
[ActiveIssue(13951)]
[Fact]
public void CreateAddRefDispose_HandleIsNotClosed()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
bool success = false;
safeHandle.DangerousAddRef(ref success);
Assert.True(success, "DangerousAddRef");
safeHandle.Dispose();
Assert.False(safeHandle.IsClosed, "closed");
Assert.Equal(1, FakeSafeWinHttpHandle.HandlesOpen);
// Clean up safeHandle to keep outstanding handles at zero.
safeHandle.DangerousRelease();
}
[ActiveIssue(13951)]
[Fact]
public void CreateAddRefDisposeDispose_HandleIsNotClosed()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
bool success = false;
safeHandle.DangerousAddRef(ref success);
Assert.True(success, "DangerousAddRef");
safeHandle.Dispose();
safeHandle.Dispose();
Assert.False(safeHandle.IsClosed, "closed");
Assert.Equal(1, FakeSafeWinHttpHandle.HandlesOpen);
// Clean up safeHandle to keep outstanding handles at zero.
safeHandle.DangerousRelease();
}
[ActiveIssue(13951)]
[Fact]
public void CreateAddRefDisposeRelease_HandleIsClosed()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
bool success = false;
safeHandle.DangerousAddRef(ref success);
Assert.True(success, "DangerousAddRef");
safeHandle.Dispose();
safeHandle.DangerousRelease();
Assert.True(safeHandle.IsClosed, "closed");
Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
}
[ActiveIssue(13951)]
[Fact]
public void CreateAddRefRelease_HandleIsNotClosed()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
bool success = false;
safeHandle.DangerousAddRef(ref success);
Assert.True(success, "DangerousAddRef");
safeHandle.DangerousRelease();
Assert.False(safeHandle.IsClosed, "closed");
Assert.Equal(1, FakeSafeWinHttpHandle.HandlesOpen);
// Clean up safeHandle to keep outstanding handles at zero.
safeHandle.Dispose();
}
[ActiveIssue(13951)]
[Fact]
public void CreateAddRefReleaseDispose_HandleIsClosed()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
bool success = false;
safeHandle.DangerousAddRef(ref success);
Assert.True(success, "DangerousAddRef");
safeHandle.DangerousRelease();
safeHandle.Dispose();
Assert.True(safeHandle.IsClosed, "closed");
Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
}
[ActiveIssue(13951)]
[Fact]
public void CreateDispose_HandleIsClosed()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
safeHandle.Dispose();
Assert.True(safeHandle.IsClosed, "closed");
}
[ActiveIssue(13951)]
[Fact]
public void CreateDisposeDispose_HandleIsClosedAndSecondDisposeIsNoop()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
safeHandle.Dispose();
safeHandle.Dispose();
Assert.True(safeHandle.IsClosed, "closed");
}
[ActiveIssue(13951)]
[Fact]
public void CreateDisposeAddRef_ThrowsObjectDisposedException()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
safeHandle.Dispose();
Assert.Throws<ObjectDisposedException>(() =>
{ bool ignore = false; safeHandle.DangerousAddRef(ref ignore); });
}
[ActiveIssue(13951)]
[Fact]
public void CreateDisposeRelease_ThrowsObjectDisposedException()
{
var safeHandle = new FakeSafeWinHttpHandle(true);
safeHandle.Dispose();
Assert.Throws<ObjectDisposedException>(() => safeHandle.DangerousRelease());
}
[ActiveIssue(13951)]
[Fact]
public void SetParentHandle_CreateParentCreateChildDisposeParent_ParentNotClosed()
{
var parentHandle = new FakeSafeWinHttpHandle(true);
var childHandle = new FakeSafeWinHttpHandle(true);
childHandle.SetParentHandle(parentHandle);
parentHandle.Dispose();
Assert.False(parentHandle.IsClosed, "closed");
Assert.Equal(2, FakeSafeWinHttpHandle.HandlesOpen);
// Clean up safeHandles to keep outstanding handles at zero.
childHandle.Dispose();
}
[ActiveIssue(13951)]
[Fact]
public void SetParentHandle_CreateParentCreateChildDisposeParentDisposeChild_HandlesClosed()
{
var parentHandle = new FakeSafeWinHttpHandle(true);
var childHandle = new FakeSafeWinHttpHandle(true);
childHandle.SetParentHandle(parentHandle);
parentHandle.Dispose();
childHandle.Dispose();
Assert.True(parentHandle.IsClosed, "closed");
Assert.True(childHandle.IsClosed, "closed");
}
[ActiveIssue(13951)]
[Fact]
public void SetParentHandle_CreateParentCreateChildDisposeChildDisposeParent_HandlesClosed()
{
var parentHandle = new FakeSafeWinHttpHandle(true);
var childHandle = new FakeSafeWinHttpHandle(true);
childHandle.SetParentHandle(parentHandle);
childHandle.Dispose();
parentHandle.Dispose();
Assert.True(parentHandle.IsClosed, "closed");
Assert.True(childHandle.IsClosed, "closed");
}
}
}

View File

@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public static class SendRequestHelper
{
public static HttpResponseMessage Send(WinHttpHandler handler, Action setup)
{
return Send(handler, setup, TestServer.FakeServerEndpoint);
}
public static HttpResponseMessage Send(WinHttpHandler handler, Action setup, string fakeServerEndpoint)
{
TestServer.SetResponse(DecompressionMethods.None, TestServer.ExpectedResponseBody);
setup();
var invoker = new HttpMessageInvoker(handler, false);
var request = new HttpRequestMessage(HttpMethod.Get, fakeServerEndpoint);
Task<HttpResponseMessage> task = invoker.SendAsync(request, CancellationToken.None);
return task.GetAwaiter().GetResult();
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Net.Http.WinHttpHandler.Unit.Tests.csproj">
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>netcoreapp;netcoreapp1.0;net46</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{A2ECDEDB-12B7-402C-9230-152B7601179F}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<TargetingPackExclusions Include="System.Net.Http.WinHttpHandler" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' ">
<Compile Include="$(CommonTestPath)\System\Net\SslProtocolSupport.cs">
<Link>CommonTest\System\Net\SslProtocolSupport.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Crypt32\Interop.certificates_types.cs">
<Link>Common\Interop\Windows\Crypt32\Interop.certificates_types.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Interop.HRESULT_FROM_WIN32.cs">
<Link>Common\Interop\Windows\Interop.HRESULT_FROM_WIN32.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\winhttp\Interop.SafeWinHttpHandle.cs">
<Link>Common\Interop\Windows\winhttp\Interop.SafeWinHttpHandle.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\winhttp\Interop.winhttp_types.cs">
<Link>Common\Interop\Windows\winhttp\Interop.winhttp_types.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\CharArrayHelpers.cs">
<Link>Common\System\CharArrayHelpers.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\StringExtensions.cs">
<Link>Common\System\StringExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Diagnostics\ExceptionExtensions.cs">
<Link>Common\System\Diagnostics\ExceptionExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\StreamHelpers.CopyValidation.cs">
<Link>Common\System\IO\StreamHelpers.CopyValidation.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
<Link>Common\System\Net\HttpKnownHeaderNames.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.TryGetHeaderName.cs">
<Link>Common\System\Net\HttpKnownHeaderNames.TryGetHeaderName.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpStatusDescription.cs">
<Link>Common\System\Net\HttpStatusDescription.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpVersionInternal.cs">
<Link>Common\System\Net\HttpVersionInternal.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\UriScheme.cs">
<Link>Common\System\Net\UriScheme.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\SecurityProtocol.cs">
<Link>Common\System\Net\SecurityProtocol.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerDefaults.cs">
<Link>Common\System\Net\Http\HttpHandlerDefaults.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerDiagnosticListenerExtensions.cs">
<Link>Common\System\Net\Http\HttpHandlerDiagnosticListenerExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerLoggingStrings.cs">
<Link>Common\System\Net\Http\HttpHandlerLoggingStrings.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Http\NoWriteNoSeekStreamContent.cs">
<Link>Common\System\Net\Http\NoWriteNoSeekStreamContent.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Http\WinHttpException.cs">
<Link>Common\System\Net\Http\WinHttpException.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Threading\Tasks\RendezvousAwaitable.cs">
<Link>Common\System\Threading\Tasks\RendezvousAwaitable.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpAuthHelper.cs">
<Link>ProductionCode\WinHttpAuthHelper.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpCertificateHelper.cs">
<Link>ProductionCode\WinHttpCertificateHelper.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpChannelBinding.cs">
<Link>ProductionCode\WinHttpChannelBinding.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpCookieContainerAdapter.cs">
<Link>ProductionCode\WinHttpCookieContainerAdapter.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpHandler.cs">
<Link>ProductionCode\WinHttpHandler.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpRequestCallback.cs">
<Link>ProductionCode\WinHttpRequestCallback.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpRequestState.cs">
<Link>ProductionCode\WinHttpRequestState.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpRequestStream.cs">
<Link>ProductionCode\WinHttpRequestStream.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpResponseHeaderReader.cs">
<Link>ProductionCode\WinHttpResponseHeaderReader.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpResponseParser.cs">
<Link>ProductionCode\WinHttpResponseParser.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpResponseStream.cs">
<Link>ProductionCode\WinHttpResponseStream.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpTraceHelper.cs">
<Link>ProductionCode\WinHttpTraceHelper.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinHttpTransportContext.cs">
<Link>ProductionCode\WinHttpTransportContext.cs</Link>
</Compile>
<Compile Include="..\..\src\System\Net\Http\WinInetProxyHelper.cs">
<Link>ProductionCode\WinInetProxyHelper.cs</Link>
</Compile>
<Compile Include="APICallHistory.cs" />
<Compile Include="ClientCertificateHelper.cs" />
<Compile Include="ClientCertificateScenarioTest.cs" />
<Compile Include="FakeInterop.cs" />
<Compile Include="FakeMarshal.cs" />
<Compile Include="FakeRegistry.cs" />
<Compile Include="FakeSafeWinHttpHandle.cs" />
<Compile Include="FakeX509Certificates.cs" />
<Compile Include="SafeWinHttpHandleTest.cs" />
<Compile Include="SendRequestHelper.cs" />
<Compile Include="TestServer.cs" />
<Compile Include="TestControl.cs" />
<Compile Include="WinHttpHandlerTest.cs" />
<Compile Include="WinHttpRequestStreamTest.cs" />
<Compile Include="WinHttpResponseHeaderReaderTest.cs" />
<Compile Include="WinHttpResponseStreamTest.cs" />
<Compile Include="XunitTestAssemblyAtrributes.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,100 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
namespace System.Net.Http.WinHttpHandlerUnitTests
{
public static class TestControl
{
public static ApiControl WinHttpOpen { get; private set; }
public static ApiControl WinHttpQueryDataAvailable { get; private set; }
public static ApiControl WinHttpReadData { get; private set; }
public static ApiControl WinHttpReceiveResponse { get; private set; }
public static ApiControl WinHttpWriteData { get; private set; }
public static int LastWin32Error { get; set; }
public static bool WinHttpAutomaticProxySupport { get; set; }
public static bool WinHttpDecompressionSupport { get; set; }
public static bool PACFileNotDetectedOnNetwork { get; set; }
public static X509Certificate2Collection CurrentUserCertificateStore{ get; set; }
public static void Reset()
{
WinHttpOpen = new ApiControl();
WinHttpQueryDataAvailable = new ApiControl();
WinHttpReadData = new ApiControl();
WinHttpReceiveResponse = new ApiControl();
WinHttpWriteData = new ApiControl();
WinHttpAutomaticProxySupport = true;
WinHttpDecompressionSupport = true;
LastWin32Error = 0;
PACFileNotDetectedOnNetwork = false;
CurrentUserCertificateStore = new X509Certificate2Collection();
}
public static void ResetAll()
{
APICallHistory.Reset();
FakeRegistry.Reset();
TestControl.Reset();
TestServer.Reset();
}
}
public sealed class ApiControl : IDisposable
{
private bool _disposed = false;
private ManualResetEvent _callbackCompletionEvent;
public ApiControl()
{
ErrorWithApiCall = false;
ErrorOnCompletion = false;
Delay = 0;
_callbackCompletionEvent = new ManualResetEvent(true);
}
public bool ErrorWithApiCall { get; set; }
public bool ErrorOnCompletion { get; set; }
public int Delay { get; set; }
public void Pause()
{
_callbackCompletionEvent.Reset();
}
public void Resume()
{
_callbackCompletionEvent.Set();
}
public void Wait()
{
_callbackCompletionEvent.WaitOne();
}
public void Dispose()
{
if (_disposed)
{
return;
}
_disposed = true;
_callbackCompletionEvent.Dispose();
}
}
}

Some files were not shown because too many files have changed in this diff Show More